jeffrafter-gemstalker 0.2.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +18 -0
- data/Rakefile +16 -17
- data/VERSION.yml +2 -2
- data/bin/gemstalk +70 -0
- data/lib/{gemstalker.rb → gem_stalker.rb} +18 -0
- data/test/responses/bostonrb-tree-master +565 -0
- data/test/responses/bostonrb.gemspec +13 -0
- data/test/responses/jeweler-tree-master +728 -0
- data/test/responses/jeweler.gemspec +48 -0
- data/test/responses/specs.4.8.gz +0 -0
- data/test/responses/technicalpickles-jeweler-0.8.1.gem +0 -0
- data/test/responses/technicalpickles-jeweler-0.9.3.gem +15 -0
- data/test/test_helper.rb +26 -1
- metadata +16 -8
- data/README +0 -24
- data/bin/stalk +0 -68
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= gemstalker
|
2
|
+
|
3
|
+
GemStalker is a small utility to determine if GitHub has built a gem yet.
|
4
|
+
|
5
|
+
sudo gem install technicalpickles-gemstalker --source http://gems.github.com
|
6
|
+
gemstalk yourusername yourrepo yourversion
|
7
|
+
|
8
|
+
You can also omit the version, and it will take the version from the repository's gemspec on the master branch.
|
9
|
+
|
10
|
+
== Contributions and credit
|
11
|
+
|
12
|
+
Origin code borrowed and inspired by hasmygembuiltyet.org.
|
13
|
+
|
14
|
+
Contributions from Jeff Rafter.
|
15
|
+
|
16
|
+
== COPYRIGHT
|
17
|
+
|
18
|
+
Copyright (c) 2009 Josh Nichols. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -4,24 +4,23 @@ require 'rake/rdoctask'
|
|
4
4
|
|
5
5
|
begin
|
6
6
|
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
s.executables = "stalk"
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "gemstalker"
|
9
|
+
gem.summary = "GemStalker is a small library to determine if GitHub has built a gem yet."
|
10
|
+
gem.email = "josh@technicalpickles.com"
|
11
|
+
gem.homepage = "http://github.com/technicalpickles/gemstalker"
|
12
|
+
gem.description = "A library for determining if GitHub has built a gem yet"
|
13
|
+
gem.authors = ["Josh Nichols"]
|
14
|
+
gem.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
|
16
15
|
end
|
17
16
|
rescue LoadError
|
18
17
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
19
18
|
end
|
20
19
|
|
21
|
-
Rake::TestTask.new do |
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
Rake::TestTask.new do |test|
|
21
|
+
test.libs << 'lib'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = false
|
25
24
|
end
|
26
25
|
|
27
26
|
Rake::RDocTask.new do |rdoc|
|
@@ -34,10 +33,10 @@ end
|
|
34
33
|
|
35
34
|
begin
|
36
35
|
require 'rcov/rcovtask'
|
37
|
-
Rcov::RcovTask.new do |
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
Rcov::RcovTask.new do |rcov|
|
37
|
+
rcov.libs << 'test'
|
38
|
+
rcov.test_files = FileList['test/**/*_test.rb']
|
39
|
+
rcov.verbose = true
|
41
40
|
end
|
42
41
|
rescue LoadError
|
43
42
|
end
|
data/VERSION.yml
CHANGED
data/bin/gemstalk
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__), '..', 'lib')
|
3
|
+
require 'gem_stalker'
|
4
|
+
|
5
|
+
def usage
|
6
|
+
puts ""
|
7
|
+
puts "Usage:"
|
8
|
+
puts ""
|
9
|
+
puts " #{File.basename $0} <username> <repository> [version]"
|
10
|
+
puts ""
|
11
|
+
puts "Begins stalking a gem at the specified location. Example:"
|
12
|
+
puts ""
|
13
|
+
puts " #{File.basename $0} techinicalpickles jeweler"
|
14
|
+
end
|
15
|
+
|
16
|
+
if ARGV.length == 0 || ARGV.include?("-h") || ARGV.include?("--help")
|
17
|
+
usage
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
trap "SIGINT" do
|
22
|
+
puts ""
|
23
|
+
puts "Stopping"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
options = {:username => ARGV[0], :repository => ARGV[1]}
|
28
|
+
options[:version] = ARGV[2] if ARGV.length >= 3
|
29
|
+
stalker = GemStalker.new(options)
|
30
|
+
|
31
|
+
$stdout.sync = true
|
32
|
+
|
33
|
+
unless stalker.gem?
|
34
|
+
puts "The repository is not configured as a rubygem yet."
|
35
|
+
puts "Go to the following url, and check 'RubyGem'"
|
36
|
+
puts "\t#{stalker.edit_repo_url}"
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
|
40
|
+
if ARGV.length < 3
|
41
|
+
puts "Using version #{stalker.version}"
|
42
|
+
end
|
43
|
+
|
44
|
+
waiting = false
|
45
|
+
|
46
|
+
puts "Checking to see if the gem has been built:"
|
47
|
+
loop do
|
48
|
+
if stalker.built?
|
49
|
+
puts "." if waiting
|
50
|
+
puts "=> Zomg, it's built, I'm so telling everyone!"
|
51
|
+
break
|
52
|
+
end
|
53
|
+
print "."
|
54
|
+
waiting = true
|
55
|
+
sleep(5)
|
56
|
+
end
|
57
|
+
|
58
|
+
waiting = false
|
59
|
+
|
60
|
+
puts "Checking to see if it is in the specfile:"
|
61
|
+
loop do
|
62
|
+
if stalker.in_specfile?
|
63
|
+
puts "." if waiting
|
64
|
+
puts "=> Sweeeet, everyone can install it now!"
|
65
|
+
break
|
66
|
+
end
|
67
|
+
print "."
|
68
|
+
waiting = true
|
69
|
+
sleep(60*5)
|
70
|
+
end
|
@@ -1,8 +1,16 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'rubygems/spec_fetcher'
|
2
3
|
|
4
|
+
# Small class for determining if a gem has been built on GitHub and if it's installable.
|
3
5
|
class GemStalker
|
4
6
|
attr_accessor :username, :name, :repository, :version
|
5
7
|
|
8
|
+
# Accepts the following options:
|
9
|
+
#
|
10
|
+
# username:: GitHub username
|
11
|
+
# repository:: repository name
|
12
|
+
# version:: version to stalk. Defaults to checking the repository for a
|
13
|
+
# gemspec to determine the latest version.
|
6
14
|
def initialize(options = {})
|
7
15
|
@username = options[:username]
|
8
16
|
@repository = options[:repository]
|
@@ -10,6 +18,7 @@ class GemStalker
|
|
10
18
|
|
11
19
|
end
|
12
20
|
|
21
|
+
# Is it built yet?
|
13
22
|
def built?
|
14
23
|
Net::HTTP.start('gems.github.com') {|http|
|
15
24
|
response = http.head(gem_path)
|
@@ -17,6 +26,7 @@ class GemStalker
|
|
17
26
|
}
|
18
27
|
end
|
19
28
|
|
29
|
+
# Is RubyGem building enabled for the repository?
|
20
30
|
def gem?
|
21
31
|
Net::HTTP.start('github.com') {|http|
|
22
32
|
res = http.get(master_path)
|
@@ -25,6 +35,7 @@ class GemStalker
|
|
25
35
|
false
|
26
36
|
end
|
27
37
|
|
38
|
+
# Is it in the specs yet? ie is it installable yet?
|
28
39
|
def in_specfile?
|
29
40
|
fetcher = Gem::SpecFetcher.new
|
30
41
|
specs = fetcher.load_specs(URI.parse('http://gems.github.com/'), 'specs')
|
@@ -33,6 +44,11 @@ class GemStalker
|
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
47
|
+
# Path to edit the repository
|
48
|
+
def edit_repo_url
|
49
|
+
"http://github.com/#{@username}/#{@repository}/edit"
|
50
|
+
end
|
51
|
+
|
36
52
|
protected
|
37
53
|
|
38
54
|
def gem_path
|
@@ -52,6 +68,8 @@ class GemStalker
|
|
52
68
|
"/#{@username}/#{@repository}/tree/master"
|
53
69
|
end
|
54
70
|
|
71
|
+
|
72
|
+
|
55
73
|
def determine_version
|
56
74
|
res = nil
|
57
75
|
Net::HTTP.start('github.com') {|http|
|