Class: Lono::Jade::Materializer::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/lono/jade/materializer/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(lono_settings = nil) ⇒ Source

Returns a new instance of Source.



3
4
5
# File 'lib/lono/jade/materializer/source.rb', line 3

def initialize(lono_settings=nil)
  @lono_settings = lono_settings || Lono::Setting.new.data
end

Instance Method Details

#gem_args(jade) ⇒ Object

String provide to gem method in Gemfile. Example:

gem "mygem", "v0.1.0", git: "xxx"


11
12
13
14
15
16
17
18
19
# File 'lib/lono/jade/materializer/source.rb', line 11

def gem_args(jade)
  args = jade.registry.args
  args = args.map { |s| %Q|"#{s}"| }.join(', ')

  options = options(jade)
  options = options.inject([]) { |r,(k,v)| r << %Q|#{k}: "#{v}"| }.join(', ')

  "#{args}, #{options}"
end

#locationObject



43
44
45
46
47
48
# File 'lib/lono/jade/materializer/source.rb', line 43

def location
  ENV["LONO_MATERIALIZED_GEMS_SOURCE"] ||
  Lono::Configset::Register::Blueprint.source ||
  settings["source"] ||
  "[email protected]:boltopspro" # default_location
end

#options(jade) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lono/jade/materializer/source.rb', line 21

def options(jade)
  registry = jade.registry
  options = registry.gem_options
  # Direct source provided as part of configset call
  #
  #    configset("ssm", git: "https://github.com/owner/ssm")
  #    configset("ssm", path: "/path/to/ssm")
  #    configset("ssm", source: "https://rubygems.org")
  #
  if options.key?(:git) || options.key?(:path) || options.key?(:source)
    return(options)
  end

  # Otherwise use the sources location settings, which does not include the repo name
  materalized_options = if location.include?("git@") || location.include?("https")
    {git: "#{location}/#{jade.repo}"}
  else
    {path: "#{location}/#{jade.repo}"}
  end
  materalized_options.merge(options)
end

#settingsObject



50
51
52
# File 'lib/lono/jade/materializer/source.rb', line 50

def settings
  @lono_settings.dig("materialized_gems") || {}
end