Class: Bundler::AsOf::ReleaseWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/as_of.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, release_json) ⇒ ReleaseWrapper

Returns a new instance of ReleaseWrapper.



113
114
115
116
117
118
# File 'lib/bundler/as_of.rb', line 113

def initialize(name, release_json)
  @name = name
  @version = Gem::Version.new(release_json["number"])
  @date = Date.parse(release_json["created_at"])
  @prerelease = release_json["prerelease"]
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



112
113
114
# File 'lib/bundler/as_of.rb', line 112

def date
  @date
end

#nameObject (readonly)

Returns the value of attribute name.



112
113
114
# File 'lib/bundler/as_of.rb', line 112

def name
  @name
end

#prereleaseObject (readonly)

Returns the value of attribute prerelease.



112
113
114
# File 'lib/bundler/as_of.rb', line 112

def prerelease
  @prerelease
end

#versionObject (readonly)

Returns the value of attribute version.



112
113
114
# File 'lib/bundler/as_of.rb', line 112

def version
  @version
end

Instance Method Details

#dependenciesObject



124
125
126
# File 'lib/bundler/as_of.rb', line 124

def dependencies
  gem_info.find { |info| info[:number] == version.to_s }[:dependencies] || []
end

#gem_infoObject



128
129
130
# File 'lib/bundler/as_of.rb', line 128

def gem_info
  @gem_info ||= Marshal.load(::URI.parse(gem_url).open.read)
end

#gem_urlObject



132
133
134
# File 'lib/bundler/as_of.rb', line 132

def gem_url
  @gem_url ||= "https://rubygems.org/api/v1/dependencies?gems=#{name}"
end

#to_sObject



120
121
122
# File 'lib/bundler/as_of.rb', line 120

def to_s
  [name, version.to_s, date.to_s, prerelease, dependencies.to_s].to_s
end