jeffrafter-gemstalker 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Josh Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,24 @@
1
+ gemstalker
2
+ ==========
3
+
4
+ GemStalker is a small library to determine if GitHub has built a gem yet.
5
+
6
+ require 'gemstalker'
7
+
8
+ stalker = GemStalker.new(:username => 'technicalpickles', :repository => 'jeweler', :version => '0.7.2'
9
+
10
+ if stalker.built?
11
+ puts "zomg, it's built, im so telling everyone"
12
+ if stalker.in_specfile?
13
+ puts "sweeeet, i can install it nao"
14
+ end
15
+ end
16
+
17
+ You can also omit the version, and it will take the version from the repository's gemspec on the master branch.
18
+
19
+ Origin code borrowed and inspired by hasmygembuiltyet.org.
20
+
21
+ COPYRIGHT
22
+ =========
23
+
24
+ Copyright (c) 2009 Josh Nichols. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = "gemstalker"
9
+ s.summary = "GemStalker is a small library to determine if GitHub has built a gem yet."
10
+ s.email = "josh@technicalpickles.com"
11
+ s.homepage = "http://github.com/technicalpickles/gemstalker"
12
+ s.description = "A library for determining if GitHub has built a gem yet"
13
+ s.authors = ["Josh Nichols"]
14
+ s.files = FileList["[A-Z]*", "{bin, lib, test}/**/*"]
15
+ s.executables = "stalk"
16
+ s.bindir = "bin"
17
+ end
18
+ rescue LoadError
19
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
+ end
21
+
22
+ Rake::TestTask.new do |t|
23
+ t.libs << 'lib'
24
+ t.pattern = 'test/**/*_test.rb'
25
+ t.verbose = false
26
+ end
27
+
28
+ Rake::RDocTask.new do |rdoc|
29
+ rdoc.rdoc_dir = 'rdoc'
30
+ rdoc.title = 'gemstalker'
31
+ rdoc.options << '--line-numbers' << '--inline-source'
32
+ rdoc.rdoc_files.include('README*')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
35
+
36
+ begin
37
+ require 'rcov/rcovtask'
38
+ Rcov::RcovTask.new do |t|
39
+ t.libs << 'test'
40
+ t.test_files = FileList['test/**/*_test.rb']
41
+ t.verbose = true
42
+ end
43
+ rescue LoadError
44
+ end
45
+
46
+ task :default => :test
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
3
+ :minor: 2
4
4
  :patch: 0
data/bin/stalk ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'gemstalker'
4
+
5
+ def usage
6
+ puts ""
7
+ puts "Usage:"
8
+ puts ""
9
+ puts " stalk <username> <repository> [version]"
10
+ puts ""
11
+ puts "Begins stalking a gem at the specified location e.g. stalk techinicalpickles jeweler"
12
+ puts ""
13
+ end
14
+
15
+ if ARGV.length == 0 || ARGV.include?("-h") || ARGV.include?("--help")
16
+ usage
17
+ exit
18
+ end
19
+
20
+ trap "SIGINT" do
21
+ puts ""
22
+ puts "Stopping"
23
+ exit
24
+ end
25
+
26
+ options = {:username => ARGV[0], :repository => ARGV[1]}
27
+ options[:version] = ARGV[2] if ARGV.length >= 3
28
+ stalker = GemStalker.new(options)
29
+
30
+ $stdout.sync = true
31
+
32
+ if ARGV.length < 3
33
+ puts "Using version #{stalker.version}"
34
+ end
35
+
36
+ unless stalker.gem?
37
+ puts "The repository is not configured as a rubygem"
38
+ puts "Configure the property in the Admin tab of the repository"
39
+ exit
40
+ end
41
+
42
+ waiting = false
43
+
44
+ puts "Checking to see if the gem has been built"
45
+ loop do
46
+ if stalker.built?
47
+ puts "" if waiting
48
+ puts "=> Zomg, it's built, I'm so telling everyone"
49
+ break
50
+ end
51
+ print "."
52
+ waiting = true
53
+ sleep(5)
54
+ end
55
+
56
+ waiting = false
57
+
58
+ puts "Checking to see if it is in the specfile"
59
+ loop do
60
+ if stalker.in_specfile?
61
+ puts "" if waiting
62
+ puts "=> Sweeeet, everyone can install it now"
63
+ break
64
+ end
65
+ print "."
66
+ waiting = true
67
+ sleep(5)
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeffrafter-gemstalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Nichols
@@ -10,22 +10,23 @@ bindir: bin
10
10
  cert_chain: []
11
11
 
12
12
  date: 2009-02-09 00:00:00 -08:00
13
- default_executable:
13
+ default_executable: stalk
14
14
  dependencies: []
15
15
 
16
16
  description: A library for determining if GitHub has built a gem yet
17
17
  email: josh@technicalpickles.com
18
- executables: []
19
-
18
+ executables:
19
+ - stalk
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - LICENSE
26
+ - Rakefile
27
+ - README
25
28
  - VERSION.yml
26
- - lib/gemstalker.rb
27
- - test/gemstalker_test.rb
28
- - test/test_helper.rb
29
+ - bin/stalk
29
30
  has_rdoc: false
30
31
  homepage: http://github.com/technicalpickles/gemstalker
31
32
  post_install_message:
data/lib/gemstalker.rb DELETED
@@ -1,57 +0,0 @@
1
- require 'net/http'
2
-
3
- class GemStalker
4
- attr_accessor :username, :name, :repository, :version
5
-
6
- def initialize(options = {})
7
- @username = options[:username]
8
- @repository = options[:repository]
9
- @version = options[:version] || determine_version
10
-
11
- end
12
-
13
- def built?
14
- Net::HTTP.start('gems.github.com') {|http|
15
- response = http.head(gem_path)
16
- response.code == "200"
17
- }
18
- end
19
-
20
- def in_specfile?
21
- fetcher = Gem::SpecFetcher.new
22
- specs = fetcher.load_specs(URI.parse('http://gems.github.com/'), 'specs')
23
- specs.any? do |(name, spec)|
24
- name == gem_name && spec.version.to_s == @version
25
- end
26
- end
27
-
28
- protected
29
-
30
- def gem_path
31
- "/gems/#{gem_name}-#{@version}.gem"
32
- end
33
-
34
- def gem_name
35
- "#{@username}-#{@repository}"
36
- end
37
-
38
- def gemspec_path
39
- # TODO this seems very unfuture proof, and also specific to master branch...
40
- "/#{@username}/#{@repository}/blob/master/#{@repository}.gemspec?raw=true"
41
- end
42
-
43
- def determine_version
44
- res = nil
45
- Net::HTTP.start('github.com') {|http|
46
- res = http.get(gemspec_path)
47
- }
48
-
49
- if res.code == "200"
50
- gemspec_file = res.body
51
- gemspec = nil
52
- # TODO this assumes Ruby format, but GitHub is cool with YAML
53
- Thread.new { gemspec = eval("$SAFE = 3\n#{gemspec_file}") }.join
54
- gemspec.version.to_s
55
- end
56
- end
57
- end
@@ -1,50 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class GemstalkerTest < Test::Unit::TestCase
4
-
5
- context "a stalker for a specific version of a gem that has not been built" do
6
- setup do
7
- @stalker = GemStalker.new(:username => 'technicalpickles', :repository => 'jeweler', :version => '0.9.3')
8
- end
9
-
10
- should "not be built yet" do
11
- assert ! @stalker.built?
12
- end
13
-
14
- should "not be in specfile yet" do
15
- assert ! @stalker.in_specfile?
16
- end
17
- end
18
-
19
- context "a stalker for a specific version of a gem that has been built and is available" do
20
- setup do
21
- @stalker = GemStalker.new(:username => 'technicalpickles', :repository => 'jeweler', :version => '0.8.1')
22
- end
23
-
24
- should "be built" do
25
- assert @stalker.built?
26
- end
27
-
28
- should "be in specfile" do
29
- assert @stalker.in_specfile?
30
- end
31
- end
32
-
33
- context "a stalker without a specific version of a gem that has been built" do
34
- setup do
35
- @stalker = GemStalker.new(:username => 'technicalpickles', :repository => 'jeweler')
36
- end
37
-
38
- should "determine version" do
39
- assert_equal '0.8.1', @stalker.version
40
- end
41
-
42
- should "be built" do
43
- assert @stalker.built?
44
- end
45
-
46
- should "be in specfile" do
47
- assert @stalker.in_specfile?
48
- end
49
- end
50
- end
data/test/test_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'ruby-debug'
5
-
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require File.join(File.dirname(__FILE__), '..', 'lib', 'gemstalker')
8
-
9
- class Test::Unit::TestCase
10
- end