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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51439885a41518b7959c19cae4bc9c32cd9efe73e29418210350edaee6c7d400
4
- data.tar.gz: 53fa81ee144ca6e51dee68c8d10aade917b678879ef0cc79b05f14e35ab3209e
3
+ metadata.gz: ef82000ae2c1b5a995b0b6f65116d9fc7a19f0f57c3fc081e2e2b2c9aa1f6258
4
+ data.tar.gz: 0d0b079706f016d7ef9cab6d2b32f10836c802a3b4f3236e8381270e2deb9830
5
5
  SHA512:
6
- metadata.gz: f86b90bc2139f1820b0cb23b463416b1a675ea1c1c3b46f3714557d5f62cf3deb82a9fd770b05797a3904161bacf3df39aac86414f458873a407a96966a8df32
7
- data.tar.gz: 2928cb4c48b0b06c6eb1112e835598452302b8ad540324532fbf7c481a569fe7837dbc9a0ec39735af7cb78c63d939b84d396f067e434825f7fbd8becf85ba84
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- songle-song-uri-parser (1.1.0)
4
+ songle-song-uri-parser (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,8 +4,8 @@ module ::Songle::SongURI
4
4
  ##
5
5
  # @constructor
6
6
  #
7
- def initialize string
8
- super("'#{ string }' isn't song uri.")
7
+ def initialize query
8
+ super("'#{ query }' isn't song uri.")
9
9
  end
10
10
  end
11
11
  end
@@ -16,23 +16,23 @@ module ::Songle::SongURI
16
16
  ##
17
17
  # @constructor
18
18
  #
19
- def initialize string, options
20
- super(string, options)
19
+ def initialize query, options
20
+ super(query, options)
21
21
 
22
- if string =~ URI_REGEX
23
- string = $3
22
+ if query =~ URI_REGEX
23
+ query = $3
24
24
  end
25
25
 
26
- if string =~ /^#{ self.endpoint_host }(.+)$/
27
- string = $1
26
+ if query =~ /^#{ self.endpoint_host }(.+)$/
27
+ query = $1
28
28
  end
29
29
 
30
- if string =~ /^#{ self.endpoint_path }(.+)$/
31
- string = $1
30
+ if query =~ /^#{ self.endpoint_path }(.+)$/
31
+ query = $1
32
32
  end
33
33
 
34
34
  source_uri =
35
- ::URI.parse("//#{ string }")
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 string, options
30
- super(string, options)
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 string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
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 string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
29
+ def initialize query, options
30
+ super(query, options)
31
31
 
32
32
  @source_host = SOURCE_HOST
33
- @source_path = $1 if string =~ URI_REGEX
34
- @source_id = $2 if string =~ URI_REGEX
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(string)
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 string, options
20
- super(string, options)
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 string =~ URI_REGEX
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 string, options
30
- super(string, options)
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 string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
29
+ def initialize query, options
30
+ super(query, options)
31
31
 
32
32
  @source_host = SOURCE_HOST
33
- @source_path = $1 if string =~ URI_REGEX
34
- @source_id = $2 if string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
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 string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
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 string =~ URI_REGEX
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(string)
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 string, options
30
- super(string, options)
29
+ def initialize query, options
30
+ super(query, options)
31
31
 
32
32
  @source_host = SOURCE_HOST
33
- @source_path = $1 if string =~ URI_REGEX
34
- @source_id = $2 if string =~ URI_REGEX
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(string)
37
+ raise ::Songle::SongURI::InvalidSongURIError.new(query)
38
38
  end
39
39
  end
40
40
 
@@ -26,17 +26,17 @@ module ::Songle
26
26
  ##
27
27
  # @constructor
28
28
  #
29
- def initialize string, options = nil
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 string, options = nil
82
- string =
83
- ::URI.decode_www_form_component(string.to_s)
81
+ def parse query, options = nil
82
+ query =
83
+ ::URI.decode_www_form_component(query.to_s)
84
84
 
85
85
  case
86
- when string =~ ::Songle::SongURI::NnSongURI::URI_REGEX
87
- return ::Songle::SongURI::NnSongURI.new(string, options)
88
- when string =~ ::Songle::SongURI::NnSchemeSongURI::URI_REGEX
89
- return ::Songle::SongURI::NnSchemeSongURI.new(string, options)
90
- when string =~ ::Songle::SongURI::NnShortSongURI::URI_REGEX
91
- return ::Songle::SongURI::NnShortSongURI.new(string, options)
92
- when string =~ ::Songle::SongURI::ScSongURI::URI_REGEX
93
- return ::Songle::SongURI::ScSongURI.new(string, options)
94
- when string =~ ::Songle::SongURI::ScSchemeSongURI::URI_REGEX
95
- return ::Songle::SongURI::ScSchemeSongURI.new(string, options)
96
- when string =~ ::Songle::SongURI::YtSongURI::URI_REGEX
97
- return ::Songle::SongURI::YtSongURI.new(string, options)
98
- when string =~ ::Songle::SongURI::YtSchemeSongURI::URI_REGEX
99
- return ::Songle::SongURI::YtSchemeSongURI.new(string, options)
100
- when string =~ ::Songle::SongURI::YtShortSongURI::URI_REGEX
101
- return ::Songle::SongURI::YtShortSongURI.new(string, options)
102
- when string =~ ::Songle::SongURI::NumericSongURI::URI_REGEX
103
- return ::Songle::SongURI::NumericSongURI.new(string, options)
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(string, options)
105
+ return ::Songle::SongURI::Mp3SongURI.new(query, options)
106
106
  end
107
107
  end
108
108
  end
@@ -13,5 +13,5 @@ require "songle/song_uri/yt_short_song_uri"
13
13
  require "songle/song_uri/invalid_song_uri_error"
14
14
 
15
15
  module ::SongleSongURIParser
16
- VERSION = "1.1.0"
16
+ VERSION = "1.1.1"
17
17
  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.0
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-25 00:00:00.000000000 Z
11
+ date: 2019-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler