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.10 lib/site_hook/methods.rb
site_hook-1.0.9 lib/site_hook/methods.rb
site_hook-1.0.8 lib/site_hook/methods.rb
site_hook-1.0.7 lib/site_hook/methods.rb
site_hook-1.0.6 lib/site_hook/methods.rb
site_hook-1.0.5 lib/site_hook/methods.rb
site_hook-1.0.4 lib/site_hook/methods.rb
site_hook-1.0.3 lib/site_hook/methods.rb
site_hook-1.0.2 lib/site_hook/methods.rb
site_hook-1.0.1 lib/site_hook/methods.rb
site_hook-1.0.0 lib/site_hook/methods.rb
site_hook-0.9.20 lib/site_hook/methods.rb
site_hook-0.9.19 lib/site_hook/methods.rb