urlenc 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/Gemfile.lock +5 -31
- data/README.md +2 -0
- data/lib/urlenc.rb +26 -16
- data/lib/urlenc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfffff99bc8a56fc57aa3e1d75f613a5004b096c58141f94c6b8107fa17811d2
|
4
|
+
data.tar.gz: 2dc6fff375b905221cdfb99fb7ea7247852b82d645b85c1c2c980791dce3f3b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce55a1de798f77c9eab974ebb58496cf9b9927a92f811c2e21098038f8ff19dbcbe098b806b9f7fc375a3046667649c31e29a573cb106e585c8a5ebdd5b70b22
|
7
|
+
data.tar.gz: 8149897d8061ca04b617b5c845f4e163928e9fbe97d2e0804d6b6e439ca8eecbc9f2b2eb13c59b3a15def0d220ed9a7dd7d7aeb4c86f2539744567617ec8e975
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v1.0.1](https://github.com/shinyaohtani/urlenc/tree/v1.0.1) (2020-05-21)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/shinyaohtani/urlenc/compare/v1.0.0...v1.0.1)
|
6
|
+
|
7
|
+
- Encoding is default behavior without specify "-e or -d"
|
8
|
+
|
9
|
+
**Implemented enhancements:**
|
10
|
+
|
11
|
+
- Is it better to treat no params as "-e"? [\#3](https://github.com/shinyaohtani/urlenc/issues/3)
|
12
|
+
|
13
|
+
**Merged pull requests:**
|
14
|
+
|
15
|
+
- If no params are given, try encoding. [\#4](https://github.com/shinyaohtani/urlenc/pull/4) ([shinyaohtani](https://github.com/shinyaohtani))
|
16
|
+
|
17
|
+
# Changelog
|
18
|
+
|
3
19
|
## [v1.0.0](https://github.com/shinyaohtani/urlenc/tree/v1.0.0) (2020-05-20)
|
4
20
|
|
5
21
|
[Full Changelog](https://github.com/shinyaohtani/urlenc/compare/58edee48598a45d6b4cbb74c12058f99aa96f97c...v1.0.0)
|
@@ -8,4 +24,7 @@
|
|
8
24
|
|
9
25
|
|
10
26
|
|
27
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
28
|
+
|
29
|
+
|
11
30
|
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
urlenc (1.0.
|
4
|
+
urlenc (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -15,28 +15,9 @@ GEM
|
|
15
15
|
addressable (2.7.0)
|
16
16
|
public_suffix (>= 2.0.2, < 5.0)
|
17
17
|
ast (2.4.0)
|
18
|
-
async (1.26.1)
|
19
|
-
console (~> 1.0)
|
20
|
-
nio4r (~> 2.3)
|
21
|
-
timers (~> 4.1)
|
22
|
-
async-http (0.52.3)
|
23
|
-
async (~> 1.25)
|
24
|
-
async-io (~> 1.28)
|
25
|
-
async-pool (~> 0.2)
|
26
|
-
protocol-http (~> 0.20.0)
|
27
|
-
protocol-http1 (~> 0.13.0)
|
28
|
-
protocol-http2 (~> 0.14.0)
|
29
|
-
async-http-faraday (0.9.0)
|
30
|
-
async-http (~> 0.42)
|
31
|
-
faraday
|
32
|
-
async-io (1.29.0)
|
33
|
-
async (~> 1.14)
|
34
|
-
async-pool (0.3.2)
|
35
|
-
async (~> 1.25)
|
36
18
|
byebug (11.1.3)
|
37
19
|
coderay (1.1.2)
|
38
20
|
concurrent-ruby (1.1.6)
|
39
|
-
console (1.8.2)
|
40
21
|
diff-lcs (1.3)
|
41
22
|
faraday (1.0.1)
|
42
23
|
multipart-post (>= 1.2, < 3)
|
@@ -44,7 +25,6 @@ GEM
|
|
44
25
|
faraday (>= 0.8)
|
45
26
|
github_changelog_generator (1.15.2)
|
46
27
|
activesupport
|
47
|
-
async-http-faraday
|
48
28
|
faraday-http-cache
|
49
29
|
multi_json
|
50
30
|
octokit (~> 4.6)
|
@@ -57,20 +37,12 @@ GEM
|
|
57
37
|
minitest (5.14.1)
|
58
38
|
multi_json (1.14.1)
|
59
39
|
multipart-post (2.1.1)
|
60
|
-
nio4r (2.5.2)
|
61
40
|
octokit (4.18.0)
|
62
41
|
faraday (>= 0.9)
|
63
42
|
sawyer (~> 0.8.0, >= 0.5.3)
|
64
43
|
parallel (1.19.1)
|
65
44
|
parser (2.7.1.2)
|
66
45
|
ast (~> 2.4.0)
|
67
|
-
protocol-hpack (1.4.2)
|
68
|
-
protocol-http (0.20.0)
|
69
|
-
protocol-http1 (0.13.0)
|
70
|
-
protocol-http (~> 0.19)
|
71
|
-
protocol-http2 (0.14.0)
|
72
|
-
protocol-hpack (~> 1.4)
|
73
|
-
protocol-http (~> 0.18)
|
74
46
|
pry (0.13.1)
|
75
47
|
coderay (~> 1.1)
|
76
48
|
method_source (~> 1.0)
|
@@ -95,13 +67,16 @@ GEM
|
|
95
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
96
68
|
rspec-support (~> 3.9.0)
|
97
69
|
rspec-support (3.9.3)
|
98
|
-
rubocop (0.
|
70
|
+
rubocop (0.84.0)
|
99
71
|
parallel (~> 1.10)
|
100
72
|
parser (>= 2.7.0.1)
|
101
73
|
rainbow (>= 2.2.2, < 4.0)
|
102
74
|
rexml
|
75
|
+
rubocop-ast (>= 0.0.3)
|
103
76
|
ruby-progressbar (~> 1.7)
|
104
77
|
unicode-display_width (>= 1.4.0, < 2.0)
|
78
|
+
rubocop-ast (0.0.3)
|
79
|
+
parser (>= 2.7.0.1)
|
105
80
|
rubocop-performance (1.5.2)
|
106
81
|
rubocop (>= 0.71.0)
|
107
82
|
rubocop-rspec (1.39.0)
|
@@ -111,7 +86,6 @@ GEM
|
|
111
86
|
addressable (>= 2.3.5)
|
112
87
|
faraday (> 0.8, < 2.0)
|
113
88
|
thread_safe (0.3.6)
|
114
|
-
timers (4.3.0)
|
115
89
|
tzinfo (1.2.7)
|
116
90
|
thread_safe (~> 0.1)
|
117
91
|
unicode-display_width (1.7.0)
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/urlenc.svg)](https://badge.fury.io/rb/urlenc)
|
2
|
+
|
1
3
|
# Urlenc
|
2
4
|
|
3
5
|
The simplest way to URL encode / decode from STDIN. URL encoding is a generic name, more accurately called Percent-encoding. The URL encoding is by far the most well-known name, so we intentionally named this gem Urlenc.
|
data/lib/urlenc.rb
CHANGED
@@ -9,6 +9,20 @@ module Urlenc
|
|
9
9
|
require 'erb'
|
10
10
|
require 'optparse'
|
11
11
|
|
12
|
+
DESC_DECODE = <<~DECODE
|
13
|
+
Decode/unescape STDIN. %22Sample%20Text%21%22 will be
|
14
|
+
converted to "Sample Text!"
|
15
|
+
DECODE
|
16
|
+
DESC_ENCODE = <<~ENCODE
|
17
|
+
Encode/escape STDIN. "Sample Text!" will be converted
|
18
|
+
to %22Sample%20Text%21%22
|
19
|
+
*default: --encode
|
20
|
+
ENCODE
|
21
|
+
DESC_SPLIT = <<~SPLIT
|
22
|
+
Split before Encode/escape. http://sample Text!/ will
|
23
|
+
be converted to http://sample%20Text%21/
|
24
|
+
*default: --no-split
|
25
|
+
SPLIT
|
12
26
|
# Usage: urlenc [options]
|
13
27
|
# -d, --decode : Decode/unescape STDIN
|
14
28
|
# -e, --encode : Encode/escape STDIN
|
@@ -16,42 +30,38 @@ module Urlenc
|
|
16
30
|
attr_accessor :params
|
17
31
|
|
18
32
|
def initialize
|
19
|
-
@params = {}
|
33
|
+
@params = { encode: true }
|
20
34
|
end
|
21
35
|
|
22
36
|
def parse_options
|
23
37
|
OptionParser.new do |opts|
|
24
38
|
opts = define_options(opts)
|
25
39
|
opts.parse!(ARGV, into: @params)
|
26
|
-
if @params[:decode].nil?
|
27
|
-
puts opts.help
|
28
|
-
end
|
40
|
+
puts opts.help if @params[:decode].nil? && @params[:encode].nil?
|
29
41
|
end
|
30
42
|
end
|
31
43
|
|
32
44
|
def run
|
33
45
|
if @params[:decode]
|
34
46
|
STDIN.each { |line| puts CGI.unescape(line.chomp) }
|
35
|
-
elsif @params[:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
puts protocol + line.split('/', -1).map { |e| ERB::Util.url_encode(e) }.join('/')
|
40
|
-
end
|
41
|
-
else
|
42
|
-
STDIN.each { |line| puts ERB::Util.url_encode(line.chomp) }
|
47
|
+
elsif @params[:split]
|
48
|
+
STDIN.each do |line|
|
49
|
+
protocol = line.chomp!.slice!(%r{^.+://}) || ''
|
50
|
+
puts protocol + line.split('/', -1).map { |e| ERB::Util.url_encode(e) }.join('/')
|
43
51
|
end
|
52
|
+
else
|
53
|
+
STDIN.each { |line| puts ERB::Util.url_encode(line.chomp) }
|
44
54
|
end
|
45
55
|
end
|
46
56
|
|
47
|
-
def define_options(opts)
|
57
|
+
def define_options(opts) # rubocop:disable Metrics/AbcSize
|
48
58
|
opts.version = VERSION
|
49
59
|
opts.separator ' Required:'
|
50
|
-
opts.on('-d', '--decode',
|
51
|
-
opts.on('-e', '--encode',
|
60
|
+
opts.on('-d', '--decode', *DESC_DECODE.split(/\R/)) { |v| v }
|
61
|
+
opts.on('-e', '--encode', *DESC_ENCODE.split(/\R/)) { |v| v }
|
52
62
|
opts.separator ''
|
53
63
|
opts.separator ' Optional:'
|
54
|
-
opts.on('-s', '--split',
|
64
|
+
opts.on('-s', '--[no-]split', *DESC_SPLIT.split(/\R/)) { |v| v }
|
55
65
|
opts.separator ''
|
56
66
|
opts.separator ' Common options:'
|
57
67
|
opts.on_tail('-h', '--help', 'Show this message') do
|
data/lib/urlenc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: urlenc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinya Ohtani (shinyaohtani@github)
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|