knowyourgems 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5d4ea6a3b933792fcb50b11f5721e3e8bc50e66
4
- data.tar.gz: d734395a2e4617138782d1e21650b858f7b2c958
3
+ metadata.gz: c100c179bdf44a207a835cb8c16f0c5c2b1cf95e
4
+ data.tar.gz: 22180e6cba04de91615a76012d5ed9130cad39c9
5
5
  SHA512:
6
- metadata.gz: eaac219fd72ad0b760a3fe8efbf2363ae0185176ea3f929dc4e3f3b632b01eb831fdd84692003ac17709c70e968fa63da5373a6609dc4fa0754b311b1e1e20e3
7
- data.tar.gz: ee1d15890bd5811bcae0d6396c7dd2e0b4c2121bd90dde675d2ec90669d9991a37d3f9b953544109c0536195c6f1cff2661ff5e2580ba800d889c03f79a758f4
6
+ metadata.gz: 956f68596605951bb86abe8d0f03daa3b43085211eb40d5f9f536a28f5ec0b5612d785ab9659436aeefc6231651b7d6d075eef778ac2b8e11d8e02f6dedf8727
7
+ data.tar.gz: bf396964ce8392e4100019f19782e6cd1c5502291b0c0c309d8755ca14816452c44b73db72e697e81f0b6044f94db397a2b318b7f9b2bac1c495acd5acc6e55b
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in knowyourgems.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Karan Arora
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Knowyourgems
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/knowyourgems`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'knowyourgems'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install knowyourgems
22
+
23
+ ## Usage
24
+
25
+ 1) Lists all the gems you own, just provide your rubygems handle
26
+
27
+ Knowyourgems.name_of_your_gems “karanarora"
28
+
29
+ ==> ["hash_multi_tool", "knowyourgems"]
30
+
31
+ 2) Lists no. of gems you own, just provide your rubygems handle
32
+
33
+ Knowyourgems.your_total_gems “karanarora"
34
+
35
+ ==> 2
36
+
37
+ 3) Find when you updated your last gem:
38
+
39
+ Knowyourgems.last_updated "hash_multi_tool"
40
+
41
+ ==> "2 days"
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ 1. Fork it ( https://github.com/karanarora/knowyourgems/fork )
52
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 4. Push to the branch (`git push origin my-new-feature`)
55
+ 5. Create a new Pull Request
56
+
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "knowyourgems"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
Binary file
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'knowyourgems/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "knowyourgems"
8
+ spec.version = Knowyourgems::VERSION
9
+ spec.authors = ["Karan Arora"]
10
+ spec.email = ["mail@arorakaran.com"]
11
+
12
+ spec.summary = %q{This gem helps you find out the history/details of gems you have written.}
13
+ spec.description = %q{This gem helps you find out the history/details of gems you have written.}
14
+ spec.homepage = "https://github.com/karanarora/knowyourgems/"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+ end
@@ -0,0 +1,3 @@
1
+ module Knowyourgems
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,74 @@
1
+ require "knowyourgems/version"
2
+ require "net/http"
3
+ require 'json'
4
+ require 'time'
5
+
6
+ module Knowyourgems
7
+ class << self
8
+ def name_of_your_gems user_handle
9
+ response, valid = gems_api_common user_handle
10
+ if valid
11
+ response.collect!{|r| r['name']}
12
+ else
13
+ response
14
+ end
15
+ end
16
+
17
+ def your_total_gems user_handle
18
+ response, valid = gems_api_common user_handle
19
+ if valid
20
+ response.count
21
+ else
22
+ response
23
+ end
24
+ end
25
+
26
+ def http_response service
27
+ uri = URI(service)
28
+ response = Net::HTTP.get_response(uri)
29
+ end
30
+
31
+ def gems_api_common user_handle
32
+ url = gem_api user_handle
33
+ response = http_response url
34
+ response, valid = valid_response? response
35
+ return response,valid
36
+ end
37
+
38
+ def last_updated gem
39
+ url = versions_api gem
40
+ response = http_response url
41
+ response, valid = valid_response? response
42
+ if valid
43
+ ((DateTime.now - DateTime.parse(response.first['built_at'])).to_i).to_s + ' days'
44
+ else
45
+ response
46
+ end
47
+ end
48
+
49
+ def gem_api user_handle
50
+ "https://rubygems.org/api/v1/owners/#{user_handle}/gems.json"
51
+ end
52
+
53
+ def versions_api gem
54
+ "https://rubygems.org/api/v1/versions/#{gem}.json"
55
+ end
56
+
57
+ def valid_response? response
58
+ case response
59
+ when Net::HTTPSuccess || Net::HTTPOK
60
+ return (JSON.parse response.body), true
61
+ when Net::HTTPNotFound
62
+ {'error' => "#{response.message}: Invalid user handle"}
63
+ when Net::HTTPUnauthorized
64
+ {'error' => "#{response.message}: username and password set and correct?"}
65
+ when Net::HTTPServerError
66
+ {'error' => "#{response.message}: try again later?"}
67
+ else
68
+ {'error' => response.message}
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knowyourgems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karan Arora
@@ -58,7 +58,21 @@ email:
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
- files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - knowyourgems-0.1.0.gem
73
+ - knowyourgems.gemspec
74
+ - lib/knowyourgems.rb
75
+ - lib/knowyourgems/version.rb
62
76
  homepage: https://github.com/karanarora/knowyourgems/
63
77
  licenses:
64
78
  - MIT