Sha256: e7a9f8ed299e9614a45ed8ba14cc5907f6ef8cd7d39a4dff997bf25c04dceaad

Contents?: true

Size: 1.31 KB

Versions: 33

Compression:

Stored size: 1.31 KB

Contents

require "site_hook/config"

module SiteHook
  class Methods
    def self.mklogdir
      path = SiteHook::Paths.logs
      if path.exist?
        STDERR.puts "'#{path}' exists, skipping.."
        # Path exists, don't do anything
      else
        STDERR.puts "'#{path}' does not exist. Creating..."
        FileUtils.mkpath(path.to_s)
      end
    end
    def self.mkconfdir
      path = SiteHook::Paths.dir
      if path.exist?
        STDERR.puts "'#{path}' exists, skipping.."
      else
        STDERR.puts "'#{path}' does not exist. Creating..."
      end
    end
    def self.mkconf
      path = SiteHook::Paths.config
      if path.exist?
        STDERR.puts "'#{path}' exists, skipping.."
      else
        STDERR.puts "'#{path}' does not exist. Creating..."
        TTY::File.create_file(path, SiteHook::ConfigSections.all_samples)
      end
    end

    # @param [String] hook_name the hook name as defined in the projects:... directive
    def self.find_hook(hook_name)
      project_objs = SiteHook::Configs::Projects.constants
      ret_val = project_objs.detect do |obj|
        SiteHook::Configs::Projects.const_get(obj.to_s).real_key.to_s == hook_name.to_s
      end
      if ret_val.nil?
        return nil
      elsif ret_val
        return SiteHook::Configs::Projects.const_get(ret_val)
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
site_hook-1.0.30 lib/site_hook/methods.rb
site_hook-1.0.29 lib/site_hook/methods.rb
site_hook-1.0.28 lib/site_hook/methods.rb
site_hook-1.0.27 lib/site_hook/methods.rb
site_hook-1.0.26 lib/site_hook/methods.rb
site_hook-1.0.25 lib/site_hook/methods.rb
site_hook-1.0.24 lib/site_hook/methods.rb
site_hook-1.0.23 lib/site_hook/methods.rb
site_hook-1.0.22 lib/site_hook/methods.rb
site_hook-1.0.21 lib/site_hook/methods.rb
site_hook-1.0.20 lib/site_hook/methods.rb
site_hook-1.0.19 lib/site_hook/methods.rb
site_hook-1.0.18 lib/site_hook/methods.rb
site_hook-1.0.17 lib/site_hook/methods.rb
site_hook-1.0.16 lib/site_hook/methods.rb
site_hook-1.0.15 lib/site_hook/methods.rb
site_hook-1.0.14 lib/site_hook/methods.rb
site_hook-1.0.13 lib/site_hook/methods.rb
site_hook-1.0.12 lib/site_hook/methods.rb
site_hook-1.0.11 lib/site_hook/methods.rb