gemfresh 1.0.2 → 1.0.3
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/README.md +5 -2
- data/gemfresh.gemspec +1 -1
- data/gemfresh.rb +69 -84
- data/support.rb +39 -0
- metadata +28 -53
data/README.md
CHANGED
@@ -4,17 +4,20 @@ Scans your bundler Gemfile and lets you know how up-to-date your gems are.
|
|
4
4
|
## Installation and Usage
|
5
5
|
|
6
6
|
To install, simply grab the gem:
|
7
|
+
|
7
8
|
gem install gemfresh
|
8
|
-
|
9
|
+
|
9
10
|
Change a project directory with a Gemfile (e.g. Your Rails v3+ project) and
|
10
11
|
type:
|
12
|
+
|
11
13
|
gemfresh
|
12
14
|
|
13
15
|
This will output a list of current, updateable and obsolete gems. For more
|
14
16
|
information on what this means, run gemfresh with the --help option:
|
17
|
+
|
15
18
|
gemfresh --help
|
16
19
|
|
17
20
|
## License
|
18
21
|
MIT Licensed. See MIT-LICENSE.txt for more information.
|
19
22
|
|
20
|
-
Thanks [@jonathannen](http://twitter.com/jonathannen).
|
23
|
+
Thanks, [@jonathannen](http://twitter.com/jonathannen).
|
data/gemfresh.gemspec
CHANGED
data/gemfresh.rb
CHANGED
@@ -14,13 +14,17 @@ if ARGV.include?('--help')
|
|
14
14
|
your current directory. Generally you'll simply invoke gemfresh from your
|
15
15
|
Rails (or similar) project directory.
|
16
16
|
|
17
|
-
Gemfresh will list three categories of gems
|
18
|
-
|
17
|
+
Gemfresh will list three categories of gems:
|
18
|
+
|
19
|
+
"Current" gems are up-to-date.
|
20
|
+
|
21
|
+
"Obsolete" gems have a newer version than the one specified in your Gemfile
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
"Updateable" gems have a newer version, and it is within the version in your Gemfile
|
24
|
+
e.g. Gemfile: '~> 2.2.0'
|
25
|
+
Gemfile.lock: 2.2.1
|
26
|
+
Latest: 2.2.2
|
27
|
+
Running bundle update will attempt to update these gems.
|
24
28
|
|
25
29
|
Just because a gem is updateable or obsolete, doesn't mean it can be
|
26
30
|
updated. There might be dependencies that limit you to specific versions.
|
@@ -28,7 +32,7 @@ if ARGV.include?('--help')
|
|
28
32
|
Check the bundler documentation (http://gembundler.com/) for more
|
29
33
|
information on Gemfiles.
|
30
34
|
HELP
|
31
|
-
exit
|
35
|
+
exit 1
|
32
36
|
end
|
33
37
|
|
34
38
|
# Check for gemfile and lockfiles
|
@@ -36,34 +40,14 @@ gemfile = ARGV[0] || './Gemfile'
|
|
36
40
|
lockfile = ARGV[1] || './Gemfile.lock'
|
37
41
|
unless File.exists?(gemfile)
|
38
42
|
puts "Couldn't find #{gemfile}.\nRun gemfresh with --help if you need more information."
|
39
|
-
exit
|
43
|
+
exit -1
|
40
44
|
end
|
41
45
|
unless File.exists?(lockfile)
|
42
46
|
puts "Couldn't find #{lockfile}.\nRun gemfresh with --help if you need more information."
|
43
|
-
exit
|
44
|
-
end
|
45
|
-
|
46
|
-
# Front for RubyGems
|
47
|
-
class RubyGemReader < Struct.new('RubyGemReader', :uri)
|
48
|
-
def get(path, data={}, content_type='application/x-www-form-urlencoded')
|
49
|
-
request = Net::HTTP::Get.new(path)
|
50
|
-
request.add_field 'Connection', 'keep-alive'
|
51
|
-
request.add_field 'Keep-Alive', '30'
|
52
|
-
request.add_field 'User-Agent', 'github.com/jonathannen/gemfresh'
|
53
|
-
response = connection.request request
|
54
|
-
response.body
|
55
|
-
end
|
56
|
-
private
|
57
|
-
# A persistent connection
|
58
|
-
def connection(host = Gem.host)
|
59
|
-
return @connection unless @connection.nil?
|
60
|
-
@connection = Net::HTTP.new self.uri.host, self.uri.port
|
61
|
-
@connection.start
|
62
|
-
@connection
|
63
|
-
end
|
47
|
+
exit -1
|
64
48
|
end
|
65
49
|
|
66
|
-
# Start in
|
50
|
+
# Start in earnest
|
67
51
|
puts "Checking the freshness of your Gemfile.\n"
|
68
52
|
|
69
53
|
# Get the data from bundler
|
@@ -77,6 +61,8 @@ sources = {}
|
|
77
61
|
results = { :current => [], :update => [], :obsolete => [] }
|
78
62
|
count = 0
|
79
63
|
prereleases = 0
|
64
|
+
unavailable = 0
|
65
|
+
untracked = 0
|
80
66
|
|
81
67
|
# Map dependencies to their specs, then select RubyGem sources
|
82
68
|
dep_specs = deps.map { |dep| [dep, specs.find { |spec| spec.name == dep.name }] }
|
@@ -85,43 +71,67 @@ dep_specs = dep_specs.select { |dep, spec| !spec.nil? && (spec.source.class == B
|
|
85
71
|
# Do we have any deps?
|
86
72
|
if deps.empty?
|
87
73
|
puts "No top-level RubyGem dependencies found in your Gemfile.\nRun gemfresh with --help if you need more information."
|
88
|
-
exit
|
74
|
+
exit true # Successful in that everything is theoretically up-to-date
|
89
75
|
end
|
90
76
|
|
91
77
|
# Iterate through the deps, checking the spec against the latest version
|
92
78
|
print "Hitting up your RubyGems sources: "
|
93
79
|
dep_specs.each do |dep, spec|
|
94
80
|
name = dep.name
|
95
|
-
|
96
|
-
|
97
|
-
#
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
81
|
+
|
82
|
+
# Get a connection to the rubygem repository, reusing the source
|
83
|
+
# connection if we can. Any error and that source is marked unavailable.
|
84
|
+
gemdata = versions = false
|
85
|
+
spec.source.remotes.each do |remote|
|
86
|
+
begin
|
87
|
+
next if remote.nil?
|
88
|
+
reader = sources[remote]
|
89
|
+
next if reader == :unavailable # Source previously marked unavailable
|
90
|
+
reader = sources[remote] = RubyGemReader.new(remote) if reader.nil?
|
91
|
+
|
92
|
+
# Get the RubyGems data
|
93
|
+
# lookup = RubyGems.get("/api/v1/gems/#{name}.yaml")
|
94
|
+
gemdata = reader.get("/api/v1/gems/#{name}.yaml")
|
95
|
+
gemdata = YAML.load(gemdata)
|
96
|
+
|
97
|
+
# Get the versions list as well
|
98
|
+
versions = reader.get("/api/v1/versions/#{name}.yaml")
|
99
|
+
versions = YAML.load(versions)
|
100
|
+
|
101
|
+
# Break if we've got the data we need
|
102
|
+
break unless !gemdata || !versions
|
103
|
+
|
104
|
+
rescue SourceUnavailableError => sae
|
105
|
+
# Mark source as unavailable
|
106
|
+
sources[remote] = :unavailable
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# No Gem Data or Version information? Not a versioned or tracked gem, so
|
111
|
+
# nothing we can deal with
|
112
|
+
if !gemdata || !versions || gemdata['version'].nil?
|
113
|
+
unavailable =+ 1
|
114
|
+
print "x"
|
115
|
+
|
116
|
+
# Otherwise, all good - store as a diff and move on
|
117
|
+
else
|
118
|
+
diff = SpecDiff.new(dep, spec, gemdata, versions)
|
119
|
+
results[diff.classify] << diff
|
120
|
+
prereleases +=1 if diff.prerelease?
|
121
|
+
count += 1
|
122
|
+
print "."
|
123
|
+
end
|
124
|
+
|
120
125
|
STDOUT.flush
|
121
126
|
end
|
122
127
|
puts " Done!"
|
123
128
|
|
124
|
-
# Let the user about prereleases
|
129
|
+
# Let the user know about prereleases
|
130
|
+
if unavailable > 0
|
131
|
+
puts "\nCouldn't get data for #{unavailable} gem#{unavailable == 1 ? '' : 's'}. It might be the RubyGem source is down or unaccessible. Give it another try in a moment."
|
132
|
+
end
|
133
|
+
|
134
|
+
# Let the user know about prereleases
|
125
135
|
if prereleases > 0
|
126
136
|
puts "\nYou have #{prereleases} prerelease gem#{prereleases == 1 ? '' : 's'}. Prereleases will be marked with a '*'."
|
127
137
|
end
|
@@ -170,30 +180,5 @@ else
|
|
170
180
|
end
|
171
181
|
end
|
172
182
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
183
|
+
# Exit code is determined by presence of obsolete gems
|
184
|
+
exit results[:obsolete].empty?
|
data/support.rb
CHANGED
@@ -1,3 +1,42 @@
|
|
1
|
+
# Front for RubyGems
|
2
|
+
class SourceUnavailableError < StandardError; end
|
3
|
+
class RubyGemReader
|
4
|
+
attr_reader :uri
|
5
|
+
|
6
|
+
def initialize(uri)
|
7
|
+
@connection = nil
|
8
|
+
@uri = uri #.gsub('https://', 'http://') # No SSL for the moment
|
9
|
+
# puts @uri.inspect
|
10
|
+
# puts @uri.scheme
|
11
|
+
end
|
12
|
+
|
13
|
+
# May raise SourceUnavailableError if the source can't be accessed
|
14
|
+
def get(path, data={}, content_type='application/x-www-form-urlencoded')
|
15
|
+
begin
|
16
|
+
request = Net::HTTP::Get.new(path)
|
17
|
+
request.add_field 'Connection', 'keep-alive'
|
18
|
+
request.add_field 'Keep-Alive', '30'
|
19
|
+
request.add_field 'User-Agent', 'github.com/jonathannen/gemfresh'
|
20
|
+
response = connection.request request
|
21
|
+
response.body
|
22
|
+
rescue StandardError => se
|
23
|
+
# For now we assume this is an unavailable repo
|
24
|
+
raise SourceUnavailableError.new(se.message)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
# A persistent connection
|
30
|
+
def connection
|
31
|
+
return @connection unless @connection.nil?
|
32
|
+
@connection = Net::HTTP.new self.uri.host, self.uri.port
|
33
|
+
@connection.start
|
34
|
+
@connection
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# A class to encapsulate the difference between gem states
|
1
40
|
class SpecDiff < Struct.new(:dep, :spec, :gemdata, :versions)
|
2
41
|
|
3
42
|
# Configure the diff
|
metadata
CHANGED
@@ -1,49 +1,35 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemfresh
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 2
|
10
|
-
version: 1.0.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jon Williams
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: bundler
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70155552550560 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
- 10
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 1.0.10
|
35
22
|
type: :runtime
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70155552550560
|
37
25
|
description: Scans Gemfiles to check for obsolete and updateable gems.
|
38
|
-
email:
|
26
|
+
email:
|
39
27
|
- jon@jonathannen.com
|
40
|
-
executables:
|
28
|
+
executables:
|
41
29
|
- gemfresh
|
42
30
|
extensions: []
|
43
|
-
|
44
31
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
32
|
+
files:
|
47
33
|
- .gitignore
|
48
34
|
- Gemfile
|
49
35
|
- MIT-LICENSE.txt
|
@@ -53,39 +39,28 @@ files:
|
|
53
39
|
- gemfresh.gemspec
|
54
40
|
- gemfresh.rb
|
55
41
|
- support.rb
|
56
|
-
has_rdoc: true
|
57
42
|
homepage: https://github.com/jonathannen/gemfresh
|
58
43
|
licenses: []
|
59
|
-
|
60
44
|
post_install_message:
|
61
45
|
rdoc_options: []
|
62
|
-
|
63
|
-
require_paths:
|
46
|
+
require_paths:
|
64
47
|
- .
|
65
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
49
|
none: false
|
67
|
-
requirements:
|
68
|
-
- -
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
|
71
|
-
|
72
|
-
- 0
|
73
|
-
version: "0"
|
74
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
55
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
|
80
|
-
segments:
|
81
|
-
- 0
|
82
|
-
version: "0"
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
83
60
|
requirements: []
|
84
|
-
|
85
61
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.6
|
62
|
+
rubygems_version: 1.8.6
|
87
63
|
signing_key:
|
88
64
|
specification_version: 3
|
89
65
|
summary: Checks the freshness of your Gemfile.
|
90
66
|
test_files: []
|
91
|
-
|