gem-search 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 231d6017b8ed3cc3a800f89f12a197dc8484ed1f
4
- data.tar.gz: c5bef05b461fcad27de5b0c730eec8b9c49606cd
3
+ metadata.gz: 348c9b20914b9409de3a3fcf3284b1a6f08f9706
4
+ data.tar.gz: 65ff9dcbc7257820546d7062d8f8c04b70213e7f
5
5
  SHA512:
6
- metadata.gz: 249916d10c938be1f880f3013f4a701e7eb52660d853d55d8cec2b280d1f0b6065628ab219b96a25c5e3777e6569365cfa9008a4cdd78d94aa93878ad3e3ddfa
7
- data.tar.gz: d067723e49098a5fa604b5c12b08a4a916dd4b54451eb4cdeb7a5c19cb433df89218be795343baf318f98000a20857eb46f98b2e28f279bc55a97102d5cb2e6f
6
+ metadata.gz: 96dc3947fde43de747ecdd8d0cbb8105cc13b6878a472c0d287d4b72880f2f675d2d3df5bdedb95546d28ffe0a3bbe3f6652ca5fc0d14858cb2f62e1e0658f38
7
+ data.tar.gz: 9507652f04758b46fea9f6d90760d4b7cb93db5b7ba3d9ad1c6b33b7e2ce1f2b13205c287010042433894cfe676e49097705df603ed0da05f0c1785ac2151e5e
@@ -1,33 +1,39 @@
1
+ ## v0.1.8
2
+
3
+ - Add variations of sort [9aed9e4]
4
+ variations: a/all/, n/name, v/ver/version
5
+ (not case-sensitive)
6
+
1
7
  ## v0.1.7
2
8
 
3
- * Remove reduncancy dots [17ae8cd]
9
+ - Remove reduncancy dots [17ae8cd]
4
10
  The request was one extra.
5
11
 
6
12
  ## v0.1.6
7
13
 
8
- * Update gems [17ae8cd]
9
- * Refactor tests
14
+ - Update gems [17ae8cd]
15
+ - Refactor tests
10
16
 
11
17
  ## v0.1.5
12
18
 
13
- * Update slop for v4.0.0 and refactor. [94db668]
19
+ - Update slop for v4.0.0 and refactor. [94db668]
14
20
  unsupported Ruby 1.9.0
15
21
 
16
22
  ## v0.1.4
17
23
 
18
- * Fix cannot open gem url when gem has no homepage url. [b476b28]
24
+ - Fix cannot open gem url when gem has no homepage url. [b476b28]
19
25
 
20
26
  ## v0.1.3
21
27
 
22
- * Implement a feature that is shown a homepage url when detail ooption is selected [f89d9c2]
28
+ - Implement a feature that is shown a homepage url when detail ooption is selected [f89d9c2]
23
29
 
24
30
  ## v0.1.2
25
31
 
26
- * Correspond to linux with browse option [80bb881]
27
- * Implement a feature that is to open homepage url by a default browser. [49d2924]
32
+ - Correspond to linux with browse option [80bb881]
33
+ - Implement a feature that is to open homepage url by a default browser. [49d2924]
28
34
 
29
35
  ## v0.1.1
30
36
 
31
- * Change default sort option from n[ame] to do a[ll] (download) [7041464]
32
- * Fix default sort option doesn't work. [e404c6e]
33
- * Fix proxy doesn't work by not using authentication [210ea37]
37
+ - Change default sort option from n[ame] to do a[ll] (download) [7041464]
38
+ - Fix default sort option doesn't work. [e404c6e]
39
+ - Fix proxy doesn't work by not using authentication [210ea37]
data/README.md CHANGED
@@ -27,8 +27,8 @@ Use the gem-search as follows:
27
27
  ### Sorted by DL(all)
28
28
 
29
29
  gem-search `keyword'
30
- or
31
30
  gem-search `keyword' -s a
31
+ gem-search `keyword' -s all
32
32
 
33
33
  e.g.:
34
34
 
@@ -48,12 +48,14 @@ gtk-webkit-ruby (0.0.3) 289 289
48
48
  ```
49
49
 
50
50
  ### Sorted by gem name
51
+
51
52
  gem-search `keyword' -s n
53
+ gem-search `keyword' -s name
52
54
 
53
55
  e.g.:
54
56
 
