songle-song-uri-parser 1.1.0 → 1.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/songle/song_uri/invalid_song_uri_error.rb +2 -2
- data/lib/songle/song_uri/mp3_song_uri.rb +9 -9
- data/lib/songle/song_uri/nn_scheme_song_uri.rb +4 -4
- data/lib/songle/song_uri/nn_short_song_uri.rb +4 -4
- data/lib/songle/song_uri/nn_song_uri.rb +5 -5
- data/lib/songle/song_uri/numeric_song_uri.rb +3 -3
- data/lib/songle/song_uri/sc_scheme_song_uri.rb +4 -4
- data/lib/songle/song_uri/sc_song_uri.rb +5 -5
- data/lib/songle/song_uri/yt_scheme_song_uri.rb +4 -4
- data/lib/songle/song_uri/yt_short_song_uri.rb +4 -4
- data/lib/songle/song_uri/yt_song_uri.rb +5 -5
- data/lib/songle/song_uri.rb +26 -26
- data/lib/songle-song-uri-parser.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: ef82000ae2c1b5a995b0b6f65116d9fc7a19f0f57c3fc081e2e2b2c9aa1f6258
|
4
|
+
data.tar.gz: 0d0b079706f016d7ef9cab6d2b32f10836c802a3b4f3236e8381270e2deb9830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fc44fe2a80c7347d0fcd942b61ac28e3f73f8925ed3668848f92ab74e321a9363cee34264953c8a64bb49b8cc84a3294cae80f5d6a1058aa116866d52d70c3
|
7
|
+
data.tar.gz: e7a08557f770347183a4d00ce670c5c92a3ae2add48a00ab8f9e92b7454ace1feeee4e069f20158f86d95293a3cfe810d504772842110f32078a344daf11adf4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# CHANGELOG.md
|
2
2
|
|
3
|
+
## v1.1.1 (2019-01-26)
|
4
|
+
- Improved validation in constractor parameters
|
5
|
+
|
3
6
|
## v1.1.0 (2019-01-25)
|
4
7
|
- Changed return value of `Songle::SongURI#type` method (e.g. from "yt" to "youtube")
|
5
8
|
- Supported to the numeric format (e.g. "https://songle.jp/songs/12345")
|
data/Gemfile.lock
CHANGED
@@ -16,23 +16,23 @@ module ::Songle::SongURI
|
|
16
16
|
##
|
17
17
|
# @constructor
|
18
18
|
#
|
19
|
-
def initialize
|
20
|
-
super(
|
19
|
+
def initialize query, options
|
20
|
+
super(query, options)
|
21
21
|
|
22
|
-
if
|
23
|
-
|
22
|
+
if query =~ URI_REGEX
|
23
|
+
query = $3
|
24
24
|
end
|
25
25
|
|
26
|
-
if
|
27
|
-
|
26
|
+
if query =~ /^#{ self.endpoint_host }(.+)$/
|
27
|
+
query = $1
|
28
28
|
end
|
29
29
|
|
30
|
-
if
|
31
|
-
|
30
|
+
if query =~ /^#{ self.endpoint_path }(.+)$/
|
31
|
+
query = $1
|
32
32
|
end
|
33
33
|
|
34
34
|
source_uri =
|
35
|
-
::URI.parse("//#{
|
35
|
+
::URI.parse("//#{ query }")
|
36
36
|
|
37
37
|
@source_host = source_uri.host
|
38
38
|
@source_path = source_uri.path
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
33
|
@source_path = SOURCE_PATH
|
34
|
-
@source_id = $1 if
|
34
|
+
@source_id = $1 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
|
40
40
|
@source_path += @source_id
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
33
|
@source_path = SOURCE_PATH
|
34
|
-
@source_id = $1 if
|
34
|
+
@source_id = $1 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
|
40
40
|
@source_path += @source_id
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
|
-
@source_path = $1 if
|
34
|
-
@source_id = $2 if
|
33
|
+
@source_path = $1 if query =~ URI_REGEX
|
34
|
+
@source_id = $2 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -16,12 +16,12 @@ module ::Songle::SongURI
|
|
16
16
|
##
|
17
17
|
# @constructor
|
18
18
|
#
|
19
|
-
def initialize
|
20
|
-
super(
|
19
|
+
def initialize query, options
|
20
|
+
super(query, options)
|
21
21
|
|
22
22
|
@source_host = nil
|
23
23
|
@source_path = nil
|
24
|
-
@source_id = $3 if
|
24
|
+
@source_id = $3 if query =~ URI_REGEX
|
25
25
|
end
|
26
26
|
|
27
27
|
##
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
33
|
@source_path = SOURCE_PATH
|
34
|
-
@source_id = $1 if
|
34
|
+
@source_id = $1 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
|
40
40
|
@source_path += @source_id
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
|
-
@source_path = $1 if
|
34
|
-
@source_id = $2 if
|
33
|
+
@source_path = $1 if query =~ URI_REGEX
|
34
|
+
@source_id = $2 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
33
|
@source_path = SOURCE_PATH
|
34
|
-
@source_id = $1 if
|
34
|
+
@source_id = $1 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
|
40
40
|
@source_path += @source_id
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
33
|
@source_path = SOURCE_PATH
|
34
|
-
@source_id = $1 if
|
34
|
+
@source_id = $1 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
|
40
40
|
@source_path += @source_id
|
@@ -26,15 +26,15 @@ module ::Songle::SongURI
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
30
|
-
super(
|
29
|
+
def initialize query, options
|
30
|
+
super(query, options)
|
31
31
|
|
32
32
|
@source_host = SOURCE_HOST
|
33
|
-
@source_path = $1 if
|
34
|
-
@source_id = $2 if
|
33
|
+
@source_path = $1 if query =~ URI_REGEX
|
34
|
+
@source_id = $2 if query =~ URI_REGEX
|
35
35
|
|
36
36
|
if @source_id.nil? || @source_id.strip.empty?
|
37
|
-
raise ::Songle::SongURI::InvalidSongURIError.new(
|
37
|
+
raise ::Songle::SongURI::InvalidSongURIError.new(query)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/lib/songle/song_uri.rb
CHANGED
@@ -26,17 +26,17 @@ module ::Songle
|
|
26
26
|
##
|
27
27
|
# @constructor
|
28
28
|
#
|
29
|
-
def initialize
|
29
|
+
def initialize query, options = nil
|
30
30
|
options ||= {}
|
31
31
|
|
32
32
|
@endpoint_scheme =
|
33
|
-
options[ :endpoint_scheme ] || ENDPOINT_SCHEME
|
33
|
+
(options[ :endpoint_scheme ] || "").strip != "" ? options[ :endpoint_scheme ].strip : ENDPOINT_SCHEME
|
34
34
|
|
35
35
|
@endpoint_host =
|
36
|
-
options[ :endpoint_host ] || ENDPOINT_HOST
|
36
|
+
(options[ :endpoint_host ] || "").strip != "" ? options[ :endpoint_host ].strip : ENDPOINT_HOST
|
37
37
|
|
38
38
|
@endpoint_path =
|
39
|
-
options[ :endpoint_path ] || ENDPOINT_PATH
|
39
|
+
(options[ :endpoint_path ] || "").strip != "" ? options[ :endpoint_path ].strip : ENDPOINT_PATH
|
40
40
|
end
|
41
41
|
|
42
42
|
##
|
@@ -78,31 +78,31 @@ module ::Songle
|
|
78
78
|
# @method
|
79
79
|
# @static
|
80
80
|
#
|
81
|
-
def parse
|
82
|
-
|
83
|
-
::URI.decode_www_form_component(
|
81
|
+
def parse query, options = nil
|
82
|
+
query =
|
83
|
+
::URI.decode_www_form_component(query.to_s)
|
84
84
|
|
85
85
|
case
|
86
|
-
when
|
87
|
-
return ::Songle::SongURI::NnSongURI.new(
|
88
|
-
when
|
89
|
-
return ::Songle::SongURI::NnSchemeSongURI.new(
|
90
|
-
when
|
91
|
-
return ::Songle::SongURI::NnShortSongURI.new(
|
92
|
-
when
|
93
|
-
return ::Songle::SongURI::ScSongURI.new(
|
94
|
-
when
|
95
|
-
return ::Songle::SongURI::ScSchemeSongURI.new(
|
96
|
-
when
|
97
|
-
return ::Songle::SongURI::YtSongURI.new(
|
98
|
-
when
|
99
|
-
return ::Songle::SongURI::YtSchemeSongURI.new(
|
100
|
-
when
|
101
|
-
return ::Songle::SongURI::YtShortSongURI.new(
|
102
|
-
when
|
103
|
-
return ::Songle::SongURI::NumericSongURI.new(
|
86
|
+
when query =~ ::Songle::SongURI::NnSongURI::URI_REGEX
|
87
|
+
return ::Songle::SongURI::NnSongURI.new(query, options)
|
88
|
+
when query =~ ::Songle::SongURI::NnSchemeSongURI::URI_REGEX
|
89
|
+
return ::Songle::SongURI::NnSchemeSongURI.new(query, options)
|
90
|
+
when query =~ ::Songle::SongURI::NnShortSongURI::URI_REGEX
|
91
|
+
return ::Songle::SongURI::NnShortSongURI.new(query, options)
|
92
|
+
when query =~ ::Songle::SongURI::ScSongURI::URI_REGEX
|
93
|
+
return ::Songle::SongURI::ScSongURI.new(query, options)
|
94
|
+
when query =~ ::Songle::SongURI::ScSchemeSongURI::URI_REGEX
|
95
|
+
return ::Songle::SongURI::ScSchemeSongURI.new(query, options)
|
96
|
+
when query =~ ::Songle::SongURI::YtSongURI::URI_REGEX
|
97
|
+
return ::Songle::SongURI::YtSongURI.new(query, options)
|
98
|
+
when query =~ ::Songle::SongURI::YtSchemeSongURI::URI_REGEX
|
99
|
+
return ::Songle::SongURI::YtSchemeSongURI.new(query, options)
|
100
|
+
when query =~ ::Songle::SongURI::YtShortSongURI::URI_REGEX
|
101
|
+
return ::Songle::SongURI::YtShortSongURI.new(query, options)
|
102
|
+
when query =~ ::Songle::SongURI::NumericSongURI::URI_REGEX
|
103
|
+
return ::Songle::SongURI::NumericSongURI.new(query, options)
|
104
104
|
else
|
105
|
-
return ::Songle::SongURI::Mp3SongURI.new(
|
105
|
+
return ::Songle::SongURI::Mp3SongURI.new(query, options)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: songle-song-uri-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takahiro INOUE
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|