RubyGemsApi 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 54de93714ccaab6d7aa97da29c42bd81a30925e0
4
+ data.tar.gz: ee5b13ef796f562fa156b856ebb89a8909df6e8b
5
+ SHA512:
6
+ metadata.gz: d85f3e69506ee94f646668d2cfac56dcad8902a09d85471009e90ba77510eacb2ba99c83f761ff351ac15f6b1b627860665575f7d784d1f228b193524e081452
7
+ data.tar.gz: 744c2d3cec818c44e024757db6801341cf61fc52ba16e36a569c82dd7c3f4887fc56de707ff126258bb94035358c66049c11b81156c0f674be319c75cedf4cfa
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,22 @@
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
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - ruby
6
+ - 2.1.1
7
+
8
+ script: 'bundle exec rake'
9
+
10
+ notifications:
11
+ email:
12
+ recipients:
13
+ - steven.magelowitz@gmail.com
14
+ on_failure: change
15
+ on_success: never
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in RubyGemsApi.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 stevepm
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
+ # RubyGemsApi
2
+
3
+ Easy access to the RubyGems API through a convenient ruby interface
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'RubyGemsApi'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install RubyGemsApi
18
+
19
+ ## Usage
20
+
21
+
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/stevepm/RubyGemsApi/fork )
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 a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require "bundler/gem_tasks"
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'RubyGemsApi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "RubyGemsApi"
8
+ spec.version = RubyGemsApi::VERSION
9
+ spec.authors = ["stevepm"]
10
+ spec.email = ["steven.magelowitz@gmail.com"]
11
+ spec.summary = %q{Easy access to the RubyGems API through a convenient ruby interface}
12
+ spec.description = %q{Easy access to the RubyGems API through a convenient ruby interface}
13
+ spec.homepage = "https://github.com/stevepm/rubygemsapi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "coveralls"
25
+ spec.add_development_dependency "jazz_hands"
26
+ spec.add_development_dependency "faraday"
27
+ spec.add_development_dependency "vcr"
28
+ spec.add_development_dependency "webmock"
29
+ end
@@ -0,0 +1,3 @@
1
+ module RubyGemsApi
2
+ VERSION = "0.0.1"
3
+ end
data/lib/ruby_gems.rb ADDED
@@ -0,0 +1,80 @@
1
+ require "RubyGemsApi/version"
2
+ require 'faraday'
3
+ require 'json'
4
+
5
+ class RubyGems
6
+ def initialize(gem_name)
7
+ @response = Faraday.get "https://rubygems.org/api/v1/gems/#{gem_name}.json"
8
+ @body = JSON.parse(@response.body)
9
+ end
10
+
11
+ def status
12
+ @response.status
13
+ end
14
+
15
+ def downloads
16
+ @body["downloads"]
17
+ end
18
+
19
+ def version
20
+ @body["version"]
21
+ end
22
+
23
+ def version_downloads
24
+ @body["version_downloads"]
25
+ end
26
+
27
+ def urls
28
+ url_hash = {}
29
+ if @body["bug_tracker_uri"]
30
+ url_hash[:bug_tracker_uri] = @body["bug_tracker_uri"]
31
+ end
32
+ if @body["documentation_uri"]
33
+ url_hash[:documentation_uri] = @body["documentation_uri"]
34
+ end
35
+ if @body["gem_uri"]
36
+ url_hash[:gem_uri] = @body["gem_uri"]
37
+ end
38
+ if @body["homepage_uri"]
39
+ url_hash[:homepage_uri] = @body["homepage_uri"]
40
+ end
41
+ if @body["mailing_list_uri"]
42
+ url_hash[:mailing_list_uri] = @body["mailing_list_uri"]
43
+ end
44
+ if @body["project_uri"]
45
+ url_hash[:project_uri] = @body["project_uri"]
46
+ end
47
+ if @body["source_code_uri"]
48
+ url_hash[:source_code_uri] = @body["source_code_uri"]
49
+ end
50
+ if @body["wiki_uri"]
51
+ url_hash[:wiki_uri] = @body["wiki_uri"]
52
+ end
53
+ url_hash
54
+ end
55
+
56
+ def description
57
+ @body["info"]
58
+ end
59
+
60
+ def dependencies
61
+ @body["dependencies"]
62
+ end
63
+
64
+ def licenses
65
+ @body["licenses"]
66
+ end
67
+
68
+ def authors
69
+ @body["authors"].split(",").map{|author| author.strip}
70
+ end
71
+
72
+ def name
73
+ @body["name"]
74
+ end
75
+
76
+ def platform
77
+ @body["platform"]
78
+ end
79
+
80
+ end
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://rubygems.org/api/v1/gems/faraday.json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - "*/*"
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - nginx
23
+ Date:
24
+ - Wed, 16 Jul 2014 03:52:46 GMT
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Connection:
30
+ - keep-alive
31
+ Status:
32
+ - 200 OK
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Ua-Compatible:
36
+ - IE=Edge,chrome=1
37
+ - IE=Edge,chrome=1
38
+ Cache-Control:
39
+ - max-age=0, private, must-revalidate
40
+ Set-Cookie:
41
+ - remember_token=; path=/; expires=Thu, 16-Jul-2015 03:52:46 GMT; secure
42
+ X-Request-Id:
43
+ - bbc30eb892a70e87b4dd51721c528905
44
+ X-Runtime:
45
+ - '0.016821'
46
+ X-Rack-Cache:
47
+ - miss
48
+ body:
49
+ encoding: UTF-8
50
+ string: '{"name":"faraday","downloads":9588400,"version":"0.9.0","version_downloads":1202947,"platform":"ruby","authors":"Rick
51
+ Olson","info":"HTTP/REST API client library.","licenses":["MIT"],"project_uri":"http://rubygems.org/gems/faraday","gem_uri":"http://rubygems.org/gems/faraday-0.9.0.gem","homepage_uri":"https://github.com/lostisland/faraday","wiki_uri":null,"documentation_uri":null,"mailing_list_uri":null,"source_code_uri":null,"bug_tracker_uri":null,"dependencies":{"development":[{"name":"bundler","requirements":"~>
52
+ 1.0"}],"runtime":[{"name":"multipart-post","requirements":"< 3, >= 1.2"}]}}'
53
+ http_version:
54
+ recorded_at: Wed, 16 Jul 2014 03:52:46 GMT
55
+ recorded_with: VCR 2.9.2
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe RubyGems do
4
+ before do
5
+ VCR.use_cassette('faraday') do
6
+ @faraday = RubyGems.new("faraday")
7
+ end
8
+ end
9
+ it 'can connect to the Ruby Gems API' do
10
+ expect(@faraday.status).to eq(200)
11
+ end
12
+
13
+ it 'can return the total downloads' do
14
+ expect(@faraday.downloads).to eq(9588400)
15
+ end
16
+
17
+ it 'can return the current version' do
18
+ expect(@faraday.version).to eq("0.9.0")
19
+ end
20
+
21
+ it 'can return version downloads' do
22
+ expect(@faraday.version_downloads).to eq(1202947)
23
+ end
24
+
25
+ it 'can return the urls in a hash' do
26
+ expect(@faraday.urls).to eq({
27
+ :gem_uri => "http://rubygems.org/gems/faraday-0.9.0.gem",
28
+ :homepage_uri => "https://github.com/lostisland/faraday",
29
+ :project_uri => "http://rubygems.org/gems/faraday"
30
+ })
31
+ end
32
+
33
+ it 'can return the description' do
34
+ expect(@faraday.description).to eq("HTTP/REST API client library.")
35
+ end
36
+
37
+ it 'can return dependencies' do
38
+ expect(@faraday.dependencies).to eq({"development" => [{"name" => "bundler", "requirements" => "~> 1.0"}], "runtime" => [{"name" => "multipart-post", "requirements" => "< 3, >= 1.2"}]})
39
+ end
40
+
41
+ it 'can return the licenses' do
42
+ expect(@faraday.licenses).to eq(["MIT"])
43
+ end
44
+
45
+ it 'can return the authors' do
46
+ expect(@faraday.authors).to eq(["Rick Olson"])
47
+ end
48
+
49
+ it 'can return the name' do
50
+ expect(@faraday.name).to eq("faraday")
51
+ end
52
+
53
+ it 'can return the platform' do
54
+ expect(@faraday.platform).to eq("ruby")
55
+ end
56
+ end
@@ -0,0 +1,87 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require 'ruby_gems'
4
+ require 'vcr'
5
+
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
9
+ # file to always be loaded, without a need to explicitly require it in any files.
10
+ #
11
+ # Given that it is always loaded, you are encouraged to keep this file as
12
+ # light-weight as possible. Requiring heavyweight dependencies from this file
13
+ # will add to the boot time of your test suite on EVERY test run, even for an
14
+ # individual file that may not need all of that loaded. Instead, make a
15
+ # separate helper file that requires this one and then use it only in the specs
16
+ # that actually need it.
17
+ #
18
+ # The `.rspec` file also contains a few flags that are not defaults but that
19
+ # users commonly want.
20
+ #
21
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
+ RSpec.configure do |config|
23
+ VCR.configure do |c|
24
+ c.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
25
+ c.hook_into :webmock # or :fakeweb
26
+ end
27
+ # The settings below are suggested to provide a good initial experience
28
+ # with RSpec, but feel free to customize to your heart's content.
29
+ =begin
30
+ # These two settings work together to allow you to limit a spec run
31
+ # to individual examples or groups you care about by tagging them with
32
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
33
+ # get run.
34
+ config.filter_run :focus
35
+ config.run_all_when_everything_filtered = true
36
+
37
+ # Many RSpec users commonly either run the entire suite or an individual
38
+ # file, and it's useful to allow more verbose output when running an
39
+ # individual spec file.
40
+ if config.files_to_run.one?
41
+ # Use the documentation formatter for detailed output,
42
+ # unless a formatter has already been configured
43
+ # (e.g. via a command-line flag).
44
+ config.default_formatter = 'doc'
45
+ end
46
+
47
+ # Print the 10 slowest examples and example groups at the
48
+ # end of the spec run, to help surface which specs are running
49
+ # particularly slow.
50
+ config.profile_examples = 10
51
+
52
+ # Run specs in random order to surface order dependencies. If you find an
53
+ # order dependency and want to debug it, you can fix the order by providing
54
+ # the seed, which is printed after each run.
55
+ # --seed 1234
56
+ config.order = :random
57
+
58
+ # Seed global randomization in this process using the `--seed` CLI option.
59
+ # Setting this allows you to use `--seed` to deterministically reproduce
60
+ # test failures related to randomization by passing the same `--seed` value
61
+ # as the one that triggered the failure.
62
+ Kernel.srand config.seed
63
+
64
+ # rspec-expectations config goes here. You can use an alternate
65
+ # assertion/expectation library such as wrong or the stdlib/minitest
66
+ # assertions if you prefer.
67
+ config.expect_with :rspec do |expectations|
68
+ # Enable only the newer, non-monkey-patching expect syntax.
69
+ # For more details, see:
70
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
71
+ expectations.syntax = :expect
72
+ end
73
+
74
+ # rspec-mocks config goes here. You can use an alternate test double
75
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
76
+ config.mock_with :rspec do |mocks|
77
+ # Enable only the newer, non-monkey-patching expect syntax.
78
+ # For more details, see:
79
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
80
+ mocks.syntax = :expect
81
+
82
+ # Prevents you from mocking or stubbing a method that does not exist on
83
+ # a real object. This is generally recommended.
84
+ mocks.verify_partial_doubles = true
85
+ end
86
+ =end
87
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: RubyGemsApi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - stevepm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
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: jazz_hands
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
+ - !ruby/object:Gem::Dependency
84
+ name: faraday
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Easy access to the RubyGems API through a convenient ruby interface
126
+ email:
127
+ - steven.magelowitz@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".coveralls.yml"
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - RubyGemsApi.gemspec
141
+ - lib/RubyGemsApi/version.rb
142
+ - lib/ruby_gems.rb
143
+ - spec/fixtures/vcr_cassettes/faraday.yml
144
+ - spec/rubygemsapi_spec.rb
145
+ - spec/spec_helper.rb
146
+ homepage: https://github.com/stevepm/rubygemsapi
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.2.2
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Easy access to the RubyGems API through a convenient ruby interface
170
+ test_files:
171
+ - spec/fixtures/vcr_cassettes/faraday.yml
172
+ - spec/rubygemsapi_spec.rb
173
+ - spec/spec_helper.rb
174
+ has_rdoc: