gem-search 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +7 -2
- data/README.md +10 -7
- data/circle.yml +6 -0
- data/gem-search.gemspec +5 -8
- data/lib/gem_search/rendering.rb +1 -1
- data/lib/gem_search/version.rb +1 -1
- data/sideci_build.txt +0 -0
- data/spec/bin/gem_search_spec.rb +5 -7
- data/spec/commands/browse_spec.rb +3 -10
- data/spec/commands/run_spec.rb +9 -15
- data/spec/executor_spec.rb +29 -31
- data/spec/spec_helper.rb +14 -0
- metadata +13 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf0634f75957207eecfa92cbc539e54fda22cbd3
|
4
|
+
data.tar.gz: afa21e69df314d524de7da7f37a712dc4002b894
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f09449157f6142afa641e2fd78b06cf3a54f9d87005ddb0c3fabf77145ffacac0f4dc52d87fa7af685f248ab66e761ecdbb80667246826060089be7f27046dc
|
7
|
+
data.tar.gz: 77c99fdbc05795f6d99a665161db680b37ee2e964c1a5ddfe2e6f833b89bb36f13202fc822f0b7b4305f860fab575ec924bf4d1051f791b5642e0fd6736d99ea
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,17 @@
|
|
1
|
-
[![
|
1
|
+
[![CircleCI](https://img.shields.io/circleci/project/rochefort/gem-search.svg?style=flat)](https://circleci.com/gh/rochefort/gem-search)
|
2
2
|
[![Dependency Status](http://img.shields.io/gemnasium/rochefort/gem-search.svg?style=flat)](https://gemnasium.com/rochefort/gem-search)
|
3
3
|
[![Code Climate](http://img.shields.io/codeclimate/github/rochefort/gem-search.svg?style=flat)](https://codeclimate.com/github/rochefort/gem-search)
|
4
4
|
[![Gem Version](http://img.shields.io/gem/v/gem-search.svg?style=flat)](http://badge.fury.io/rb/gem-search)
|
5
5
|
|
6
6
|
# gem-search
|
7
7
|
|
8
|
+
Now gem-search is not published as a rubygem.
|
8
9
|
gem-search is a command line utitlity like rubygems('gem search').
|
9
10
|
You can see a download total gem and sort columns.
|
10
11
|
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
Ruby version >= 2.0.0.
|
11
15
|
|
12
16
|
## Installation
|
13
17
|
|
@@ -118,12 +122,11 @@ node-webkit-bootstrap (1.0.0) 226 226 https://gi
|
|
118
122
|
### Browse
|
119
123
|
It open rubygem's homepage in the system's default web browser.
|
120
124
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
125
|
+
gem-search -b `keyword'
|
126
|
+
|
127
|
+
or
|
128
|
+
|
129
|
+
gem-search --browse `keyword'
|
127
130
|
|
128
131
|
|
129
132
|
## Contributing
|
data/circle.yml
ADDED
data/gem-search.gemspec
CHANGED
@@ -30,14 +30,11 @@ Gem::Specification.new do |gem|
|
|
30
30
|
|
31
31
|
gem.post_install_message = install_message
|
32
32
|
|
33
|
-
gem.add_dependency 'slop', '~>4.
|
34
|
-
gem.add_dependency 'json', '~>1.8.2'
|
33
|
+
gem.add_dependency 'slop', '~>4.2.1'
|
35
34
|
gem.add_dependency 'mem', '~>0.1.5'
|
36
35
|
|
37
|
-
|
38
|
-
gem.add_development_dependency '
|
39
|
-
gem.add_development_dependency '
|
40
|
-
|
41
|
-
gem.add_development_dependency 'rspec', '~> 3.0.0'
|
42
|
-
gem.add_development_dependency 'simplecov', '~> 0.9.0'
|
36
|
+
gem.add_development_dependency 'webmock', '~>1.22.6'
|
37
|
+
gem.add_development_dependency 'rake', '~>10.3.1'
|
38
|
+
gem.add_development_dependency 'rspec', '~>3.4.0'
|
39
|
+
gem.add_development_dependency 'simplecov', '~>0.11.2'
|
43
40
|
end
|
data/lib/gem_search/rendering.rb
CHANGED
@@ -18,7 +18,7 @@ module Gem::Search
|
|
18
18
|
|
19
19
|
def ruled_line_size(gems)
|
20
20
|
@ruled_line_size = DEFAULT_RULED_LINE_SIZE.dup
|
21
|
-
max_name_size = gems.map { |gem| "#{gem['name']
|
21
|
+
max_name_size = gems.map { |gem| "#{gem['name']} (#{gem['version']})".size }.max
|
22
22
|
@ruled_line_size[0] = max_name_size if max_name_size > @ruled_line_size[0]
|
23
23
|
end
|
24
24
|
|
data/lib/gem_search/version.rb
CHANGED
data/sideci_build.txt
ADDED
File without changes
|
data/spec/bin/gem_search_spec.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
BIN = 'bin/gem-search'
|
4
2
|
|
5
3
|
USAGE = <<-EOS
|
@@ -16,13 +14,13 @@ Usage: gem-search gem_name [options]
|
|
16
14
|
-h, --help Display this help message.
|
17
15
|
EOS
|
18
16
|
|
19
|
-
RSpec.
|
20
|
-
|
21
|
-
|
17
|
+
RSpec.describe 'bin/gem-search' do
|
18
|
+
shared_examples 'display an usage' do
|
19
|
+
it 'display an usage' do
|
20
|
+
should == USAGE
|
21
|
+
end
|
22
22
|
end
|
23
|
-
end
|
24
23
|
|
25
|
-
RSpec.describe 'bin/gem-search' do
|
26
24
|
context 'with no argument' do
|
27
25
|
subject { `#{BIN}` }
|
28
26
|
it_behaves_like 'display an usage'
|
@@ -1,21 +1,14 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
include Gem::Search
|
4
2
|
|
5
3
|
RSpec.describe Commands::Browse do
|
6
4
|
describe '#call' do
|
7
|
-
before do
|
8
|
-
@executor = Executor.new
|
9
|
-
allow(Executor).to receive(:new).and_return(@executor)
|
10
|
-
@options = { browse: query }
|
11
|
-
end
|
12
|
-
|
13
5
|
let(:query) { 'factory_girl' }
|
6
|
+
let(:options) { { browse: query } }
|
14
7
|
|
15
8
|
context 'with browse option' do
|
16
9
|
it 'called Executor#browse with browse option' do
|
17
|
-
|
18
|
-
Commands::Browse.new(
|
10
|
+
expect_any_instance_of(Executor).to receive(:browse).with(query).once
|
11
|
+
Commands::Browse.new(options).call
|
19
12
|
end
|
20
13
|
end
|
21
14
|
end
|
data/spec/commands/run_spec.rb
CHANGED
@@ -1,35 +1,29 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
include Gem::Search
|
4
2
|
|
5
3
|
RSpec.describe Commands::Run do
|
6
4
|
describe '#call' do
|
7
5
|
before do
|
8
|
-
|
9
|
-
allow(
|
10
|
-
|
11
|
-
allow(@options).to receive(:arguments).and_return([query])
|
12
|
-
allow(@options).to receive(:detail?).and_return(false)
|
6
|
+
allow(options).to receive(:arguments).and_return([query])
|
7
|
+
allow(options).to receive(:detail?).and_return(false)
|
8
|
+
allow(options).to receive(:[]).with('sort')
|
13
9
|
stub_request_search(query, 1, dummy_search_result)
|
14
10
|
stub_request_search_no_result_with_page(query, 2)
|
15
11
|
end
|
16
|
-
|
17
12
|
let(:query) { 'factory_girl' }
|
13
|
+
let(:options) { double('options') }
|
18
14
|
|
19
15
|
context 'without sort option' do
|
20
16
|
it 'called Executor#search without sort option' do
|
21
|
-
|
22
|
-
Commands::Run.new(
|
17
|
+
expect_any_instance_of(Executor).to receive(:search).with(query, default_opts).once
|
18
|
+
Commands::Run.new(options).call
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
22
|
context 'with sort option' do
|
27
|
-
before
|
28
|
-
allow(@options).to receive(:sort).and_return('a')
|
29
|
-
end
|
23
|
+
before { allow(@options).to receive(:sort).and_return('a') }
|
30
24
|
it 'called Executor#search with sort option' do
|
31
|
-
|
32
|
-
Commands::Run.new(
|
25
|
+
expect_any_instance_of(Executor).to receive(:search).with(query, default_opts(sort: 'downloads')).once
|
26
|
+
Commands::Run.new(options).call
|
33
27
|
end
|
34
28
|
end
|
35
29
|
end
|
data/spec/executor_spec.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
1
|
include Gem::Search
|
4
2
|
|
5
3
|
RSpec.describe Executor do
|
6
|
-
|
7
|
-
@executor = Executor.new
|
8
|
-
end
|
4
|
+
let(:executor) { Executor.new }
|
9
5
|
|
10
6
|
describe '#search' do
|
11
7
|
context 'when a network error occurred' do
|
@@ -14,13 +10,13 @@ RSpec.describe Executor do
|
|
14
10
|
.to_return(status: 500, body: '[]')
|
15
11
|
end
|
16
12
|
let(:query) { 'network_error_orccurred' }
|
17
|
-
it { expect {
|
13
|
+
it { expect { executor.search(query) }.to raise_error(Exception) }
|
18
14
|
end
|
19
15
|
|
20
16
|
context 'when no matching gem' do
|
21
17
|
before { stub_request_search_no_result_with_page(query, 1) }
|
22
18
|
let(:query) { 'no_match_gem_name' }
|
23
|
-
it { expect {
|
19
|
+
it { expect { executor.search(query, default_opts) }.to raise_error(LibraryNotFound) }
|
24
20
|
end
|
25
21
|
|
26
22
|
describe 'with detail' do
|
@@ -40,7 +36,7 @@ RSpec.describe Executor do
|
|
40
36
|
|factory_girl_rails (3.5.0) 39724 1238780 http://github.com/thoughtbot/factory_girl_rails
|
41
37
|
|factory_girl_generator (0.0.3) 8015 15547 http://github.com/leshill/factory_girl_generator
|
42
38
|
EOS
|
43
|
-
expect {
|
39
|
+
expect { executor.search(query, default_opts(detail: true)) }.to output(res).to_stdout
|
44
40
|
end
|
45
41
|
end
|
46
42
|
end
|
@@ -62,7 +58,7 @@ RSpec.describe Executor do
|
|
62
58
|
|factory_girl_rails (3.5.0) 39724 1238780
|
63
59
|
|factory_girl_generator (0.0.3) 8015 15547
|
64
60
|
EOS
|
65
|
-
expect {
|
61
|
+
expect { executor.search(query, default_opts) }.to output(res).to_stdout
|
66
62
|
end
|
67
63
|
end
|
68
64
|
|
@@ -76,7 +72,7 @@ RSpec.describe Executor do
|
|
76
72
|
|factory_girl_rails (3.5.0) 39724 1238780
|
77
73
|
|factory_girl_generator (0.0.3) 8015 15547
|
78
74
|
EOS
|
79
|
-
expect {
|
75
|
+
expect { executor.search(query, default_opts) }.to output(res).to_stdout
|
80
76
|
end
|
81
77
|
end
|
82
78
|
|
@@ -90,7 +86,7 @@ RSpec.describe Executor do
|
|
90
86
|
|factory_girl_generator (0.0.3) 8015 15547
|
91
87
|
|factory_girl (3.6.0) 541 2042859
|
92
88
|
EOS
|
93
|
-
expect {
|
89
|
+
expect { executor.search(query, default_opts(sort: 'version_downloads')) }.to output(res).to_stdout
|
94
90
|
end
|
95
91
|
end
|
96
92
|
|
@@ -104,7 +100,7 @@ RSpec.describe Executor do
|
|
104
100
|
|factory_girl_generator (0.0.3) 8015 15547
|
105
101
|
|factory_girl_rails (3.5.0) 39724 1238780
|
106
102
|
EOS
|
107
|
-
expect {
|
103
|
+
expect { executor.search(query, default_opts(sort: 'name')) }.to output(res).to_stdout
|
108
104
|
end
|
109
105
|
end
|
110
106
|
end
|
@@ -186,7 +182,7 @@ RSpec.describe Executor do
|
|
186
182
|
|tasty-cucumber-client (0.1.10) 1504 11518
|
187
183
|
|vagrant-cucumber-host (0.1.14) 163 163
|
188
184
|
EOS
|
189
|
-
expect {
|
185
|
+
expect { executor.search(query, default_opts(sort: 'name')) }.to output(res).to_stdout
|
190
186
|
end
|
191
187
|
end
|
192
188
|
|
@@ -204,7 +200,7 @@ RSpec.describe Executor do
|
|
204
200
|
|-------------------------------------------------- -------- ---------
|
205
201
|
|size_is_42_2345678901234567890123456789012 (0.0.1) 100 1000
|
206
202
|
EOS
|
207
|
-
expect {
|
203
|
+
expect { executor.search(query, default_opts) }.to output(res).to_stdout
|
208
204
|
end
|
209
205
|
end
|
210
206
|
|
@@ -221,7 +217,7 @@ RSpec.describe Executor do
|
|
221
217
|
|--------------------------------------------------- -------- ---------
|
222
218
|
|size_is_43_23456789012345678901234567890123 (0.0.2) 200 2000
|
223
219
|
EOS
|
224
|
-
expect {
|
220
|
+
expect { executor.search(query, default_opts) }.to output(res).to_stdout
|
225
221
|
end
|
226
222
|
end
|
227
223
|
end
|
@@ -234,25 +230,25 @@ RSpec.describe Executor do
|
|
234
230
|
.to_return(status: 500, body: '[]')
|
235
231
|
end
|
236
232
|
let(:query) { 'network_error_orccurred' }
|
237
|
-
it { expect {
|
233
|
+
it { expect { executor.browse(query) }.to raise_error(Exception) }
|
238
234
|
end
|
239
235
|
|
240
236
|
context 'when no matching gem' do
|
241
237
|
before { stub_request_gems_no_result(query) }
|
242
238
|
let(:query) { 'no_match_gem_name' }
|
243
|
-
it { expect {
|
239
|
+
it { expect { executor.browse(query) }.to raise_error(OpenURI::HTTPError) }
|
244
240
|
end
|
245
241
|
|
246
242
|
context 'when no homepage_uri' do
|
247
243
|
before do
|
248
244
|
url = Executor::GEM_URL % query
|
249
|
-
allow(
|
245
|
+
allow(executor).to receive(:system).with(anything, url)
|
250
246
|
stub_request_gems(query, load_http_stubs("gems/#{query}.json"))
|
251
247
|
end
|
252
248
|
let(:query) { 'git-trend_no_homepage' }
|
253
249
|
|
254
250
|
it 'open a rubygems url' do
|
255
|
-
|
251
|
+
executor.browse(query)
|
256
252
|
end
|
257
253
|
end
|
258
254
|
|
@@ -260,13 +256,13 @@ RSpec.describe Executor do
|
|
260
256
|
before do
|
261
257
|
http_stub = load_http_stubs("gems/#{query}.json")
|
262
258
|
url = JSON.parse(http_stub)['homepage_uri']
|
263
|
-
allow(
|
259
|
+
allow(executor).to receive(:system).with(anything, url)
|
264
260
|
stub_request_gems(query, http_stub)
|
265
261
|
end
|
266
262
|
let(:query) { 'git-trend' }
|
267
263
|
|
268
264
|
it 'open a homepage url' do
|
269
|
-
|
265
|
+
executor.browse(query)
|
270
266
|
end
|
271
267
|
end
|
272
268
|
end
|
@@ -274,18 +270,20 @@ RSpec.describe Executor do
|
|
274
270
|
private
|
275
271
|
|
276
272
|
def dummy_search_result_name_size_is_42
|
277
|
-
[{
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
273
|
+
[{
|
274
|
+
'name' => 'size_is_42_2345678901234567890123456789012',
|
275
|
+
'downloads' => 1000,
|
276
|
+
'version' => '0.0.1',
|
277
|
+
'version_downloads' => 100
|
278
|
+
}].to_json
|
282
279
|
end
|
283
280
|
|
284
281
|
def dummy_search_result_name_size_is_43
|
285
|
-
[{
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
282
|
+
[{
|
283
|
+
'name' => 'size_is_43_23456789012345678901234567890123',
|
284
|
+
'downloads' => 2000,
|
285
|
+
'version' => '0.0.2',
|
286
|
+
'version_downloads' => 200
|
287
|
+
}].to_json
|
290
288
|
end
|
291
289
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,21 @@ require 'webmock/rspec'
|
|
8
8
|
require 'gem_search'
|
9
9
|
|
10
10
|
RSpec.configure do |config|
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
expectations.syntax = :expect
|
13
|
+
end
|
14
|
+
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.syntax = :expect
|
17
|
+
mocks.verify_partial_doubles = true
|
18
|
+
end
|
19
|
+
config.filter_run :focus
|
20
|
+
config.run_all_when_everything_filtered = true
|
11
21
|
config.expose_dsl_globally = false
|
22
|
+
|
23
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
24
|
+
config.order = :random
|
25
|
+
Kernel.srand config.seed
|
12
26
|
end
|
13
27
|
|
14
28
|
def load_http_stubs(file_name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rochefort
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: 4.2.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.2
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.8.2
|
26
|
+
version: 4.2.1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: mem
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +44,14 @@ dependencies:
|
|
58
44
|
requirements:
|
59
45
|
- - "~>"
|
60
46
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
47
|
+
version: 1.22.6
|
62
48
|
type: :development
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
54
|
+
version: 1.22.6
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: rake
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,28 +72,28 @@ dependencies:
|
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: 3.
|
75
|
+
version: 3.4.0
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: 3.
|
82
|
+
version: 3.4.0
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: simplecov
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
89
|
+
version: 0.11.2
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
96
|
+
version: 0.11.2
|
111
97
|
description: search gems with using rubygems.org API
|
112
98
|
email:
|
113
99
|
- terasawan@gmail.com
|
@@ -124,6 +110,7 @@ files:
|
|
124
110
|
- README.md
|
125
111
|
- Rakefile
|
126
112
|
- bin/gem-search
|
113
|
+
- circle.yml
|
127
114
|
- gem-search.gemspec
|
128
115
|
- lib/gem_search.rb
|
129
116
|
- lib/gem_search/command_builder.rb
|
@@ -136,6 +123,7 @@ files:
|
|
136
123
|
- lib/gem_search/executor.rb
|
137
124
|
- lib/gem_search/rendering.rb
|
138
125
|
- lib/gem_search/version.rb
|
126
|
+
- sideci_build.txt
|
139
127
|
- spec/bin/gem_search_spec.rb
|
140
128
|
- spec/commands/browse_spec.rb
|
141
129
|
- spec/commands/run_spec.rb
|
@@ -165,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
153
|
version: '0'
|
166
154
|
requirements: []
|
167
155
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.5.1
|
169
157
|
signing_key:
|
170
158
|
specification_version: 4
|
171
159
|
summary: search gems with using rubygems.org API
|