github-urifreezer 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fbee371db75eb8ae33064dd7e1773a0e4262b78f
4
+ data.tar.gz: 23a160bb11a7c17a6f0c09e26f3ee38ef72a7e12
5
+ SHA512:
6
+ metadata.gz: b8f56c6901aaaf923c47d4dac24cc25faf9627983031e1a3fad68182f0f4b8bb38f5cff884754369f3f470d68c8af1ff8116e3bcd574add7fb17f36f8d49774d
7
+ data.tar.gz: aea11880b18e176311e55aaf7f4f30c0dbd02ae00219fc1a8b97fe4fb00227238a944ce33808b4909ec60be855ac831a681332379c16768f0a46a36fb1b1d77e
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .DS_Store
6
+ .ruby-version
7
+ coverage
8
+ coverage.data
9
+ InstalledFiles
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+
18
+ # bundler
19
+ vendor/
20
+
21
+ # YARD artifacts
22
+ .yardoc
23
+ _yardoc
24
+ doc/
25
+
26
+ # tmp-old
27
+ .old
28
+
29
+ # editor
30
+ *~
31
+ .redcar
32
+
33
+ # other
34
+ *.lock
35
+ *.bak
36
+ tool/
37
+ .rbx/
38
+ *\#*
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+
3
+ branches:
4
+ only:
5
+ - master
6
+
7
+ rvm:
8
+ - 2.2.3
9
+ - ruby-head
10
+ - rbx-2
11
+ - jruby-head
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: rbx-2
17
+ - rvm: jruby-head
18
+
19
+ before_install:
20
+ - gem install bundler
@@ -0,0 +1 @@
1
+ --readme README.md lib/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rake'
11
+ end
@@ -0,0 +1,22 @@
1
+ (The MIT X11 License)
2
+
3
+ Copyright (c) 2015 Kenichi Kamiya
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ Github URI Freezer
2
+ =======================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/kachick/github-urifreezer.png)](http://travis-ci.org/kachick/github-urifreezer)
5
+ [![Gem Version](https://badge.fury.io/rb/github-urifreezer.png)](http://badge.fury.io/rb/github-urifreezer)
6
+ [![Dependency Status](https://gemnasium.com/kachick/github-urifreezer.svg)](https://gemnasium.com/kachick/github-urifreezer)
7
+
8
+ Description
9
+ -----------
10
+
11
+ Github referenced URI(branch/path#Ln-Lm) is very useful to communicate.
12
+ But they are temporary and unsteady, newer commits modify the meanings.
13
+ This script replaces them with other URI that based to latest-commit of the branch.
14
+
15
+ Usage
16
+ -----
17
+
18
+ ```shell
19
+ $ ghuf https://github.com/user/pj/blob/branch/path#Ln-Lm
20
+ #=> https://github.com/user/pj/blob/LATEST-COMMIT-OF-THE-BRANCH/path#Ln-Lm
21
+ ```
22
+
23
+ Requirements
24
+ -------------
25
+
26
+ * Ruby - [2.2 or later](http://travis-ci.org/#!/kachick/github-urifreezer)
27
+
28
+ Install
29
+ -------
30
+
31
+ ```shell
32
+ $ gem install github-urifreezer
33
+ ```
34
+
35
+ License
36
+ --------
37
+
38
+ The MIT X11 License
39
+ Copyright (c) 2015 Kenichi Kamiya
40
+ See MIT-LICENSE for further details.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: [:spec]
7
+
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.ruby_opts = %w[-w]
11
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: us-ascii
3
+
4
+ require 'thor'
5
+ require_relative '../lib/github/urifreezer'
6
+
7
+ class GhUF < Thor
8
+ desc 'based-URI', 'Print the fixed URI under latest commit of the branch'
9
+ def fix(uri)
10
+ puts Github::URIFreezer.fix(uri)
11
+ end
12
+ end
13
+
14
+ GhUF.start ['fix', *ARGV]
@@ -0,0 +1,33 @@
1
+ require './lib/github/urifreezer/version'
2
+
3
+ Gem::Specification.new do |gem|
4
+ # specific
5
+
6
+ gem.description = %q{Github referenced URI(branch/path#Ln-Lm) is very useful to communicate.
7
+ But they are temporary and unsteady, newer commits modify the meanings.
8
+ This script replaces them with other URI that based to latest-commit of the branch.}
9
+
10
+ gem.summary = gem.description.dup
11
+ gem.homepage = 'https://github.com/kachick/github-urifreezer'
12
+ gem.license = 'MIT'
13
+ gem.name = 'github-urifreezer'
14
+ gem.version = '0.0.1.1'
15
+
16
+ gem.required_ruby_version = '>= 2.2'
17
+
18
+ gem.add_runtime_dependency 'thor', '>= 0.19', '< 0.20'
19
+
20
+ gem.add_development_dependency 'rspec', '>= 3.3', '< 4'
21
+ gem.add_development_dependency 'yard', '>= 0.8.7.6', '< 0.9'
22
+ gem.add_development_dependency 'rake', '>= 10', '< 20'
23
+ gem.add_development_dependency 'bundler', '>= 1.10', '< 2'
24
+
25
+ # common
26
+
27
+ gem.authors = ['Kenichi Kamiya']
28
+ gem.email = ['kachick1+ruby@gmail.com']
29
+ gem.files = `git ls-files`.split($\)
30
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
31
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
32
+ gem.require_paths = ['lib']
33
+ end
@@ -0,0 +1,31 @@
1
+ # coding: us-ascii
2
+ # Copyright (c) 2015 Kenichi Kamiya
3
+
4
+ require 'uri'
5
+ require 'open-uri'
6
+ require 'json'
7
+ require_relative 'urifreezer/version'
8
+
9
+ module Github
10
+ module URIFreezer
11
+ class << self
12
+ # @param uri [String, URI]
13
+ # @return [URI]
14
+ # @example
15
+ # When a referenced URI is "https://github.com/kachick/striuct/blob/gh-pages/yard/file.MIT-LICENSE.html#L6-L11"
16
+ # Then the frozen URI will be "https://github.com/kachick/striuct/blob/0e089fe7f97c444a4c5ba3a571d300078b87d17e/yard/file.MIT-LICENSE.html#L6-L11"
17
+ #
18
+ def fix(uri)
19
+ uri = uri.kind_of?(URI) ? uri : URI.parse(uri)
20
+ if %r!\A/(?<user_blob>(?<user_pj>[^/]+/[^/]+)/blob)/(?<branch>[^/]+)/?(?<suffix>.*)! =~ uri.path
21
+ # Github API v3
22
+ api_res = open "https://api.github.com/repos/#{user_pj}/commits/#{branch}"
23
+ api = JSON.parse api_res.read, symbolize_names: true
24
+ URI::HTTPS.new uri.scheme, nil, uri.host, nil, nil, [nil, user_blob, api.fetch(:sha), suffix].join('/'), nil, nil, uri.fragment, true
25
+ else
26
+ raise "given an unexpexted URI: #{uri}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ # coding: us-ascii
2
+
3
+ module Github
4
+ module URIFreezer
5
+ VERSION = '0.0.1'.freeze
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # coding: us-ascii
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ describe Github::URIFreezer do
6
+ before :each do
7
+ @target = 'https://github.com/kachick/striuct/blob/gh-pages/yard/file.MIT-LICENSE.html#L6-L11'
8
+ @result = URI.parse 'https://github.com/kachick/striuct/blob/0e089fe7f97c444a4c5ba3a571d300078b87d17e/yard/file.MIT-LICENSE.html#L6-L11'
9
+ end
10
+
11
+ describe '.fix' do
12
+ it { expect(Github::URIFreezer.fix @target).to eq(@result) }
13
+ it { expect(Github::URIFreezer.fix URI.parse(@target)).to eq(@result) }
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # coding: us-ascii
2
+
3
+ require 'rspec'
4
+
5
+ require_relative '../lib/github/urifreezer'
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: github-urifreezer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Kenichi Kamiya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.20'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.19'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.20'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.3'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '3.3'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
53
+ - !ruby/object:Gem::Dependency
54
+ name: yard
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.8.7.6
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.9'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 0.8.7.6
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.9'
73
+ - !ruby/object:Gem::Dependency
74
+ name: rake
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '10'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '20'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '10'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '20'
93
+ - !ruby/object:Gem::Dependency
94
+ name: bundler
95
+ requirement: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '1.10'
100
+ - - "<"
101
+ - !ruby/object:Gem::Version
102
+ version: '2'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '1.10'
110
+ - - "<"
111
+ - !ruby/object:Gem::Version
112
+ version: '2'
113
+ description: |-
114
+ Github referenced URI(branch/path#Ln-Lm) is very useful to communicate.
115
+ But they are temporary and unsteady, newer commits modify the meanings.
116
+ This script replaces them with other URI that based to latest-commit of the branch.
117
+ email:
118
+ - kachick1+ruby@gmail.com
119
+ executables:
120
+ - ghuf
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".gitignore"
125
+ - ".travis.yml"
126
+ - ".yardopts"
127
+ - Gemfile
128
+ - MIT-LICENSE
129
+ - README.md
130
+ - Rakefile
131
+ - bin/ghuf
132
+ - github-urifreezer.gemspec
133
+ - lib/github/urifreezer.rb
134
+ - lib/github/urifreezer/version.rb
135
+ - spec/github-urifreezer_spec.rb
136
+ - spec/spec_helper.rb
137
+ homepage: https://github.com/kachick/github-urifreezer
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '2.2'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.4.8
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Github referenced URI(branch/path#Ln-Lm) is very useful to communicate. But
161
+ they are temporary and unsteady, newer commits modify the meanings. This script
162
+ replaces them with other URI that based to latest-commit of the branch.
163
+ test_files:
164
+ - spec/github-urifreezer_spec.rb
165
+ - spec/spec_helper.rb
166
+ has_rdoc: