gem_paths 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e3d058c9c410d4ea5dc5cb24eafb7dbf7ddca4370f19931e8efe2c85be0b178
4
- data.tar.gz: 9372762550102ec570e2b2d4b438ba9b35159de9d872339e0a270d909293757c
3
+ metadata.gz: ab575f0abbcb7374009cff4885ece82452980429f918a9295d6ae0f4788532ef
4
+ data.tar.gz: a8fa38a8bb06e89517f98f9f0614be555a7d0edcaa1a15bae60244cbdac1fe55
5
5
  SHA512:
6
- metadata.gz: 3b6a76a7da04548498ab5a70e1f24878abacb554efa5e043828a8ed20365cbb71f739d72aa514df706177443c90efd22ed09523e37d1653b5f9b81d4d63cb7f8
7
- data.tar.gz: 34f371a1d60d58fafa8c436907a9d989e845c5a4d4254b2b5f92c6f220f945bce4060d4ff03fbb82adac036c00b01e960f157461ded2d349f98bb0fd24fbe0b6
6
+ metadata.gz: 90679cc1226dbb20828748c06dd60d213550322a12b576f38f04d218f7caef772723f56cade9300be929af467edd6c254eeef9891f345d9d29b3b8478ebf5520
7
+ data.tar.gz: 195b1933fac5e118dcc56dca7324801148be81f0cb7ebb4c42d22aed737db161a956b594c6d6b6093db83b33995aa2d2cbe5be9d17741e476b6c0234d618d54e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gem_paths (0.1.0)
4
+ gem_paths (0.2.0)
5
5
  bundler (~> 2.0)
6
6
  thor (~> 0.20)
7
7
 
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # GemPaths
2
+
3
+ GemPaths can display the paths to the gems Bundler has/will install. It can display the paths in different formats (currently GNU Make, YAML and JSON format) and optionally display a warning if one or more of the gems have not yet been installed.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gem_paths'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gem_paths
20
+
21
+ ## Usage
22
+
23
+ To display a help text, do:
24
+
25
+ $ gempaths
26
+
27
+ To display the path for each installed gem, do:
28
+
29
+ $ gempaths list
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` and `cucumber features`
34
+ to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
+
36
+ To install your local copy of this gem onto your local machine, run `bundle exec rake install`.
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ic-factory/gem_paths
data/lib/gem_paths/cli.rb CHANGED
@@ -5,9 +5,26 @@ module GemPaths
5
5
  class CLI < Thor
6
6
 
7
7
  desc "list", "List path of each gem"
8
- # option :format, :type => :string, :banner => 'text|make', :desc => 'Specify the output format'
8
+ option :format, :type => :string, :banner => 'yaml|json|make', :default => "make", :desc => 'Specify the output format'
9
9
  def list
10
- puts GemPaths::List.to_make
10
+ defaults = {"format" => "make"}
11
+ opt = defaults.merge(options)
12
+ begin
13
+ case opt['format']
14
+ when 'yaml'
15
+ say GemPaths::List.to_yaml
16
+ when 'json'
17
+ puts GemPaths::List.to_json
18
+ when 'make'
19
+ puts GemPaths::List.to_make
20
+ else
21
+ shell.error set_color("Invalid value for --format option. Try 'gempaths help list' for more info.", Thor::Shell::Color::RED)
22
+ exit(2)
23
+ end
24
+ rescue
25
+ shell.error set_color("Unexpected error occurred. Please make sure you have a Gemfile.lock file in your project.", Thor::Shell::Color::RED)
26
+ exit(3)
27
+ end
11
28
  end
12
29
 
13
30
  end
@@ -4,18 +4,28 @@ module GemPaths
4
4
 
5
5
  def self.gem_name_path_map
6
6
  Bundler.load.specs.sort_by(&:name).map { |s|
7
- [
8
- s.name,
9
- s.full_gem_path,
10
- ]
7
+ [s.name, s.full_gem_path]
11
8
  }
12
9
  end
13
10
  private_class_method :gem_name_path_map
14
11
 
15
12
 
16
13
  def self.to_make
17
- gem_name_path_map.map { |pair| "gempath(#{pair[0]}) := #{pair[1]}" }
14
+ gem_name_path_map.map { |pair| "gem-path-#{pair[0]} := #{pair[1]}" }
18
15
  end
16
+
17
+ def self.to_yaml
18
+ str = "---\n"
19
+ str << "gem:\n"
20
+ str << " path:\n"
21
+ str << gem_name_path_map.map { |pair| " #{pair[0]}: #{pair[1]}" }.join("\n")
22
+ end
23
+
24
+ def self.to_json
25
+ require 'json'
26
+ JSON.pretty_generate(gem_name_path_map)
27
+ end
28
+
19
29
  end
20
30
 
21
31
  end
@@ -1,3 +1,3 @@
1
1
  module GemPaths
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_paths
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Torben Jacobsen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2019-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,6 +109,7 @@ files:
109
109
  - Gemfile
110
110
  - Gemfile.lock
111
111
  - LICENSE
112
+ - README.md
112
113
  - Rakefile
113
114
  - bin/console
114
115
  - bin/setup