github-urifreezer 0.0.1.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fbee371db75eb8ae33064dd7e1773a0e4262b78f
4
- data.tar.gz: 23a160bb11a7c17a6f0c09e26f3ee38ef72a7e12
2
+ SHA256:
3
+ metadata.gz: 8e9ab1e02f5f939f456dba5805e5c0335ab4891ab602e97985a253d1b02e01fc
4
+ data.tar.gz: '008a911797dd526ace34744a4e82b04d53fa525420832b0515405638e544b75c'
5
5
  SHA512:
6
- metadata.gz: b8f56c6901aaaf923c47d4dac24cc25faf9627983031e1a3fad68182f0f4b8bb38f5cff884754369f3f470d68c8af1ff8116e3bcd574add7fb17f36f8d49774d
7
- data.tar.gz: aea11880b18e176311e55aaf7f4f30c0dbd02ae00219fc1a8b97fe4fb00227238a944ce33808b4909ec60be855ac831a681332379c16768f0a46a36fb1b1d77e
6
+ metadata.gz: ab8f188bb4e3c35a73bc353c9c182bc0b62bd4683a11de6a27e120f8973614e8a015ee5d1b366a9269be5b41e471ec76768aaade622839aa02c3a23880f3695c
7
+ data.tar.gz: 197a98ac3dc617c030c4217f4861bee6a03ac3e2ccb68afdce7030cb365cc384095064378f311a8582d0646e38b0df3807bb2d6c3b6d6796d6f35a05630e6a37
File without changes
data/README.md CHANGED
@@ -1,40 +1,23 @@
1
- Github URI Freezer
1
+ GitHub URI Freezer
2
2
  =======================
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/kachick/github-urifreezer.png)](http://travis-ci.org/kachick/github-urifreezer)
4
+ ![Build Status](https://github.com/kachick/github-urifreezer/actions/workflows/test_behaviors.yml/badge.svg?branch=main)
5
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
6
 
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.
7
+ Getting GitHub permanent links to files
14
8
 
15
9
  Usage
16
10
  -----
17
11
 
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
- -------
12
+ Require Ruby 2.6 or later
30
13
 
31
- ```shell
14
+ ```console
32
15
  $ gem install github-urifreezer
16
+ $ ghuf.rb 'https://github.com/rails/rails/blob/v5.2.6/activesupport/lib/active_support.rb#L33'
17
+ https://github.com/rails/rails/blob/48661542a2607d55f436438fe21001d262e61fec/activesupport/lib/active_support.rb#L33
33
18
  ```
34
19
 
35
- License
36
- --------
20
+ NOTE
21
+ ---
37
22
 
38
- The MIT X11 License
39
- Copyright (c) 2015 Kenichi Kamiya
40
- See MIT-LICENSE for further details.
23
+ * [GitHub has been provided `y` option for browser access](https://docs.github.com/en/github/managing-files-in-a-repository/managing-files-on-github/getting-permanent-links-to-files)
@@ -1,14 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
  # coding: us-ascii
3
+ # frozen_string_literal: true
3
4
 
5
+ require 'bundler/setup'
4
6
  require 'thor'
5
7
  require_relative '../lib/github/urifreezer'
6
8
 
7
9
  class GhUF < Thor
8
10
  desc 'based-URI', 'Print the fixed URI under latest commit of the branch'
9
11
  def fix(uri)
10
- puts Github::URIFreezer.fix(uri)
12
+ puts GitHub::URIFreezer.fix(uri)
11
13
  end
12
14
  end
13
15
 
14
- GhUF.start ['fix', *ARGV]
16
+ GhUF.start(['fix', *ARGV])
@@ -1,4 +1,6 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
3
+
2
4
  # Copyright (c) 2015 Kenichi Kamiya
3
5
 
4
6
  require 'uri'
@@ -6,7 +8,7 @@ require 'open-uri'
6
8
  require 'json'
7
9
  require_relative 'urifreezer/version'
8
10
 
9
- module Github
11
+ module GitHub
10
12
  module URIFreezer
11
13
  class << self
12
14
  # @param uri [String, URI]
@@ -18,12 +20,12 @@ module Github
18
20
  def fix(uri)
19
21
  uri = uri.kind_of?(URI) ? uri : URI.parse(uri)
20
22
  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
23
+ # GitHub API v3
24
+ api_res = URI.open("https://api.github.com/repos/#{user_pj}/commits/#{branch}")
25
+ api = JSON.parse(api_res.read, symbolize_names: true)
26
+ URI::HTTPS.new(uri.scheme, nil, uri.host, nil, nil, [nil, user_blob, api.fetch(:sha), suffix].join('/'), nil, nil, uri.fragment, true)
25
27
  else
26
- raise "given an unexpexted URI: #{uri}"
28
+ raise "given an unexpected URI: #{uri}"
27
29
  end
28
30
  end
29
31
  end
@@ -1,7 +1,8 @@
1
1
  # coding: us-ascii
2
+ # frozen_string_literal: true
2
3
 
3
- module Github
4
+ module GitHub
4
5
  module URIFreezer
5
- VERSION = '0.0.1'.freeze
6
+ VERSION = '0.0.2'
6
7
  end
7
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: github-urifreezer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Kamiya
8
- autorequire:
9
- bindir: bin
8
+ autorequire:
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-22 00:00:00.000000000 Z
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -16,129 +16,38 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.19'
19
+ version: 1.1.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '0.20'
22
+ version: 1.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.19'
29
+ version: 1.1.0
30
30
  - - "<"
31
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.
32
+ version: 1.2.0
33
+ description: Getting GitHub permanent links to files
117
34
  email:
118
35
  - kachick1+ruby@gmail.com
119
36
  executables:
120
- - ghuf
37
+ - ghuf.rb
121
38
  extensions: []
122
39
  extra_rdoc_files: []
123
40
  files:
124
- - ".gitignore"
125
- - ".travis.yml"
126
- - ".yardopts"
127
- - Gemfile
128
- - MIT-LICENSE
41
+ - MIT-LICENSE.txt
129
42
  - README.md
130
- - Rakefile
131
- - bin/ghuf
132
- - github-urifreezer.gemspec
43
+ - exe/ghuf.rb
133
44
  - lib/github/urifreezer.rb
134
45
  - lib/github/urifreezer/version.rb
135
- - spec/github-urifreezer_spec.rb
136
- - spec/spec_helper.rb
137
46
  homepage: https://github.com/kachick/github-urifreezer
138
47
  licenses:
139
48
  - MIT
140
49
  metadata: {}
141
- post_install_message:
50
+ post_install_message:
142
51
  rdoc_options: []
143
52
  require_paths:
144
53
  - lib
@@ -146,21 +55,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
55
  requirements:
147
56
  - - ">="
148
57
  - !ruby/object:Gem::Version
149
- version: '2.2'
58
+ version: '2.6'
150
59
  required_rubygems_version: !ruby/object:Gem::Requirement
151
60
  requirements:
152
61
  - - ">="
153
62
  - !ruby/object:Gem::Version
154
63
  version: '0'
155
64
  requirements: []
156
- rubyforge_project:
157
- rubygems_version: 2.4.8
158
- signing_key:
65
+ rubygems_version: 3.2.15
66
+ signing_key:
159
67
  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:
68
+ summary: Getting GitHub permanent links to files
69
+ test_files: []
data/.gitignore DELETED
@@ -1,38 +0,0 @@
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
- *\#*
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
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
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --readme README.md lib/**/*.rb
data/Gemfile DELETED
@@ -1,11 +0,0 @@
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
data/Rakefile DELETED
@@ -1,11 +0,0 @@
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
@@ -1,33 +0,0 @@
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
@@ -1,15 +0,0 @@
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
data/spec/spec_helper.rb DELETED
@@ -1,5 +0,0 @@
1
- # coding: us-ascii
2
-
3
- require 'rspec'
4
-
5
- require_relative '../lib/github/urifreezer'