version_gemfile 1.0.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.
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +6 -0
- data/bin/version_gemfile +18 -0
- data/lib/version_gemfile.rb +5 -0
- data/lib/version_gemfile/version.rb +3 -0
- data/lib/version_gemfile/versioner.rb +83 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/Gemfile.final.test +27 -0
- data/spec/support/Gemfile.initial.test +27 -0
- data/spec/support/Gemfile.initial.test.lock +173 -0
- data/spec/version_gemfile/versioner_spec.rb +76 -0
- data/spec/version_gemfile_spec.rb +5 -0
- data/version_gemfile.gemspec +22 -0
- metadata +107 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Nicolás Hock Isaza
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Version Gemfile
|
2
|
+
|
3
|
+
[](http://travis-ci.org/nhocki/version_gemfile)
|
4
|
+
|
5
|
+
|
6
|
+
Version Gemfile is a simple gem to add version numbers to your Gemfile gems.
|
7
|
+
|
8
|
+
The [problem](http://tenderlovemaking.com/2012/12/18/rails-4-and-your-gemfile.html)
|
9
|
+
is that most people don't add that simple `'~> x.x.x'` part at the end and
|
10
|
+
that makes it horrible to run `bundle update`. Well, at least, you can't trust that!
|
11
|
+
|
12
|
+
## How does it work?
|
13
|
+
|
14
|
+
*Version Gemfile* will go through your *Gemfile* looking for unversioned
|
15
|
+
gems, then will query your *Gemfile.lock* to get the current version of each
|
16
|
+
gem you're using and update your *Gemfile*.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
gem 'version_gemfile'
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install version_gemfile
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Simply type `$ version_gemfile` and you're done.
|
35
|
+
|
36
|
+
Also, you should consider the [Add Gem](https://github.com/abuiles/add_gem) gem to add gems to your Gemfile.
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/version_gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'version_gemfile'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
|
8
|
+
opt_parser = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: version_gemfile [options]"
|
10
|
+
|
11
|
+
opts.on("-g", "--gemfile", "Gemfile path") do |path|
|
12
|
+
options[:gemfile] = path
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
opt_parser.parse!
|
17
|
+
|
18
|
+
VersionGemfile::Versioner.add_versions!(options)
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module VersionGemfile
|
4
|
+
class Versioner
|
5
|
+
attr_reader :lock_contents, :gemfile_content, :options, :lockfile_path,
|
6
|
+
:gemfile_path
|
7
|
+
|
8
|
+
IS_GEM_LINE = /^\s* gem \s+ ['|"] /ix
|
9
|
+
HAS_VERSION = /^\s*gem \s+ ['|"] \s* [\w|-]+ \s* ['|"]\s*,\s*['|"]/ix
|
10
|
+
GET_GEM_NAME = /^\s*gem \s+ ['|"] \s* ([\w|-]+) \s* ['|"]/ix
|
11
|
+
GET_VERSION_NUMBER = /^\s+[\w|-]+ \s \( ([\w|\.]+) \)/ix
|
12
|
+
|
13
|
+
def self.add_versions!(options = {})
|
14
|
+
new(options).add_versions
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(options = {})
|
18
|
+
@options = normalize_hash(options.clone)
|
19
|
+
@gemfile_path = @options.fetch('gemfile'){ 'Gemfile' }
|
20
|
+
@lockfile_path = "#{@gemfile_path}.lock"
|
21
|
+
|
22
|
+
@lock_contents = File.read(lockfile_path)
|
23
|
+
@gemfile_content = File.readlines(gemfile_path)
|
24
|
+
@orig_gemfile = File.read(gemfile_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
#TODO: Clean this up!
|
28
|
+
def add_versions
|
29
|
+
new_gemfile = Tempfile.new("Gemfile.versioned")
|
30
|
+
begin
|
31
|
+
gemfile_content.each do |gem_line|
|
32
|
+
if is_gem_line?(gem_line)
|
33
|
+
new_gemfile.puts(build_gem_line(gem_line))
|
34
|
+
else
|
35
|
+
new_gemfile.puts(gem_line)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
File.truncate(gemfile_path, 0)
|
39
|
+
new_gemfile.rewind
|
40
|
+
File.open(gemfile_path, "w") {|f| f.write(new_gemfile.read)}
|
41
|
+
rescue Exception => e
|
42
|
+
puts "ERROR: #{e}"
|
43
|
+
puts "Restoring Gemfile at #{gemfile_path}"
|
44
|
+
File.open(gemfile_path, "w") {|f| f.write(@orig_gemfile)}
|
45
|
+
ensure
|
46
|
+
new_gemfile.close
|
47
|
+
new_gemfile.unlink
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def match_gem(gem_line)
|
52
|
+
gem_line.match(HAS_VERSION)
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_gem_line?(gem_line)
|
56
|
+
gem_line =~ IS_GEM_LINE
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_gem_line(gem_line, version = nil)
|
60
|
+
return gem_line if gem_line.match(HAS_VERSION)
|
61
|
+
gem_name = gem_line.match(GET_GEM_NAME) { $1 }
|
62
|
+
spaces = gem_line.match(/^(\s+)/){ $1 }
|
63
|
+
version ||= get_version(gem_name)
|
64
|
+
"#{spaces}gem '#{gem_name}', '~> #{version}'"
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def get_version(gem_name)
|
70
|
+
regexp = /^\s+#{gem_name}\s\(([\w|\.]+)\)/ix
|
71
|
+
regexp.match(lock_contents) { $1 }
|
72
|
+
end
|
73
|
+
|
74
|
+
def normalize_hash(hash)
|
75
|
+
hash.keys.each do |k|
|
76
|
+
unless k.is_a?(String)
|
77
|
+
hash[k.to_s] = hash.delete(k)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
hash
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'version_gemfile'
|
3
|
+
|
4
|
+
Bundler.require(:default, :test, :development)
|
5
|
+
|
6
|
+
module SpecHelpers
|
7
|
+
def support_dir_path
|
8
|
+
File.join(File.dirname(__FILE__), "support")
|
9
|
+
end
|
10
|
+
|
11
|
+
def read_support_file(filename)
|
12
|
+
File.read(File.join(support_dir_path, filename))
|
13
|
+
end
|
14
|
+
|
15
|
+
def support_file_lines(filename)
|
16
|
+
File.readlines(File.join(support_dir_path, filename))
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_gemfile_lock
|
20
|
+
read_support_file "Gemfile.initial.test.lock"
|
21
|
+
end
|
22
|
+
|
23
|
+
def final_gemfile
|
24
|
+
read_support_file "Gemfile.final.test"
|
25
|
+
end
|
26
|
+
|
27
|
+
def original_gemfile_lines
|
28
|
+
support_file_lines "Gemfile.initial.test"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
RSpec.configure do |config|
|
34
|
+
config.expect_with :rspec do |c|
|
35
|
+
c.syntax = :expect
|
36
|
+
end
|
37
|
+
config.include SpecHelpers
|
38
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
ruby '1.9.3'
|
3
|
+
|
4
|
+
gem 'rails', '3.2.8'
|
5
|
+
gem 'pg', '~> 0.14.1'
|
6
|
+
gem 'nokogiri', '~> 1.5.5'
|
7
|
+
gem 'jquery-rails', '~> 2.1.3'
|
8
|
+
gem 'airbrake', '~> 3.1.6'
|
9
|
+
gem 'devise', '~> 2.1.2'
|
10
|
+
gem "twitter-bootstrap-rails", "2.1.4"
|
11
|
+
gem 'friendly_id', '~> 4.0.8'
|
12
|
+
gem 'redcarpet', '~> 2.2.2'
|
13
|
+
gem 'rack-timeout', '~> 0.0.3'
|
14
|
+
gem 'mixpanel', '~> 3.0.2'
|
15
|
+
gem "rails3_acts_as_paranoid", "~> 0.2.0"
|
16
|
+
|
17
|
+
|
18
|
+
group :development, :test do
|
19
|
+
gem 'rspec-rails', '~> 2.11.4'
|
20
|
+
gem 'factory_girl_rails', '~> 4.1.0'
|
21
|
+
end
|
22
|
+
|
23
|
+
group :assets do
|
24
|
+
gem 'sass-rails', '~> 3.2.3'
|
25
|
+
gem 'uglifier', '>= 1.0.3'
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
ruby '1.9.3'
|
3
|
+
|
4
|
+
gem 'rails', '3.2.8'
|
5
|
+
gem "pg"
|
6
|
+
gem "nokogiri"
|
7
|
+
gem 'jquery-rails'
|
8
|
+
gem "airbrake"
|
9
|
+
gem "devise"
|
10
|
+
gem "twitter-bootstrap-rails", "2.1.4"
|
11
|
+
gem "friendly_id"
|
12
|
+
gem "redcarpet"
|
13
|
+
gem "rack-timeout"
|
14
|
+
gem "mixpanel"
|
15
|
+
gem "rails3_acts_as_paranoid", "~> 0.2.0"
|
16
|
+
|
17
|
+
|
18
|
+
group :development, :test do
|
19
|
+
gem "rspec-rails"
|
20
|
+
gem "factory_girl_rails"
|
21
|
+
end
|
22
|
+
|
23
|
+
group :assets do
|
24
|
+
gem 'sass-rails', '~> 3.2.3'
|
25
|
+
gem 'uglifier', '>= 1.0.3'
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,173 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.8)
|
5
|
+
actionpack (= 3.2.8)
|
6
|
+
mail (~> 2.4.4)
|
7
|
+
actionpack (3.2.8)
|
8
|
+
activemodel (= 3.2.8)
|
9
|
+
activesupport (= 3.2.8)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.4)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.3)
|
17
|
+
activemodel (3.2.8)
|
18
|
+
activesupport (= 3.2.8)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.8)
|
21
|
+
activemodel (= 3.2.8)
|
22
|
+
activesupport (= 3.2.8)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.8)
|
26
|
+
activemodel (= 3.2.8)
|
27
|
+
activesupport (= 3.2.8)
|
28
|
+
activesupport (3.2.8)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
airbrake (3.1.6)
|
32
|
+
builder
|
33
|
+
girl_friday
|
34
|
+
arel (3.0.2)
|
35
|
+
bcrypt-ruby (3.0.1)
|
36
|
+
builder (3.0.4)
|
37
|
+
commonjs (0.2.6)
|
38
|
+
connection_pool (0.9.2)
|
39
|
+
devise (2.1.2)
|
40
|
+
bcrypt-ruby (~> 3.0)
|
41
|
+
orm_adapter (~> 0.1)
|
42
|
+
railties (~> 3.1)
|
43
|
+
warden (~> 1.2.1)
|
44
|
+
diff-lcs (1.1.3)
|
45
|
+
erubis (2.7.0)
|
46
|
+
escape (0.0.4)
|
47
|
+
execjs (1.4.0)
|
48
|
+
multi_json (~> 1.0)
|
49
|
+
factory_girl (4.1.0)
|
50
|
+
activesupport (>= 3.0.0)
|
51
|
+
factory_girl_rails (4.1.0)
|
52
|
+
factory_girl (~> 4.1.0)
|
53
|
+
railties (>= 3.0.0)
|
54
|
+
friendly_id (4.0.8)
|
55
|
+
girl_friday (0.10.0)
|
56
|
+
connection_pool (~> 0.9.0)
|
57
|
+
hike (1.2.1)
|
58
|
+
i18n (0.6.1)
|
59
|
+
journey (1.0.4)
|
60
|
+
jquery-rails (2.1.3)
|
61
|
+
railties (>= 3.1.0, < 5.0)
|
62
|
+
thor (~> 0.14)
|
63
|
+
json (1.7.5)
|
64
|
+
less (2.2.2)
|
65
|
+
commonjs (~> 0.2.6)
|
66
|
+
less-rails (2.2.6)
|
67
|
+
actionpack (>= 3.1)
|
68
|
+
less (~> 2.2.0)
|
69
|
+
libv8 (3.3.10.4)
|
70
|
+
mail (2.4.4)
|
71
|
+
i18n (>= 0.4.0)
|
72
|
+
mime-types (~> 1.16)
|
73
|
+
treetop (~> 1.4.8)
|
74
|
+
mime-types (1.19)
|
75
|
+
mixpanel (3.0.2)
|
76
|
+
escape
|
77
|
+
json
|
78
|
+
rack
|
79
|
+
multi_json (1.3.6)
|
80
|
+
nokogiri (1.5.5)
|
81
|
+
orm_adapter (0.4.0)
|
82
|
+
pg (0.14.1)
|
83
|
+
polyglot (0.3.3)
|
84
|
+
rack (1.4.1)
|
85
|
+
rack-cache (1.2)
|
86
|
+
rack (>= 0.4)
|
87
|
+
rack-ssl (1.3.2)
|
88
|
+
rack
|
89
|
+
rack-test (0.6.2)
|
90
|
+
rack (>= 1.0)
|
91
|
+
rack-timeout (0.0.3)
|
92
|
+
rails (3.2.8)
|
93
|
+
actionmailer (= 3.2.8)
|
94
|
+
actionpack (= 3.2.8)
|
95
|
+
activerecord (= 3.2.8)
|
96
|
+
activeresource (= 3.2.8)
|
97
|
+
activesupport (= 3.2.8)
|
98
|
+
bundler (~> 1.0)
|
99
|
+
railties (= 3.2.8)
|
100
|
+
rails3_acts_as_paranoid (0.2.4)
|
101
|
+
activerecord (~> 3.2)
|
102
|
+
railties (3.2.8)
|
103
|
+
actionpack (= 3.2.8)
|
104
|
+
activesupport (= 3.2.8)
|
105
|
+
rack-ssl (~> 1.3.2)
|
106
|
+
rake (>= 0.8.7)
|
107
|
+
rdoc (~> 3.4)
|
108
|
+
thor (>= 0.14.6, < 2.0)
|
109
|
+
rake (0.9.2.2)
|
110
|
+
rdoc (3.12)
|
111
|
+
json (~> 1.4)
|
112
|
+
redcarpet (2.2.2)
|
113
|
+
rspec (2.11.0)
|
114
|
+
rspec-core (~> 2.11.0)
|
115
|
+
rspec-expectations (~> 2.11.0)
|
116
|
+
rspec-mocks (~> 2.11.0)
|
117
|
+
rspec-core (2.11.1)
|
118
|
+
rspec-expectations (2.11.3)
|
119
|
+
diff-lcs (~> 1.1.3)
|
120
|
+
rspec-mocks (2.11.3)
|
121
|
+
rspec-rails (2.11.4)
|
122
|
+
actionpack (>= 3.0)
|
123
|
+
activesupport (>= 3.0)
|
124
|
+
railties (>= 3.0)
|
125
|
+
rspec (~> 2.11.0)
|
126
|
+
sass (3.2.1)
|
127
|
+
sass-rails (3.2.5)
|
128
|
+
railties (~> 3.2.0)
|
129
|
+
sass (>= 3.1.10)
|
130
|
+
tilt (~> 1.3)
|
131
|
+
sprockets (2.1.3)
|
132
|
+
hike (~> 1.2)
|
133
|
+
rack (~> 1.0)
|
134
|
+
tilt (~> 1.1, != 1.3.0)
|
135
|
+
therubyracer (0.10.2)
|
136
|
+
libv8 (~> 3.3.10)
|
137
|
+
thor (0.16.0)
|
138
|
+
tilt (1.3.3)
|
139
|
+
treetop (1.4.12)
|
140
|
+
polyglot
|
141
|
+
polyglot (>= 0.3.1)
|
142
|
+
twitter-bootstrap-rails (2.1.4)
|
143
|
+
actionpack (>= 3.1)
|
144
|
+
less-rails (~> 2.2.3)
|
145
|
+
railties (>= 3.1)
|
146
|
+
therubyracer (>= 0.10.2)
|
147
|
+
tzinfo (0.3.34)
|
148
|
+
uglifier (1.3.0)
|
149
|
+
execjs (>= 0.3.0)
|
150
|
+
multi_json (~> 1.0, >= 1.0.2)
|
151
|
+
warden (1.2.1)
|
152
|
+
rack (>= 1.0)
|
153
|
+
|
154
|
+
PLATFORMS
|
155
|
+
ruby
|
156
|
+
|
157
|
+
DEPENDENCIES
|
158
|
+
airbrake
|
159
|
+
devise
|
160
|
+
factory_girl_rails
|
161
|
+
friendly_id
|
162
|
+
jquery-rails
|
163
|
+
mixpanel
|
164
|
+
nokogiri
|
165
|
+
pg
|
166
|
+
rack-timeout
|
167
|
+
rails (= 3.2.8)
|
168
|
+
rails3_acts_as_paranoid (~> 0.2.0)
|
169
|
+
redcarpet
|
170
|
+
rspec-rails
|
171
|
+
sass-rails (~> 3.2.3)
|
172
|
+
twitter-bootstrap-rails (= 2.1.4)
|
173
|
+
uglifier (>= 1.0.3)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module VersionGemfile
|
4
|
+
describe Versioner do
|
5
|
+
|
6
|
+
describe "#build_gem_line" do
|
7
|
+
let(:versioner) { Versioner.new }
|
8
|
+
|
9
|
+
it "adds a pessimistic version to the gem" do
|
10
|
+
expect(versioner.build_gem_line("gem 'rails'", "45.3.2")).to eql("gem 'rails', '~> 45.3.2'")
|
11
|
+
expect(versioner.build_gem_line('gem "rails"', "45.3.2")).to eql("gem 'rails', '~> 45.3.2'")
|
12
|
+
expect(versioner.build_gem_line('gem "rack-cache"', "5.3.2")).to eql("gem 'rack-cache', '~> 5.3.2'")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "adds the version from the Gemfile.lock file" do
|
16
|
+
versioner.stub(lock_contents: test_gemfile_lock)
|
17
|
+
expect(versioner.build_gem_line "gem 'pg'" ).to eql("gem 'pg', '~> 0.14.1'")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#add_versions" do
|
22
|
+
let(:options) {{
|
23
|
+
gemfile: File.join(support_dir_path, "Gemfile.initial.test")
|
24
|
+
}}
|
25
|
+
|
26
|
+
let(:versioner) { Versioner.new(options) }
|
27
|
+
|
28
|
+
before do
|
29
|
+
@original_gemfile = File.read(options[:gemfile])
|
30
|
+
versioner.stub(lock_contents: test_gemfile_lock)
|
31
|
+
versioner.stub(gemfile_content: original_gemfile_lines)
|
32
|
+
end
|
33
|
+
|
34
|
+
after do
|
35
|
+
File.open(options[:gemfile], "w"){|f| f.write(@original_gemfile)}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "adds versions to the gemfile" do
|
39
|
+
versioner.add_versions
|
40
|
+
expect(File.read(options[:gemfile])).to eql(final_gemfile)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "Versioner.add_versions! also adds versions to the gemfile" do
|
44
|
+
Versioner.add_versions!(options)
|
45
|
+
expect(File.read(options[:gemfile])).to eql(final_gemfile)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#match_gem" do
|
50
|
+
let(:matcher) { Versioner.new }
|
51
|
+
it "matches with a line with a version" do
|
52
|
+
gems = <<-GEMS
|
53
|
+
gem ' rails ', '3.2.8'
|
54
|
+
gem "rails", '~> 2.3.4' :require => "something/else"
|
55
|
+
gem "pg", '>= 2.3.4' require: "something/else"
|
56
|
+
GEMS
|
57
|
+
|
58
|
+
gems.split("\n").each do |gem_name|
|
59
|
+
expect(matcher.match_gem(gem_name)).to be_true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
it "doesn't match with a gem without a version" do
|
64
|
+
gems = <<-GEMS
|
65
|
+
gem ' rails '
|
66
|
+
gem "rails", :require => "something/else"
|
67
|
+
gem "pg", require: "something/else"
|
68
|
+
GEMS
|
69
|
+
|
70
|
+
gems.split("\n").each do |gem_name|
|
71
|
+
expect(matcher.match_gem(gem_name)).to be_false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version_gemfile/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "version_gemfile"
|
8
|
+
gem.version = VersionGemfile::VERSION
|
9
|
+
gem.authors = ["Nicolás Hock Isaza"]
|
10
|
+
gem.email = ["nhocki@gmail.com"]
|
11
|
+
gem.description = %q{Tool to add version to your Gemfile's gems.}
|
12
|
+
gem.summary = %q{Prevent future problems dude. Add the versions and move on.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency('rake', '~> 10.0.3')
|
21
|
+
gem.add_development_dependency('rspec', '~> 2.12.0')
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: version_gemfile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nicolás Hock Isaza
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 10.0.3
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 10.0.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.12.0
|
46
|
+
description: Tool to add version to your Gemfile's gems.
|
47
|
+
email:
|
48
|
+
- nhocki@gmail.com
|
49
|
+
executables:
|
50
|
+
- version_gemfile
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .travis.yml
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/version_gemfile
|
61
|
+
- lib/version_gemfile.rb
|
62
|
+
- lib/version_gemfile/version.rb
|
63
|
+
- lib/version_gemfile/versioner.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
- spec/support/Gemfile.final.test
|
66
|
+
- spec/support/Gemfile.initial.test
|
67
|
+
- spec/support/Gemfile.initial.test.lock
|
68
|
+
- spec/version_gemfile/versioner_spec.rb
|
69
|
+
- spec/version_gemfile_spec.rb
|
70
|
+
- version_gemfile.gemspec
|
71
|
+
homepage: ''
|
72
|
+
licenses: []
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: 2288187485407978392
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
hash: 2288187485407978392
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.23
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Prevent future problems dude. Add the versions and move on.
|
101
|
+
test_files:
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
- spec/support/Gemfile.final.test
|
104
|
+
- spec/support/Gemfile.initial.test
|
105
|
+
- spec/support/Gemfile.initial.test.lock
|
106
|
+
- spec/version_gemfile/versioner_spec.rb
|
107
|
+
- spec/version_gemfile_spec.rb
|