latest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ .DS_Store
4
+ Gemfile.lock
5
+ pkg/*
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+
5
+ script: "bundle exec rake"
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2011 - 2012 Spencer Steffen and Citrus Media Group.
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of Citrus Media Group nor the names of its
15
+ contributors may be used to endorse or promote products derived from this
16
+ software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Latest [![Build Status](https://secure.travis-ci.org/citrus/latest.png)](http://travis-ci.org/citrus/latest)
2
+
3
+ ### Latest keeps us up to speed by querying rubygems.org for a gem's most recent version number. Yep, that's all it does.
4
+
5
+ Basically I was tired of visiting `https://rubygems.org/gems/whatever-gem` to find out a gem's most recent version number.
6
+
7
+
8
+ ------------------------------------------------------------------------------
9
+ Usage
10
+ ------------------------------------------------------------------------------
11
+
12
+ After installing, use latest from your command line like so:
13
+
14
+
15
+ ```bash
16
+ latest rails
17
+ # rails 3.2.1
18
+
19
+ latest rails spree haml
20
+ # rails 3.2.1
21
+ # spree 1.0.0
22
+ # haml 3.1.4
23
+ ```
24
+
25
+
26
+ ------------------------------------------------------------------------------
27
+ Installation
28
+ ------------------------------------------------------------------------------
29
+
30
+ As usual, just use the `gem install` command:
31
+
32
+ ```bash
33
+ gem install latest
34
+ # or
35
+ sudo gem install latest
36
+ ```
37
+
38
+
39
+ ------------------------------------------------------------------------------
40
+ Testing
41
+ ------------------------------------------------------------------------------
42
+
43
+ Testing is done with minitest. Run the tests with:
44
+
45
+ ```bash
46
+ bundle exec rake
47
+ ```
48
+
49
+
50
+ ------------------------------------------------------------------------------
51
+ Requirements
52
+ ------------------------------------------------------------------------------
53
+
54
+ Other than rake and bundler for development, Latest has zero gem dependencies! All it requires is Ruby >= 1.9.2.
55
+
56
+
57
+ ------------------------------------------------------------------------------
58
+ License
59
+ ------------------------------------------------------------------------------
60
+
61
+ Copyright (c) 2011 - 2012 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new
5
+
6
+ task :default => [ :test ]
data/bin/latest ADDED
@@ -0,0 +1,20 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ $:.push File.expand_path("../../lib", __FILE__)
5
+
6
+ require "latest"
7
+
8
+ if ARGV.first =~ /^-(v|-version)$/
9
+ puts "Latest v" + Latest::VERSION
10
+ else
11
+ ARGV.each do |name|
12
+ print name + " "
13
+ begin
14
+ puts Latest.version(name)
15
+ rescue Latest::GemNotFoundError => e
16
+ print "<- "
17
+ puts e.message
18
+ end
19
+ end
20
+ end
data/latest.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "latest/version"
4
+
5
+ Gem::Specification.new do |s|
6
+
7
+ s.name = "latest"
8
+ s.version = Latest::VERSION
9
+ s.authors = ["Spencer Steffen"]
10
+ s.email = ["spencer@citrusme.com"]
11
+ s.homepage = "https://github.com/citrus/latest"
12
+ s.summary = %q{Latest keeps us up to speed by querying rubygems.org for a gem's most recent version number. Yep, that's all it does.}
13
+ s.description = %q{Latest keeps us up to speed by querying rubygems.org for a gem's most recent version number. Yep, that's all it does.}
14
+
15
+ s.rubyforge_project = "latest"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.required_ruby_version = ">= 1.9.2"
23
+
24
+ s.add_development_dependency "rake", "> 0"
25
+ s.add_development_dependency "bundler", "> 0"
26
+
27
+ end
data/lib/latest/gem.rb ADDED
@@ -0,0 +1,32 @@
1
+ require "uri"
2
+ require "net/https"
3
+ require "json"
4
+
5
+ module Latest
6
+ class Gem
7
+
8
+ attr_reader :attributes
9
+
10
+ def initialize(name)
11
+ @attributes = fetch(name)
12
+ if @attributes.nil?
13
+ raise ::Latest::GemNotFoundError, "`#{name}` could not be found on rubygems.org!"
14
+ end
15
+ self
16
+ end
17
+
18
+ private
19
+
20
+ def fetch(name)
21
+ uri = URI("https://rubygems.org/api/v1/gems/#{name}.json")
22
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
23
+ request = Net::HTTP::Get.new uri.request_uri
24
+ response = http.request request
25
+ if response.is_a?(Net::HTTPSuccess)
26
+ return JSON.parse(response.body)
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Latest
2
+ VERSION = "0.1.0"
3
+ end
data/lib/latest.rb ADDED
@@ -0,0 +1,13 @@
1
+ require "latest/version"
2
+ require "latest/gem"
3
+
4
+ module Latest
5
+
6
+ class GemNotFoundError < StandardError; end
7
+
8
+ def self.version(name)
9
+ gem = Gem.new(name)
10
+ gem.attributes["version"]
11
+ end
12
+
13
+ end
data/test/test_gem.rb ADDED
@@ -0,0 +1,18 @@
1
+ require "minitest/autorun"
2
+ require "latest"
3
+
4
+ class TestGem < MiniTest::Unit::TestCase
5
+
6
+ def test_should_fetch_on_initialize
7
+ gem = ::Latest::Gem.new("rake")
8
+ assert_equal Hash, gem.attributes.class
9
+ assert_equal "rake", gem.attributes["name"]
10
+ end
11
+
12
+ def test_raise_error_when_gem_is_not_found
13
+ assert_raises Latest::GemNotFoundError do
14
+ ::Latest::Gem.new("some-gem-that-probably-wont-exist-2")
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,37 @@
1
+ require "minitest/autorun"
2
+ require "latest"
3
+
4
+ class TestLatest < MiniTest::Unit::TestCase
5
+
6
+ BIN = File.expand_path("../../bin/latest", __FILE__)
7
+
8
+ def test_has_version
9
+ assert_equal String, Latest::VERSION.class
10
+ end
11
+
12
+ def test_executable_exists
13
+ assert File.exists?(BIN)
14
+ end
15
+
16
+ def test_executable_is_executable
17
+ assert File.executable?(BIN)
18
+ end
19
+
20
+ def test_executable_returns_version
21
+ out = `#{BIN} -v`
22
+ assert_match "Latest v#{Latest::VERSION}", out
23
+ end
24
+
25
+ def test_executable_fetches_and_prints_version
26
+ out = `#{BIN} rake`
27
+ assert_match /rake \d.\d.\d(.\d)?/, out
28
+ end
29
+
30
+ def test_executable_fetches_and_prints_multiple_versions
31
+ out = `#{BIN} rake rails spree`.split("\n")
32
+ assert_match /rake \d.\d.\d(.\d)?/, out[0]
33
+ assert_match /rails \d.\d.\d(.\d)?/, out[1]
34
+ assert_match /spree \d.\d.\d(.\d)?/, out[2]
35
+ end
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: latest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Spencer Steffen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &70259770155560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>'
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *70259770155560
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &70259770154620 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>'
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70259770154620
36
+ description: Latest keeps us up to speed by querying rubygems.org for a gem's most
37
+ recent version number. Yep, that's all it does.
38
+ email:
39
+ - spencer@citrusme.com
40
+ executables:
41
+ - latest
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - .travis.yml
47
+ - Gemfile
48
+ - LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - bin/latest
52
+ - latest.gemspec
53
+ - lib/latest.rb
54
+ - lib/latest/gem.rb
55
+ - lib/latest/version.rb
56
+ - test/test_gem.rb
57
+ - test/test_latest.rb
58
+ homepage: https://github.com/citrus/latest
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.9.2
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ segments:
77
+ - 0
78
+ hash: 3157611615867857554
79
+ requirements: []
80
+ rubyforge_project: latest
81
+ rubygems_version: 1.8.10
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: Latest keeps us up to speed by querying rubygems.org for a gem's most recent
85
+ version number. Yep, that's all it does.
86
+ test_files:
87
+ - test/test_gem.rb
88
+ - test/test_latest.rb