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 +4 -4
- data/CHANGELOG.md +4 -0
- data/bin/safedep +2 -2
- data/lib/safedep/cli/option_parser.rb +56 -0
- data/lib/safedep/cli.rb +16 -0
- data/lib/safedep/gemfile_lock.rb +6 -1
- data/lib/safedep/version.rb +1 -1
- data/spec/safedep/gemfile_lock_spec.rb +6 -0
- metadata +3 -2
- data/lib/safedep.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f81a9a095d287d0acfa6085600c2c91b1fd51886
|
4
|
+
data.tar.gz: 695497fc629e33cf1815523fbdf9efb63590fd04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3800b441e6346922281067c09726085e522dbf472227c18cb8ed7679754fa9535b2f85be8b189fc830964bb89f2565db680deea9f735d1839487f6b31c40daf
|
7
|
+
data.tar.gz: 6301c82baa0a18e2f30e7e9283fb87fbd3056f6698358094a6d96bc736328c60d0c79720ffae31bb68fe848205deb53aa7fecb2f91199c53e4995e8b3e1a0c30
|
data/CHANGELOG.md
CHANGED
data/bin/safedep
CHANGED
@@ -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
|
data/lib/safedep/cli.rb
ADDED
data/lib/safedep/gemfile_lock.rb
CHANGED
@@ -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
|
data/lib/safedep/version.rb
CHANGED
@@ -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.
|
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
|