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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87ce33fa711df489d17d4ca2b4fcfce5459a140a
4
- data.tar.gz: 0ff054ad4a5c8254bb18a112667239fecb226d05
3
+ metadata.gz: c81a53ab938c4b637d662453d77039754457bf73
4
+ data.tar.gz: 9ad1c2cdf6067e005152783e7b66500a7e644d10
5
5
  SHA512:
6
- metadata.gz: e1d7a146cd0a25d19fd4f8215f890c11dce3f9a3865864fa8e277c155c7fb3a3737440a8f652708a8606b71a705029a55229b87af4d738a51305978a1947b6d3
7
- data.tar.gz: aa195eb8c70fb570e8ffdcd275734bd809b1eecdf13017f91e46b4bd834b140a1efd859a709027cc65bfb02c99a93e76db338c72f44dae1b6f0e0b9829b00297
6
+ metadata.gz: e37e051f19666f28efad6a75a09fcd667e6a2f04b77e9066ed49e60d9ba1a1ce88e582014f4a1de030426121dba7748783d6c3c991ee2417aa54608e512ab892
7
+ data.tar.gz: c54f196ab6a624a75ead07a2787df6a1c0f185e13824419d3ddc730b203f59144a70ad5c9fef3d5b311295c8d3bc8551931c1c2adbd802f8a7a0fd42abe89fec
@@ -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/
@@ -1,9 +1,21 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  bundler_args: --without development
3
4
  rvm:
4
- - ruby-head
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: 'bundle exec rspec' do
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
-
@@ -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
- @data = get(url_for_song(args[:artist], args[:song]))
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
- JSON.parse @data
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
 
@@ -1,3 +1,3 @@
1
1
  module Lyriki
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.1".freeze
3
3
  end
@@ -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 response.error!
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.0.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-02-21 00:00:00.000000000 Z
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"