Class: Blondie::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/blondie/builder.rb

Constant Summary collapse

RUBY_GEMS_URL =
"https://rubygems.org/downloads/".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile_path) ⇒ Builder

Returns a new instance of Builder.



10
11
12
# File 'lib/blondie/builder.rb', line 10

def initialize(gemfile_path)
  @gemfile_path = gemfile_path
end

Instance Attribute Details

#gemfile_pathObject (readonly)

Returns the value of attribute gemfile_path.



8
9
10
# File 'lib/blondie/builder.rb', line 8

def gemfile_path
  @gemfile_path
end

Instance Method Details

#urlsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/blondie/builder.rb', line 14

def urls
  @urls ||= {}.tap do |hash|
    gems_hash.each do |key, value|
      version = value.last&.gsub(/\"|'/, "")
      specifier = value.first.gsub(/\"|'/, "") if value.count == 2
      specifier&.gsub!("\"", "")
      library = key.gsub(/('|,|")/, "")
      url = "#{RUBY_GEMS_URL}#{library}"
      url += versioned_url(library, specifier, version)
      hash[library] = url
    end
  end
end