safedep 0.0.1 → 0.0.2

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: f1cb012ac2d4a305d3336571face073efbb280cb
4
- data.tar.gz: 0869786aa9865ba2b5c0e0244bb1b1c5c9dcf4f9
3
+ metadata.gz: f81a9a095d287d0acfa6085600c2c91b1fd51886
4
+ data.tar.gz: 695497fc629e33cf1815523fbdf9efb63590fd04
5
5
  SHA512:
6
- metadata.gz: b0758ba09057c0dbdd8f1bb469f4acb38b92b6dcab88d22b9be1b51557c54126df2a3f1ef5ebd3ad93cb2a0fb5151e5334795fb964c351aaef0dbe6f5d22d0d3
7
- data.tar.gz: 0f6f50bfd5adc9aed4ed7cf266131b1b7d53323e6e02d79376ce711f08f16e41ed4b22111677634842b226e4c6ba85db2ae4e4b3af02da0512abfaa5c0f0ec2b
6
+ metadata.gz: a3800b441e6346922281067c09726085e522dbf472227c18cb8ed7679754fa9535b2f85be8b189fc830964bb89f2565db680deea9f735d1839487f6b31c40daf
7
+ data.tar.gz: 6301c82baa0a18e2f30e7e9283fb87fbd3056f6698358094a6d96bc736328c60d0c79720ffae31bb68fe848205deb53aa7fecb2f91199c53e4995e8b3e1a0c30
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v0.0.2
6
+
7
+ * Fix an error when a `Gemfile` includes `bundler` dependency without version specifier.
8
+
5
9
  ## v0.0.1
6
10
 
7
11
  * Initial release.
data/bin/safedep CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
4
- require 'safedep/runner'
4
+ require 'safedep/cli'
5
5
 
6
- Safedep::Runner.run
6
+ Safedep::CLI.run
@@ -0,0 +1,56 @@
1
+ require 'optparse'
2
+ require 'safedep/version'
3
+
4
+ module Safedep
5
+ class OptionParser
6
+ def self.parse(args)
7
+ new.parse(args)
8
+ end
9
+
10
+ def initialize
11
+ setup
12
+ end
13
+
14
+ def parse(args)
15
+ args = args.dup
16
+ parser.parse!(args)
17
+ args
18
+ end
19
+
20
+ private
21
+
22
+ def setup
23
+ define_option('--version') do
24
+ puts Version.to_s
25
+ exit
26
+ end
27
+ end
28
+
29
+ def define_option(*options, &block)
30
+ long_option = options.find { |option| option.start_with?('--') }
31
+ description_lines = descriptions[long_option]
32
+ parser.on(*options, *description_lines, &block)
33
+ end
34
+
35
+ def parser
36
+ @parser ||= begin
37
+ banner = "Usage: #{command_name} [options]\n\n"
38
+ summary_width = 32 # Default
39
+ indentation = ' ' * 2
40
+ ::OptionParser.new(banner, summary_width, indentation)
41
+ end
42
+ end
43
+
44
+ def command_name
45
+ File.basename($PROGRAM_NAME)
46
+ end
47
+
48
+ def descriptions
49
+ @descriptions ||= {
50
+ '--version' => [
51
+ "Show #{command_name} version."
52
+ ]
53
+ }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,16 @@
1
+ require 'safedep/cli/option_parser'
2
+ require 'safedep/runner'
3
+
4
+ module Safedep
5
+ class CLI
6
+ def self.run(args = ARGV)
7
+ new.run(args)
8
+ end
9
+
10
+ def run(args)
11
+ OptionParser.new.parse(args)
12
+ Runner.run
13
+ puts 'Done.'
14
+ end
15
+ end
16
+ end
@@ -1,4 +1,5 @@
1
1
  require 'bundler'
2
+ require 'ostruct'
2
3
 
3
4
  module Safedep
4
5
  class GemfileLock
@@ -13,7 +14,7 @@ module Safedep
13
14
  end
14
15
 
15
16
  def dependencies
16
- lockfile.specs
17
+ @dependencies ||= lockfile.specs + [bundler_dependency]
17
18
  end
18
19
 
19
20
  private
@@ -24,5 +25,9 @@ module Safedep
24
25
  Bundler::LockfileParser.new(content)
25
26
  end
26
27
  end
28
+
29
+ def bundler_dependency
30
+ OpenStruct.new(name: 'bundler', version: Bundler::VERSION)
31
+ end
27
32
  end
28
33
  end
@@ -3,7 +3,7 @@ module Safedep
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
- PATCH = 1
6
+ PATCH = 2
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
@@ -76,6 +76,12 @@ module Safedep
76
76
  it 'returns an array of the specifications' do
77
77
  expect(dep_names).to include('rake', 'rspec', 'rubocop')
78
78
  end
79
+
80
+ it 'includes "bundler" dependency' do
81
+ dependency = lockfile.find_dependency('bundler')
82
+ expect(dependency.name).to eq('bundler')
83
+ expect(dependency.version).to eq(Bundler::VERSION)
84
+ end
79
85
  end
80
86
  end
81
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safedep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama
@@ -70,9 +70,10 @@ files:
70
70
  - README.md
71
71
  - Rakefile
72
72
  - bin/safedep
73
- - lib/safedep.rb
74
73
  - lib/safedep/abstract_dependency.rb
75
74
  - lib/safedep/abstract_gemfile.rb
75
+ - lib/safedep/cli.rb
76
+ - lib/safedep/cli/option_parser.rb
76
77
  - lib/safedep/gemfile.rb
77
78
  - lib/safedep/gemfile/dependency.rb
78
79
  - lib/safedep/gemfile_lock.rb
data/lib/safedep.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'safedep/version'
2
-
3
- module Safedep
4
- # Your code goes here...
5
- end