55
57
  ```
56
- $ gem-search webkit
58
+ $ gem-search webkit -s n
57
59
  NAME DL(ver) DL(all)
58
60
  -------------------------------------------------- -------- ---------
59
61
  capybara-webkit (0.12.1) 24863 185214
@@ -68,7 +70,10 @@ webkit-rspec-formatter (2.0.2) 613 1573
68
70
  ```
69
71
 
70
72
  ### Sorted by DL(ver)
73
+
71
74
  gem-search `keyword' -s v
75
+ gem-search `keyword' -s ver
76
+ gem-search `keyword' -s version
72
77
 
73
78
  e.g.:
74
79
 
@@ -2,9 +2,9 @@ module GemSearch
2
2
  module Commands
3
3
  class Run < Base
4
4
  ENABLE_SORT_OPTS = {
5
- 'v' => 'version_downloads',
6
5
  'a' => 'downloads',
7
6
  'n' => 'name',
7
+ 'v' => 'version_downloads',
8
8
  }
9
9
 
10
10
  def call
@@ -28,8 +28,9 @@ module GemSearch
28
28
  private
29
29
 
30
30
  def setup_opts
31
+ sort = options['sort'] ? ENABLE_SORT_OPTS[options['sort'][0].downcase] : nil
31
32
  {
32
- sort: ENABLE_SORT_OPTS[options['sort']] || 'downloads',
33
+ sort: sort || 'downloads',
33
34
  detail: options.detail?
34
35
  }
35
36
  end
@@ -1,3 +1,3 @@
1
1
  module GemSearch
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -1,6 +1,14 @@
1
1
  include GemSearch
2
2
 
3
3
  RSpec.describe Commands::Run do
4
+ shared_examples 'sort example' do |expected_option, actual_option|
5
+ before { allow(options).to receive(:[]).with('sort').and_return(actual_option) }
6
+ it 'called Executor#search with sort option' do
7
+ expect_any_instance_of(Executor).to receive(:search).with(query, default_opts(sort: expected_option)).once
8
+ Commands::Run.new(options).call
9
+ end
10
+ end
11
+
4
12
  describe '#call' do
5
13
  before do
6
14
  allow(options).to receive(:arguments).and_return([query])
@@ -12,18 +20,50 @@ RSpec.describe Commands::Run do
12
20
  let(:query) { 'factory_girl' }
13
21
  let(:options) { double('options') }
14
22
 
15
- context 'without sort option' do
16
- it 'called Executor#search without sort option' do
17
- expect_any_instance_of(Executor).to receive(:search).with(query, default_opts).once
18
- Commands::Run.new(options).call
23
+ describe 'sort option' do
24
+ describe 'sort by all' do
25
+ context 'without sort option' do
26
+ include_examples 'sort example', 'downloads', nil
27
+ end
28
+ context 'with disalbe sort option' do
29
+ include_examples 'sort example', 'downloads', 'xyz'
30
+ end
31
+ context 'with a' do
32
+ include_examples 'sort example', 'downloads', 'a'
33
+ end
34
+ context 'with all' do
35
+ include_examples 'sort example', 'downloads', 'all'
36
+ end
37
+ context 'with ALL' do
38
+ include_examples 'sort example', 'downloads', 'ALL'
39
+ end
19
40
  end
20
41
  end
21
42
 
22
- context 'with sort option' do
23
- before { allow(@options).to receive(:sort).and_return('a') }
24
- it 'called Executor#search with sort option' do
25
- expect_any_instance_of(Executor).to receive(:search).with(query, default_opts(sort: 'downloads')).once
26
- Commands::Run.new(options).call
43
+ describe 'sort by name' do
44
+ context 'with n' do
45
+ include_examples 'sort example', 'name', 'n'
46
+ end
47
+ context 'with name' do
48
+ include_examples 'sort example', 'name', 'name'
49
+ end
50
+ context 'with NAME' do
51
+ include_examples 'sort example', 'name', 'NAME'
52
+ end
53
+ end
54
+
55
+ describe 'sort by ver' do
56
+ context 'with v' do
57
+ include_examples 'sort example', 'version_downloads', 'v'
58
+ end
59
+ context 'with ver' do
60
+ include_examples 'sort example', 'version_downloads', 'ver'
61
+ end
62
+ context 'with version' do
63
+ include_examples 'sort example', 'version_downloads', 'version'
64
+ end
65
+ context 'with VER' do
66
+ include_examples 'sort example', 'version_downloads', 'VER'
27
67
  end
28
68
  end
29
69
  end
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.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - rochefort
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop