gem-home 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +23 -0
- data/Rakefile +9 -0
- data/gem-home.gemspec +23 -0
- data/lib/rubygems/commands/docs_command.rb +15 -0
- data/lib/rubygems/commands/home_command.rb +15 -0
- data/lib/rubygems/commands/issues_command.rb +15 -0
- data/lib/rubygems/home/browser.rb +17 -0
- data/lib/rubygems/home/spec_loader.rb +69 -0
- data/lib/rubygems_plugin.rb +5 -0
- data/test/stubs/full_data.json +1 -0
- data/test/stubs/github_home.json +6 -0
- data/test/stubs/github_issues.json +6 -0
- data/test/stubs/no_data.json +3 -0
- data/test/test_helper.rb +5 -0
- data/test/test_spec_loader.rb +57 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 665486b62cff1fd7cb2bf5b07a53d010061ff940
|
4
|
+
data.tar.gz: a268b8d2c0d1ff8f815ac6760d2d6b781db0e571
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d160b81688a73cb441cd70814a626d087d3d2a266d207b244d2dfdb6bf03d76ab610bba7749d202485dabac6ed2898429fe5ab3f7cfcf1e3c2b1af53c9f5c0d7
|
7
|
+
data.tar.gz: c8e75b1f44b7215bbfcd63129d85f9a2b83415f872119b2b97ce9f0d46f313915cf297b9be84278dab8778ea769448542b4413108d53868b7459d2d9a1962172
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Ryan
|
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,23 @@
|
|
1
|
+
# Gem::Home
|
2
|
+
|
3
|
+
Ads some useful extensions to the default `gem` command
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install gem-home
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
```bash
|
12
|
+
gem home gem-name
|
13
|
+
gem issues gem-name
|
14
|
+
gem docs gem-name
|
15
|
+
```
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
1. Fork it ( https://github.com/[my-github-username]/gem-home/fork )
|
20
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
21
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
22
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
23
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/gem-home.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "gem-home"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Ryan"]
|
9
|
+
spec.email = ["ryan@mazondo.com"]
|
10
|
+
spec.summary = "Adds convenience methods to the gem command"
|
11
|
+
spec.description = "gem home `gem-name`, gem docs `gem-name`, gem issues `gem-name`"
|
12
|
+
spec.homepage = "https://github.com/mazondo/gem-home"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "webmock", "~> 1.20.4"
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Gem::Commands::DocsCommand < Gem::Command
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
super 'docs', "Open a gem's documentation"
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
require "rubygems/home/spec_loader"
|
9
|
+
require "rubygems/home/browser"
|
10
|
+
|
11
|
+
name = get_one_gem_name
|
12
|
+
link = ::Gem::Home::SpecLoader.get_docs_url(name)
|
13
|
+
::Gem::Home::Browser.open_link(link)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Gem::Commands::HomeCommand < Gem::Command
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
super 'home', "Open a gem's homepage"
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
require "rubygems/home/spec_loader"
|
9
|
+
require "rubygems/home/browser"
|
10
|
+
|
11
|
+
name = get_one_gem_name
|
12
|
+
link = ::Gem::Home::SpecLoader.get_home_url(name)
|
13
|
+
::Gem::Home::Browser.open_link(link)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Gem::Commands::IssuesCommand < Gem::Command
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
super 'issues', "Open a gem's issue tracker"
|
5
|
+
end
|
6
|
+
|
7
|
+
def execute
|
8
|
+
require "rubygems/home/spec_loader"
|
9
|
+
require "rubygems/home/browser"
|
10
|
+
|
11
|
+
name = get_one_gem_name
|
12
|
+
link = ::Gem::Home::SpecLoader.get_issues_url(name)
|
13
|
+
::Gem::Home::Browser.open_link(link)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Gem
|
2
|
+
module Home
|
3
|
+
module Browser
|
4
|
+
|
5
|
+
# open_url takes in a url, and attempts
|
6
|
+
# to open it in a browser using `git web--browse {{link}}`
|
7
|
+
def self.open_link(url)
|
8
|
+
unless system("git", "web--browse", url)
|
9
|
+
puts "Couldn't start Browser"
|
10
|
+
puts "But, you can do it yourself!"
|
11
|
+
puts link
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "json"
|
3
|
+
require "uri"
|
4
|
+
module Gem
|
5
|
+
module Home
|
6
|
+
module SpecLoader
|
7
|
+
def self.get_issues_url(gem)
|
8
|
+
data = pull_gemspec(gem)
|
9
|
+
link = data["bug_tracker_uri"]
|
10
|
+
return link if link && valid_url?(link)
|
11
|
+
# looks like nobody gave us an issue tracker
|
12
|
+
# are we working with a github link?
|
13
|
+
github_link = github_repo(data)
|
14
|
+
return [github_link, "issues"].join("/") if github_link
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.get_home_url(gem)
|
19
|
+
data = pull_gemspec(gem)
|
20
|
+
link = data["homepage_uri"]
|
21
|
+
return link if link && valid_url?(link)
|
22
|
+
# looks like nobody gave us a homepage
|
23
|
+
# are we working with a github link?
|
24
|
+
github_link = github_repo(data)
|
25
|
+
return github_link if github_link
|
26
|
+
|
27
|
+
# jeeze, not even a github repo.
|
28
|
+
# They don't deserve it, but we'll fall back to rubydocs
|
29
|
+
return "http://www.rubydoc.info/gems/#{gem}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.get_docs_url(gem)
|
33
|
+
data = pull_gemspec(gem)
|
34
|
+
link = data["documentation_uri"]
|
35
|
+
return link if link && valid_url?(link)
|
36
|
+
# looks like nobody gave us a documentation url
|
37
|
+
# let's send them to rubydocs
|
38
|
+
return "http://www.rubydoc.info/gems/#{gem}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.pull_gemspec(gem)
|
42
|
+
begin
|
43
|
+
result = open("http://rubygems.org/api/v1/gems/#{gem}.json").read
|
44
|
+
return JSON.parse(result)
|
45
|
+
rescue => e
|
46
|
+
puts "Error loading #{gem} gem's spec from rubygems.org"
|
47
|
+
puts e.message
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.valid_url?(url)
|
53
|
+
url =~ URI::regexp
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.github_repo(data)
|
57
|
+
possible = ["homepage_uri", "wiki_uri", "documentation_uri", "source_code_uri", "bug_tracker_uri"]
|
58
|
+
possible.each do |p|
|
59
|
+
link = data[p]
|
60
|
+
if link && link =~ /^(https{0,1}:\/\/)?(www\.)?github\.com/i
|
61
|
+
matches = link.match(/^(https{0,1}:\/\/)?(www\.)?github\.com\/([a-zA-Z]+)\/([a-zA-Z]+)/i)
|
62
|
+
return ["https://github.com", matches[3], matches[4]].join("/") if matches[3] && matches[4]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
return false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"name":"harpoon","downloads":650,"version":"0.0.4","version_downloads":309,"platform":"ruby","authors":"Ryan Quinn","info":"Deploy small server-less webapps to amazon s3, including buckets, dns and permissions","licenses":["MIT"],"project_uri":"http://rubygems.org/gems/harpoon","gem_uri":"http://rubygems.org/gems/harpoon-0.0.4.gem","homepage_uri":"http://www.getharpoon.com","wiki_uri":"","documentation_uri":"http://docs.getharpoon.com","mailing_list_uri":"","source_code_uri":"https://github.com/mazondo/harpoon","bug_tracker_uri":"https://getharpoon.com/issues","dependencies":{"development":[],"runtime":[{"name":"activesupport","requirements":"~\u003e 4.1.5"},{"name":"aws-sdk","requirements":"~\u003e 1.51.0"},{"name":"colorize","requirements":"~\u003e 0.7.3"},{"name":"netrc","requirements":"~\u003e 0.7.7"},{"name":"public_suffix","requirements":"~\u003e 1.4.5"},{"name":"thor","requirements":"~\u003e 0.19.1"}]}}
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe "Spec Loader" do
|
4
|
+
let(:spec) {::Gem::Home::SpecLoader}
|
5
|
+
|
6
|
+
before do
|
7
|
+
stub_request(:get, "http://rubygems.org/api/v1/gems/full-json.json").
|
8
|
+
to_return(:status => 200, :body => IO.read("test/stubs/full_data.json").strip)
|
9
|
+
stub_request(:get, "http://rubygems.org/api/v1/gems/github-homepage-json.json").
|
10
|
+
to_return(:status => 200, :body => IO.read("test/stubs/github_home.json").strip)
|
11
|
+
stub_request(:get, "http://rubygems.org/api/v1/gems/github-issues-json.json").
|
12
|
+
to_return(:status => 200, :body => IO.read("test/stubs/github_issues.json").strip)
|
13
|
+
stub_request(:get, "http://rubygems.org/api/v1/gems/no-data-json.json").
|
14
|
+
to_return(:status => 200, :body => IO.read("test/stubs/no_data.json").strip)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "issues" do
|
18
|
+
it "Should use gemspec issues path if present" do
|
19
|
+
link = spec.get_issues_url("full-json")
|
20
|
+
assert_equal "https://getharpoon.com/issues", link
|
21
|
+
end
|
22
|
+
|
23
|
+
it "Should fallback to github if possible" do
|
24
|
+
link = spec.get_issues_url("github-homepage-json")
|
25
|
+
assert_equal "https://github.com/mazondo/harpoon/issues", link
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "docs" do
|
30
|
+
it "Should use gemspec docs path if present" do
|
31
|
+
link = spec.get_docs_url("full-json")
|
32
|
+
assert_equal "http://docs.getharpoon.com", link
|
33
|
+
end
|
34
|
+
|
35
|
+
it "Should fallback to rubydocs if nothing else" do
|
36
|
+
link = spec.get_docs_url("github-homepage-json")
|
37
|
+
assert_equal "http://www.rubydoc.info/gems/github-homepage-json", link
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "home" do
|
42
|
+
it "Should use gemspec home path if present" do
|
43
|
+
link = spec.get_home_url("full-json")
|
44
|
+
assert_equal "http://www.getharpoon.com", link
|
45
|
+
end
|
46
|
+
|
47
|
+
it "Should fallback to github if possible" do
|
48
|
+
link = spec.get_home_url("github-issues-json")
|
49
|
+
assert_equal "https://github.com/mazondo/harpoon", link
|
50
|
+
end
|
51
|
+
|
52
|
+
it "Should fallback to rubydoc if nothing else" do
|
53
|
+
link = spec.get_docs_url("no-data-json")
|
54
|
+
assert_equal "http://www.rubydoc.info/gems/no-data-json", link
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem-home
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-03 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.20.4
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.20.4
|
55
|
+
description: gem home `gem-name`, gem docs `gem-name`, gem issues `gem-name`
|
56
|
+
email:
|
57
|
+
- ryan@mazondo.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- gem-home.gemspec
|
68
|
+
- lib/rubygems/commands/docs_command.rb
|
69
|
+
- lib/rubygems/commands/home_command.rb
|
70
|
+
- lib/rubygems/commands/issues_command.rb
|
71
|
+
- lib/rubygems/home/browser.rb
|
72
|
+
- lib/rubygems/home/spec_loader.rb
|
73
|
+
- lib/rubygems_plugin.rb
|
74
|
+
- test/stubs/full_data.json
|
75
|
+
- test/stubs/github_home.json
|
76
|
+
- test/stubs/github_issues.json
|
77
|
+
- test/stubs/no_data.json
|
78
|
+
- test/test_helper.rb
|
79
|
+
- test/test_spec_loader.rb
|
80
|
+
homepage: https://github.com/mazondo/gem-home
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.2.2
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Adds convenience methods to the gem command
|
104
|
+
test_files:
|
105
|
+
- test/stubs/full_data.json
|
106
|
+
- test/stubs/github_home.json
|
107
|
+
- test/stubs/github_issues.json
|
108
|
+
- test/stubs/no_data.json
|
109
|
+
- test/test_helper.rb
|
110
|
+
- test/test_spec_loader.rb
|