fastgem 0.0.3 → 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: ef21f9c078009e20ecd2dfa8c0bb29c57177b1e2
4
- data.tar.gz: 0429bf129f68359f08864492d8858544c6f83c19
3
+ metadata.gz: 07c5bc3bda5b6198afdbdcdcfbd9971626cefb56
4
+ data.tar.gz: 2662394f5a6a29f2b36cc1a3a1ed4d2d7b5be2f1
5
5
  SHA512:
6
- metadata.gz: 0094b1cb3525b2dd0d9ebb2a6973d577fc418128d35a951e719a66f65e87bd2ac7c9507124d8924d778309293bced03e73cb22c1ba8b1bffe2a110d656d7906e
7
- data.tar.gz: e8acfad6f0ae581621bd91d62f34aeca14a431c9c83def711c90fae4b39891736658dac6620f6c4652d6637a22ed52b6d4cf56aa355377fca74171fed95be61c
6
+ metadata.gz: d3e3212b5334d5ce1195de9a5ea85effa7c2db7657b8ac9d80197393a42b922b3441923e9739073ce70e024a8fec3126852258617b3c52559c6762d6982a8bf0
7
+ data.tar.gz: 99289d3db2474e589f8b1ff35fa438f2bbd5611ee3f86220f7fcdca6f628210462481d5c9d299ca5a0fc64a428b164b0891e1ba2031a723879eda43a567cf055
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fastgem (0.0.3)
4
+ fastgem (0.1.8)
5
5
  gli (= 2.13.4)
6
6
  rainbow (= 2.0)
7
7
  terminal-table (= 1.5.2)
data/README.md CHANGED
@@ -1,35 +1,37 @@
1
1
  # Fastgem
2
- ![](https://badge.fury.io/rb/fastgem.svg)
2
+ ![fastgem project logo](https://badge.fury.io/rb/fastgem.svg)
3
3
 
4
- Fastgem is a terminal client for search ruby gem.
5
- Only supports Ruby 1.9 and later.
6
- To install fastgem, we need ruby pre-installed, please refer to https://www.ruby-lang.org/en/installation/ to know how to install ruby.
7
- I recommend rvm to control the version of installed ruby.
4
+ Fastgem is a terminal client for searching inside your ruby gems.
8
5
 
6
+ https://github.com/Nguyenanh/fastgem
9
7
 
10
- - **Homepage**: https://github.com/Nguyenanh/fastgem
11
-
8
+ Required:
9
+ - `ruby` 1.9 or greater (see https://www.ruby-lang.org/en/installation/ )
10
+ - `rubygems` (included with ruby; see https://github.com/rubygems/rubygems )
12
11
 
12
+ Recommended:
13
+ - `rvm` for controling your versions of ruby (see: https://github.com/rvm/rvm )
13
14
 
14
15
  ## Installation
15
- Install it yourself as:
16
+
17
+ Install as you would any other ruby gem:
18
+
16
19
  ```
17
20
  $ gem install fastgem
18
21
  ```
19
- ![](https://cloud.githubusercontent.com/assets/7424863/12011037/5bb30e08-acf1-11e5-9a9d-db3685af0621.jpg)
22
+ ![screenshot of fastgem output](https://cloud.githubusercontent.com/assets/7424863/12011037/5bb30e08-acf1-11e5-9a9d-db3685af0621.jpg)
20
23
 
21
- ## Use
22
- in your terminal
24
+ ## Using
25
+
26
+ To find which gems contain the string "foo", you would type:
23
27
  ```
24
- fastgem search 'text-you-want-search'
28
+ $ fastgem search 'foo'
25
29
  ```
26
30
 
27
31
  ## Contributing
28
32
 
29
- 1. Fork it ( https://github.com/Nguyenanh/fastgem/fork)
33
+ 1. Fork the project ( https://github.com/Nguyenanh/fastgem/fork )
30
34
  2. Create your feature branch (`git checkout -b my-new-feature`)
31
35
  3. Commit your changes (`git commit -am 'Add some feature'`)
32
36
  4. Push to the branch (`git push origin my-new-feature`)
33
- 5. Create new Pull Request
34
-
35
- ## Inspired by
37
+ 5. Create a new pull request with a description of your changes
@@ -4,7 +4,7 @@ require 'fastgem'
4
4
 
5
5
  include GLI::App
6
6
 
7
- program_desc 'Search Gem from Rubygem colors'
7
+ program_desc 'Search Gem from Rubygem.org colors'
8
8
 
9
9
  version Fastgem::VERSION
10
10
 
@@ -21,16 +21,12 @@ flag [:f,:flagname]
21
21
 
22
22
 
23
23
  desc 'Search gem with keywork command line'
24
- arg_name 'Search Top 10 Gem'
24
+ arg_name 'foo'
25
25
  command :search do |c|
26
- c.desc 'Describe a switch to new'
27
- c.switch :s
28
-
29
- c.desc 'Describe a flag to new'
30
- c.default_value 'default'
31
- c.flag :f
26
+ c.desc 'Order by count downloads'
27
+ c.switch :d
32
28
  c.action do |global_options,options,args|
33
- Fastgem.search(args[0])
29
+ Fastgem.search(args[0], options)
34
30
  end
35
31
  end
36
32
  exit run(ARGV)
@@ -12,14 +12,14 @@ spec = Gem::Specification.new do |s|
12
12
  ")
13
13
  s.require_paths << 'lib'
14
14
  s.has_rdoc = true
15
- s.extra_rdoc_files = ['README.rdoc','fastgem.rdoc']
15
+ s.extra_rdoc_files = ['README.rdoc', 'fastgem.rdoc']
16
16
  s.rdoc_options << '--title' << 'fastgem' << '--main' << 'README.rdoc' << '--ri'
17
17
  s.bindir = 'bin'
18
- s.executables << "fastgem"
18
+ s.executables << 'fastgem'
19
19
  s.add_development_dependency('rake')
20
20
  s.add_development_dependency('rdoc')
21
21
  s.add_development_dependency('aruba')
22
22
  s.add_runtime_dependency('rainbow', '2.0')
23
- s.add_runtime_dependency('gli','2.13.4')
23
+ s.add_runtime_dependency('gli', '2.13.4')
24
24
  s.add_runtime_dependency('terminal-table', '1.5.2')
25
25
  end
@@ -2,17 +2,29 @@ require 'fastgem/version.rb'
2
2
  require 'fastgem/table.rb'
3
3
  %w(net/https uri thread json).each { |lib| require lib }
4
4
  module Fastgem
5
- def self.search(q)
5
+ def self.search(q, options)
6
6
  uri = URI.parse("https://rubygems.org/api/v1/search.json?query=#{q}")
7
7
  http = Net::HTTP.new(uri.host, uri.port)
8
8
  http.use_ssl = true
9
9
  request = Net::HTTP::Get.new(uri.request_uri)
10
10
  response = http.request(request)
11
11
  results = JSON.parse(response.body)
12
+ results = sort_downloads(results) if options[:d]
13
+ template(results)
14
+ end
15
+
16
+ private
17
+
18
+ def self.sort_downloads(results)
19
+ results.sort!{|a,b| b['downloads'] <=> a['downloads']}
20
+ end
21
+
22
+ def self.template(results)
12
23
  table = Fastgem::Table.new
13
24
  results.each do |result|
14
25
  table.format(result)
15
26
  end
16
27
  table.after
17
28
  end
29
+
18
30
  end
@@ -1,3 +1,3 @@
1
1
  module Fastgem
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nguyen Anh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-28 00:00:00.000000000 Z
11
+ date: 2015-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake