Module: GemfileEntry
- Defined in:
- lib/gemfile_entry.rb,
lib/gemfile_entry/version.rb
Constant Summary collapse
- VERSION =
'0.0.0'.freeze
Class Method Summary collapse
Class Method Details
.active(gem1) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/gemfile_entry.rb', line 14 def self.active(gem1) # NOTE: The delete and gsub commands do not work for removing # substrings containing dashes. # As a result, - is converted to _. path = `bundle show #{gem1}` path_last = path.split('/').last path_last_u = path_last.tr('-', '_') gem1_u = gem1.tr('-', '_') version = path_last_u.delete(gem1_u).delete('_').delete("\n") gemfile_line = "gem '#{gem1}', '#{version}'" gemfile_line end |
.latest(gem1) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/gemfile_entry.rb', line 5 def self.latest(gem1) # rubocop:disable Metrics/LineLength version_json = `curl -s https://rubygems.org/api/v1/versions/#{gem1}/latest.json` # rubocop:enable Metrics/LineLength version = version_json.delete('"').delete('{\version\:\)').delete('\}') gemfile_line = "gem '#{gem1}', '#{version}'" gemfile_line end |