lyriki 1.0.1 → 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/.codeclimate.yml +27 -0
- data/.travis.yml +15 -3
- data/Guardfile +1 -2
- data/config/rubocop.yml +15 -0
- data/lib/lyriki/legacy/song_data.rb +6 -2
- data/lib/lyriki/legacy/song_lyrics.rb +4 -0
- data/lib/lyriki/version.rb +1 -1
- data/lib/web_helpers.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c81a53ab938c4b637d662453d77039754457bf73
|
4
|
+
data.tar.gz: 9ad1c2cdf6067e005152783e7b66500a7e644d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e37e051f19666f28efad6a75a09fcd667e6a2f04b77e9066ed49e60d9ba1a1ce88e582014f4a1de030426121dba7748783d6c3c991ee2417aa54608e512ab892
|
7
|
+
data.tar.gz: c54f196ab6a624a75ead07a2787df6a1c0f185e13824419d3ddc730b203f59144a70ad5c9fef3d5b311295c8d3bc8551931c1c2adbd802f8a7a0fd42abe89fec
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
# brakeman:
|
4
|
+
# enabled: true
|
5
|
+
duplication:
|
6
|
+
enabled: true
|
7
|
+
config:
|
8
|
+
languages:
|
9
|
+
ruby:
|
10
|
+
mass_threshold: 45
|
11
|
+
javascript:
|
12
|
+
mass_threshold: 30
|
13
|
+
fixme:
|
14
|
+
enabled: true
|
15
|
+
rubocop:
|
16
|
+
enabled: true
|
17
|
+
config: "config/rubocop.yml"
|
18
|
+
ratings:
|
19
|
+
paths:
|
20
|
+
- "**.inc"
|
21
|
+
- "**.js"
|
22
|
+
- "**.jsx"
|
23
|
+
- "**.module"
|
24
|
+
- "**.rb"
|
25
|
+
exclude_paths:
|
26
|
+
- config/
|
27
|
+
- spec/fixtures/
|
data/.travis.yml
CHANGED
@@ -1,9 +1,21 @@
|
|
1
|
+
sudo: false
|
1
2
|
language: ruby
|
2
3
|
bundler_args: --without development
|
3
4
|
rvm:
|
4
|
-
-
|
5
|
-
- 2.2.0
|
6
|
-
- 2.1.4
|
5
|
+
- 2
|
7
6
|
- 2.0
|
7
|
+
- 2.1
|
8
|
+
- 2.1.10
|
9
|
+
- 2.2
|
10
|
+
- ruby-head
|
11
|
+
- ruby-head-clang
|
12
|
+
- jruby-head
|
13
|
+
matrix:
|
14
|
+
fast_finish: true
|
15
|
+
allow_failures:
|
16
|
+
- rvm: jruby-head
|
17
|
+
- rvm: ruby-head
|
18
|
+
- rvm: ruby-head-clang
|
19
|
+
- rvm: 2.1.10
|
8
20
|
script:
|
9
21
|
- bundle exec rspec
|
data/Guardfile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
guard :rspec, cmd:
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
2
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
3
3
|
watch(%r{^spec/.+_spec\.rb$})
|
4
4
|
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
5
5
|
watch("spec/spec_helper.rb") { "spec" }
|
6
6
|
end
|
7
|
-
|
data/config/rubocop.yml
CHANGED
@@ -6,6 +6,21 @@ AllCops:
|
|
6
6
|
Metrics/LineLength:
|
7
7
|
Max: 120
|
8
8
|
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/EmptyLinesAroundBlockBody:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/EmptyLinesAroundClassBody:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/EmptyLinesAroundModuleBody:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/ExtraSpacing:
|
22
|
+
Enabled: false
|
23
|
+
|
9
24
|
Style/SpaceAroundEqualsInParameterDefault:
|
10
25
|
Enabled: false
|
11
26
|
|
@@ -9,11 +9,13 @@ module Lyriki
|
|
9
9
|
|
10
10
|
def initialize(**args)
|
11
11
|
raise ArgumentError unless args[:artist] && args[:song]
|
12
|
-
|
12
|
+
data = JSON.parse(get(url_for_song(args[:artist], args[:song])))
|
13
|
+
raise NoLyricsError, "lyrics not found: #{data}" if data["lyrics"] == "Not found"
|
14
|
+
@data = data
|
13
15
|
end
|
14
16
|
|
15
17
|
def response_data
|
16
|
-
|
18
|
+
@data
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -25,3 +27,5 @@ module Lyriki
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
30
|
+
|
31
|
+
class NoLyricsError < StandardError; end
|
@@ -11,6 +11,10 @@ module Lyriki
|
|
11
11
|
def initialize(**args)
|
12
12
|
raise ArgumentError unless args[:artist] && args[:song]
|
13
13
|
song_data = SongData.new(args).response_data
|
14
|
+
if song_data["lyrics"] == "Not found"
|
15
|
+
raise NoLyricsError, "lyrics not found: #{song_data}"
|
16
|
+
end
|
17
|
+
|
14
18
|
@data = get(song_data["url"])
|
15
19
|
end
|
16
20
|
|
data/lib/lyriki/version.rb
CHANGED
data/lib/web_helpers.rb
CHANGED
@@ -5,11 +5,13 @@ module WebHelpers
|
|
5
5
|
def get(url, limit=10)
|
6
6
|
raise ArgumentError, "get() redirects too deep" if limit < 1
|
7
7
|
|
8
|
+
raise EditUrlError, "shouldn't be trying to edit... #{url}" if url =~ /[?&]action=edit\b/
|
9
|
+
|
8
10
|
response = Net::HTTP.get_response(URI(url))
|
9
11
|
case response
|
10
12
|
when Net::HTTPSuccess then response.body
|
11
13
|
when Net::HTTPRedirection then get(response["location"], limit - 1)
|
12
|
-
else
|
14
|
+
else response.error!
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -18,3 +20,5 @@ module WebHelpers
|
|
18
20
|
end
|
19
21
|
|
20
22
|
end
|
23
|
+
|
24
|
+
class EditUrlError < StandardError; end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lyriki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -118,6 +118,7 @@ executables: []
|
|
118
118
|
extensions: []
|
119
119
|
extra_rdoc_files: []
|
120
120
|
files:
|
121
|
+
- ".codeclimate.yml"
|
121
122
|
- ".gitignore"
|
122
123
|
- ".hound.yml"
|
123
124
|
- ".pullreview.yml"
|