ultraquiz 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17bb6a2af3fd6a0a6c09d748cac64058adac3e43
4
+ data.tar.gz: ec0ac4ea570e78de7f66aa6749268d3b36863cfd
5
+ SHA512:
6
+ metadata.gz: 71b807e182240e2a9ad6d1d202f35683f6e597dd3af9c2510433158f644d783854a50e8dc515c4f3b7eba7d8247919c6defd086b71ff00de70df7472b1e74398
7
+ data.tar.gz: 6ecc443e3b0c57cab9db1eca0c4f1e5ac3b16d9517d6faea18bb9123c1467cd509668c78c394ac74ba898720a9d91ad63ab5bb420a6cc541c62498dee711e852
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/cache
19
+ vendor/bundler
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ultraquiz.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Yusuke Ando
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ultraquiz
2
+
3
+ get stats data from rubygems.org
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ultraquiz'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ultraquiz
18
+
19
+ ## Usage
20
+
21
+ ```bundle exec ultraquiz fetchcsv```
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/ultraquiz ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ultraquiz'
4
+ require 'ultraquiz/gems_client'
5
+ require 'thor'
6
+
7
+ module Ultraquiz
8
+ class UltraquizCLI < Thor
9
+ desc 'fetchcsv', 'fetch data from rubygems.org'
10
+ def fetchcsv (query='')
11
+ page = 1
12
+ ultra = Ultraquiz.new
13
+ gems = GemsClient.new
14
+ matched = []
15
+ while true
16
+ response = gems.search('', page)
17
+ break if response.empty?
18
+ page += 1
19
+ next if response.is_a?(String)
20
+ print ultra.putsAsCsv(response)
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ Ultraquiz::UltraquizCLI.start
data/lib/ultraquiz.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'ultraquiz/version'
2
+ require 'ultraquiz/gems_client'
3
+ require 'csv'
4
+
5
+ module Ultraquiz
6
+ class Ultraquiz
7
+ def popular
8
+ gems = GemsClient.new
9
+ gems.search ''
10
+ end
11
+
12
+ def searchAll(query)
13
+ gems = GemsClient.new
14
+ matched = []
15
+ page = 1
16
+ while true
17
+ response = gems.search(query, page)
18
+ break if response.empty?
19
+ page += 1
20
+ matched += response
21
+ end
22
+ matched
23
+ end
24
+
25
+ def putsAsCsv(data)
26
+ csv_string = CSV.generate do |csv|
27
+ data.each do |row|
28
+ csv << [
29
+ row["name"],
30
+ row["downloads"],
31
+ row["version"],
32
+ row["version_downloads"],
33
+ row["authors"]
34
+ ]
35
+ end
36
+ end
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,14 @@
1
+ require 'gems'
2
+ require 'gems/client'
3
+
4
+ module Ultraquiz
5
+ class GemsClient < Gems::Client
6
+ def search(query, page = 1)
7
+ yaml_data = get(
8
+ "/api/v1/search.yaml",
9
+ {:query => query, :page => "#{page}"}
10
+ )
11
+ response = YAML.load(yaml_data)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module Ultraquiz
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'ultraquiz'
2
+
3
+ describe 'Ultraquiz', '#popular' do
4
+ it "returns list includes 100 gems" do
5
+ ultraquiz = Ultraquiz::Ultraquiz.new
6
+ ultraquiz.popular.size.should eq(30)
7
+ ultraquiz.popular[0]["name"].should eq('thor')
8
+ end
9
+ end
10
+
11
+ describe 'Ultraquiz', '#putsAsCsv' do
12
+ it "returns single line of csv for data" do
13
+ ultraquiz = Ultraquiz::Ultraquiz.new
14
+ ultraquiz.putsAsCsv([{
15
+ "name" => 'thor',
16
+ "downloads" => 100000,
17
+ "version" => '0.18.1',
18
+ "version_downloads" => 3000,
19
+ "authors" => 'Katz'
20
+ }]).should eq('thor,100000,0.18.1,3000,Katz' + "\n")
21
+ end
22
+
23
+ it "returns multi line of csv for data" do
24
+ ultraquiz = Ultraquiz::Ultraquiz.new
25
+ ultraquiz.putsAsCsv([{
26
+ "name" => 'thor',
27
+ "downloads" => 100000,
28
+ "version" => '0.18.1',
29
+ "version_downloads" => 3000,
30
+ "authors" => 'Katz'
31
+ },{
32
+ "name" => 'rake',
33
+ "downloads" => 90000,
34
+ "version" => '10.1.1',
35
+ "version_downloads" => 4000,
36
+ "authors" => 'Jim'
37
+ }]).should eq('thor,100000,0.18.1,3000,Katz' + "\n" + 'rake,90000,10.1.1,4000,Jim' + "\n")
38
+ end
39
+ end
data/ultraquiz.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ultraquiz/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ultraquiz"
8
+ spec.version = Ultraquiz::VERSION
9
+ spec.authors = ["Yusuke Ando"]
10
+ spec.email = ["yandod@gmail.com"]
11
+ spec.description = 'get trivial stats from rubygems.org'
12
+ spec.summary = 'get trivial stats'
13
+ spec.homepage = "https://github.com/yandod/ultraquiz"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "gems"
22
+ spec.add_dependency "thor"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ultraquiz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yusuke Ando
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gems
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: get trivial stats from rubygems.org
84
+ email:
85
+ - yandod@gmail.com
86
+ executables:
87
+ - ultraquiz
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/ultraquiz
97
+ - lib/ultraquiz.rb
98
+ - lib/ultraquiz/gems_client.rb
99
+ - lib/ultraquiz/version.rb
100
+ - spec/ultraquiz_spec.rb
101
+ - ultraquiz.gemspec
102
+ homepage: https://github.com/yandod/ultraquiz
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.0.3
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: get trivial stats
126
+ test_files:
127
+ - spec/ultraquiz_spec.rb