Sha256: 4d2de60e982d030d009ede9ea00a5d45d263c836c83fd27f63a3321d927b2f7b

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require "rubygems"

module Lono
  class Jadespec
    extend Memoist

    delegate :name, to: :gemspec

    attr_accessor :from
    attr_reader :root, :source_type
    def initialize(root, source_type)
      @root, @source_type = root, source_type
    end

    def exist?
      !!gemspec_file
    end

    def gemspec
      Gem::Specification::load(gemspec_file)
    end
    memoize :gemspec

    def gemspec_file
      Dir.glob("#{@root}/*.gemspec").first
    end

    def lono_type
      metadata["lono_type"] || detect_type
    end

    def detect_type
      configset = Dir.glob("#{@root}/lib/configset.*").size > 0
      configset ? "configset" : "blueprint"
    end

    def lono_strategy
      return metadata["lono_strategy"] if metadata["lono_strategy"]
      lono_type == "blueprint" ? "dsl" : "erb" # TODO: default to dsl for configset also in next major release
    end

    # backward-compatiable for now
    def auto_camelize
      metadata["lono_auto_camelize"] || false
    end

    def metadata
      gemspec.metadata || {}
    end
    memoize :metadata
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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