gemfile_interpreter 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6a529a9378858c6ab1d69a49e9a0a2d9c2ee8092
4
- data.tar.gz: 924f4814a334e2a97bbe254bef4d1ce04b036f29
3
+ metadata.gz: 8094fe1e397a716636eaf598bfb48483e293738f
4
+ data.tar.gz: eea6a0af918499b7e7ed93fc11088f080ea87417
5
5
  SHA512:
6
- metadata.gz: 72c8cee37e11b88cef07083dc0be9999e37e38ce80d818005adc45f20f2f1228b467d200abb7d5cfc4f71ed8e5f2d155cbe360735af0cb52c8e890097078fa2b
7
- data.tar.gz: 4b6155cc9e3c1d1fa8264499b1e858d5c12d0e177305051593b8cfa0831506366125fce71e14c72a59520f70b4ddf29751cd8e4de30653befc127652c85f19cd
6
+ metadata.gz: 59ad8e61bb194b346a644217c8e28609eef041d6552680be6f46e174f80de877e3575d39d3b04cce873cd1c551571b65e3b40eb4efd76231cfda9a7f6cd9506d
7
+ data.tar.gz: 43c792105098a9c621b17cff93460f6ba1b541107db8ca3938fac76f16555bac28e50605b4a83aebec1edd0560fa58e824ac7a79f585a0b7f44cb6c0f350ad54
@@ -9,14 +9,14 @@ class GemfileInterpreter
9
9
  gemfile_path = File.join dir, gemfile
10
10
  lockfile_path = File.join dir, (lockfile || "#{gemfile}.lock")
11
11
  @parsed = nil
12
- @gems = ReadonlyBundler.load_gemfile gemfile_path, lockfile_path
12
+ @gems, @dependencies = ReadonlyBundler.load_gemfile gemfile_path, lockfile_path
13
13
  true
14
14
  end
15
15
 
16
- attr_reader :gems
16
+ attr_reader :gems, :dependencies
17
17
 
18
18
  def parsed
19
- @parsed = Parser.parse gems
19
+ @parsed = Parser.parse gems, dependencies
20
20
  end
21
21
 
22
22
  def to_json
@@ -3,20 +3,21 @@ require 'bundler'
3
3
  class GemfileInterpreter
4
4
  module Parser
5
5
  class << self
6
- def parse gems
6
+ def parse gems, dependencies
7
7
  hash = {}
8
8
  gems.each do |gem|
9
- hash[gem.name] = parse_gem gem
9
+ hash[gem.name] = parse_gem gem, dependencies
10
10
  end
11
11
  hash
12
12
  end
13
13
 
14
- def parse_gem gem
14
+ def parse_gem gem, dependencies
15
15
  hash = {}
16
16
  [:version, :full_name, :platform, :remote].map do |method|
17
17
  hash[method.to_s] = gem.send(method).to_s
18
18
  end
19
19
  hash['source'] = parse_source gem.source
20
+ hash['in_gemfile'] = dependencies.any? {|d| d.name == gem.name }
20
21
  hash
21
22
  end
22
23
 
@@ -15,7 +15,7 @@ class GemfileInterpreter
15
15
  @default_lockfile = Pathname.new lockfile
16
16
  ensure_file_exists! default_gemfile, GemfileMissingError
17
17
  ensure_file_exists! default_lockfile, GemfileLockMissingError
18
- definition.resolve
18
+ return definition.resolve, definition.dependencies
19
19
  end
20
20
 
21
21
  def default_gemfile
@@ -1,3 +1,3 @@
1
1
  class GemfileInterpreter
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -33,7 +33,7 @@ RSpec.describe GemfileInterpreter do
33
33
  rubygems_gem('railties', '5.0.1'),
34
34
  rubygems_gem('responders', '2.3.0'),
35
35
  rubygems_gem('warden', '1.2.7'),
36
- rubygems_gem('devise', '4.2.0'),
36
+ rubygems_gem('devise', '4.2.0', true),
37
37
  rubygems_gem('multipart-post', '2.0.0'),
38
38
  rubygems_gem('faraday', '0.10.1'),
39
39
  rubygems_gem('hashie', '3.5.3'),
@@ -43,7 +43,7 @@ RSpec.describe GemfileInterpreter do
43
43
  rubygems_gem('oauth2', '1.3.0'),
44
44
  rubygems_gem('omniauth', '1.6.1'),
45
45
  rubygems_gem('omniauth-oauth2', '1.3.1'),
46
- git_gem('omniauth-keltec', '0.0.1', 'https://github.com/ThunderKey/omniauth-keltec.git', 'd954a55459b48cb56be4dbbcaa1fd2afc113db5b'),
46
+ git_gem('omniauth-keltec', '0.0.1', 'https://github.com/ThunderKey/omniauth-keltec.git', 'd954a55459b48cb56be4dbbcaa1fd2afc113db5b', true),
47
47
  ]
48
48
  end
49
49
 
@@ -75,7 +75,7 @@ RSpec.describe GemfileInterpreter do
75
75
  rubygems_gem('railties', '5.0.1'),
76
76
  rubygems_gem('responders', '2.3.0'),
77
77
  rubygems_gem('warden', '1.2.7'),
78
- rubygems_gem('devise', '4.2.0'),
78
+ rubygems_gem('devise', '4.2.0', true),
79
79
  rubygems_gem('multipart-post', '2.0.0'),
80
80
  rubygems_gem('faraday', '0.10.1'),
81
81
  rubygems_gem('hashie', '3.5.3'),
@@ -85,7 +85,7 @@ RSpec.describe GemfileInterpreter do
85
85
  rubygems_gem('oauth2', '1.3.0'),
86
86
  rubygems_gem('omniauth', '1.6.1'),
87
87
  rubygems_gem('omniauth-oauth2', '1.3.1'),
88
- git_gem('omniauth-keltec', '0.0.1', 'https://github.com/ThunderKey/omniauth-keltec.git', 'd954a55459b48cb56be4dbbcaa1fd2afc113db5b'),
88
+ git_gem('omniauth-keltec', '0.0.1', 'https://github.com/ThunderKey/omniauth-keltec.git', 'd954a55459b48cb56be4dbbcaa1fd2afc113db5b', true),
89
89
  ]
90
90
  end
91
91
 
@@ -104,15 +104,15 @@ RSpec.describe GemfileInterpreter do
104
104
 
105
105
  private
106
106
 
107
- def rubygems_gem name, version
108
- gem name, version, {'type' => 'rubygems', 'remotes' => ['https://rubygems.org/']}
107
+ def rubygems_gem name, version, in_gemfile = false
108
+ gem name, version, {'type' => 'rubygems', 'remotes' => ['https://rubygems.org/']}, in_gemfile
109
109
  end
110
110
 
111
- def git_gem name, version, uri, revision
112
- gem name, version, {'type' => 'git', 'revision' => revision, 'uri' => uri}
111
+ def git_gem name, version, uri, revision, in_gemfile = false
112
+ gem name, version, {'type' => 'git', 'revision' => revision, 'uri' => uri}, in_gemfile
113
113
  end
114
114
 
115
- def gem name, version, source
116
- [name, {'version' => version, 'full_name' => "#{name}-#{version}", 'platform' => 'ruby', 'remote' => '', 'source' => source}]
115
+ def gem name, version, source, in_gemfile
116
+ [name, {'version' => version, 'full_name' => "#{name}-#{version}", 'platform' => 'ruby', 'remote' => '', 'source' => source, 'in_gemfile' => in_gemfile}]
117
117
  end
118
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemfile_interpreter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Ganz