Sha256: 689163a4366377809def9bfb85523da6e964ca7d817fe36fea8f4d840778a1bf

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

class Lono::Configset
  class Generator
    def initialize(options)
      @options = options
      @configset = options[:configset]
      @type = options[:type] || "project"
    end

    def run
      check_configset_exist!
      structure = build
      puts YAML.dump(structure)
    end

    def check_configset_exist!
      exist = !!Lono::Finder::Configset.find(@configset)
      unless exist
        puts "configset #{@configset.color(:green)} not found."
        exit 1
      end
    end

    def build
      # Examples:
      #   Erb.new(options).build
      #   Dsl.new(options).build
      generator_class = "Lono::Configset::Strategy::#{strategy.camelize}"
      generator_class = Object.const_get(generator_class)
      generator_class.new(@options.merge(root: configset_root)).build
    end

    def strategy
      jadespec = Lono::Jadespec.new(configset_root, "unknown") # abusing Jadespec to get strategy
      jadespec.lono_strategy
    end

    def configset_root
      finder = finder_class.new
      found = finder.find(@configset, local_only: false)
      found.root if found
    end

    def finder_class
      case @type
      when "project"
        Lono::Finder::Configset
      when "blueprint"
        Lono::Finder::Blueprint::Configset
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lono-7.3.2 lib/lono/configset/generator.rb
lono-7.3.1 lib/lono/configset/generator.rb
lono-7.3.0 lib/lono/configset/generator.rb
lono-7.2.3 lib/lono/configset/generator.rb
lono-7.2.2 lib/lono/configset/generator.rb
lono-7.2.1 lib/lono/configset/generator.rb
lono-7.2.0 lib/lono/configset/generator.rb
lono-7.1.0 lib/lono/configset/generator.rb