gemline 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/gemline CHANGED
@@ -1,4 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "gemline"
4
- Gemline.query(ARGV[0])
4
+
5
+ ## TODO: Real command line parsing to support some switches
6
+ ## for things like:
7
+ ## --pre : Get latest pre-release version
8
+ ## --gemspec or -g : Get the gemspec version of the gemline
9
+ ## --major N : Get latest version of gem within the given major release number
10
+ ## --web or -w : Get rubygems.org link
11
+ gem = STDIN.tty? ? ARGV[0] : STDIN.read
12
+
13
+ Gemline.query(gem)
data/gemline.gemspec CHANGED
@@ -13,9 +13,9 @@ Gem::Specification.new do |gem|
13
13
  gem.name = "gemline"
14
14
  gem.require_paths = ["lib"]
15
15
 
16
- gem.version = '0.1.3'
16
+ gem.version = '0.1.4'
17
17
 
18
18
  gem.add_dependency('crack')
19
19
  gem.add_development_dependency('rake') # For Travis CI
20
- gem.add_development_dependency(%q<rspec>, [">= 2.7.0"])
20
+ gem.add_development_dependency(%q<rspec>, [">= 2.11.0"])
21
21
  end
data/lib/gemline.rb CHANGED
@@ -9,7 +9,7 @@ class Gemline
9
9
  attr_accessor :gem, :gemline, :json, :response
10
10
 
11
11
  def self.query(gem_name)
12
- gem_name = gem_name.to_s.gsub(/[^\w\-]+/,'')
12
+ gem_name = sanitize_gem_name(gem_name)
13
13
  check_input(gem_name)
14
14
 
15
15
  g = Gemline.new(gem_name)
@@ -23,6 +23,10 @@ class Gemline
23
23
  end
24
24
  end
25
25
 
26
+ def self.sanitize_gem_name(gem_name)
27
+ gem_name.to_s.gsub(/[^\w\-]+/,'')
28
+ end
29
+
26
30
 
27
31
  def initialize(gem_name, options = {})
28
32
  @gem = gem_name.to_s.gsub(/[^\w\-]+/,'') # Yeah, a little over-defensive.
@@ -9,13 +9,13 @@ describe "gemline output" do
9
9
 
10
10
  it "should output one line to STDOUT so the output can be appended to a Gemfile" do
11
11
  grab_io { Gemline.query('rails') }
12
- @stdout.readlines.count.should eq(1)
12
+ expect(@stdout.readlines.count).to eq(1)
13
13
  end
14
14
 
15
15
  it "should output nothing to STDOUT on error" do
16
16
  Kernel.stub(:exit)
17
17
  grab_io { Gemline.query('doesnotexist') }
18
- @stdout.readlines.count.should eq(0)
18
+ expect(@stdout.readlines.count).to eq(0)
19
19
  end
20
20
 
21
21
  end
data/spec/gemline_spec.rb CHANGED
@@ -10,29 +10,29 @@ describe Gemline do
10
10
 
11
11
  it "should be able to parse the version out of a good json string" do
12
12
  g = Gemline.new('rails')
13
- g.gemline.should == %Q{gem "rails", "~> 3.1.1"}
13
+ expect(g.gemline).to eq(%Q{gem "rails", "~> 3.1.1"})
14
14
  end
15
15
 
16
16
  it "should whine when the gem you are querying does not exist" do
17
17
  g = Gemline.new('doesnotexist')
18
18
  g.gem_not_found?.should be_true
19
- g.gemline.should be_nil
19
+ expect(g.gemline).to be_nil
20
20
  end
21
21
 
22
22
  it "should properly detect a blocked gem name" do
23
23
  g = Gemline.new('yaml')
24
- g.gem_not_found?.should be_true
25
- g.gemline.should be_nil
24
+ expect(g.gem_not_found?).to be_true
25
+ expect(g.gemline).to be_nil
26
26
  end
27
27
 
28
28
  it "should properly handle funny characters in the returned JSON" do
29
29
  g = Gemline.new('nokogiri')
30
- g.gemline.should == %Q{gem "nokogiri", "~> 1.5.5"}
30
+ expect(g.gemline).to eq(%Q{gem "nokogiri", "~> 1.5.5"})
31
31
  end
32
32
 
33
33
  it "should be able to generate a gemspec-style gemline" do
34
34
  g = Gemline.new('rails', :gemspec => true)
35
- g.gemline.should == %Q!gem.add_dependency(%q<rails>, ["~> 3.1.1"])!
35
+ expect(g.gemline).to eq(%Q!gem.add_dependency(%q<rails>, ["~> 3.1.1"])!)
36
36
  end
37
37
 
38
38
  end
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,7 @@ Bundler.setup
9
9
 
10
10
 
11
11
  RSpec.configure do |c|
12
-
12
+ # c.mock_with :rr
13
13
  end
14
14
 
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-28 00:00:00.000000000 Z
12
+ date: 2012-12-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: crack
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 2.7.0
53
+ version: 2.11.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 2.7.0
61
+ version: 2.11.0
62
62
  description: Grab the latest Gemfile 'gem' line for a specific Ruby gem
63
63
  email:
64
64
  - joe@joealba.com
@@ -94,12 +94,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ segments:
98
+ - 0
99
+ hash: 824165569411568049
97
100
  required_rubygems_version: !ruby/object:Gem::Requirement
98
101
  none: false
99
102
  requirements:
100
103
  - - ! '>='
101
104
  - !ruby/object:Gem::Version
102
105
  version: '0'
106
+ segments:
107
+ - 0
108
+ hash: 824165569411568049
103
109
  requirements: []
104
110
  rubyforge_project:
105
111
  rubygems_version: 1.8.24