Sha256: a7b66ad67913adc6ba5d3b222f63aaf9a7a52abca39f758add2a8c88861f8b54
Contents?: true
Size: 922 Bytes
Versions: 1
Compression:
Stored size: 922 Bytes
Contents
require 'gemfile_entry/version' # module GemfileEntry 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 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 end # Your new gem is a module by default. You may wish to use a class instead.
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gemfile_entry-0.0.0 | lib/gemfile_entry.rb |