lol_static 0.0.2 → 0.0.4
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/lib/lol_static/endpoint.rb +31 -0
- data/lib/lol_static/item.rb +3 -10
- data/lib/lol_static/realm.rb +2 -2
- data/lib/lol_static/spell.rb +12 -0
- data/lib/lol_static/version.rb +1 -1
- data/lib/lol_static.rb +6 -2
- data/spec/lol_static/item_spec.rb +14 -4
- data/spec/lol_static/spell_spec.rb +24 -0
- data/spec/spec_helper.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec2be92c96b8fd39cee72182d7b57b327bdd3d06
|
4
|
+
data.tar.gz: 43dbd7e54398e48c810300c3efd39c13c9cca6a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c2775c1ba3876a3797ef0cb5720e219881a2d747d7e00933862f28aa44cd41ce2daca01809368f45c5cb1956192fa85379e78c4c41924e3b6f0407059724ca3
|
7
|
+
data.tar.gz: 8251298ca7b4d12fc604bea935d0727f1952fa4aef71b3f7f9768be7d86420d0979e608f42860c20031d46c409c94fdf9b511c86e3b9ab22cd165a56674bea20
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module LolStatic
|
4
|
+
class Endpoint
|
5
|
+
|
6
|
+
def self.api_version
|
7
|
+
LolStatic.api_version
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(id)
|
11
|
+
@id = id
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_version
|
15
|
+
self.class.api_version
|
16
|
+
end
|
17
|
+
|
18
|
+
def download(path)
|
19
|
+
open(image_url) do |image|
|
20
|
+
File.open(path, 'wb') do |f|
|
21
|
+
f.write(image.read)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
rescue OpenURI::HTTPError
|
25
|
+
false
|
26
|
+
else
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/lol_static/item.rb
CHANGED
@@ -1,22 +1,15 @@
|
|
1
1
|
require 'lol_static'
|
2
|
+
require 'lol_static/endpoint'
|
2
3
|
|
3
4
|
module LolStatic
|
4
|
-
class Item
|
5
|
+
class Item < Endpoint
|
5
6
|
|
6
7
|
def self.api_version
|
7
8
|
LolStatic.api_version('item')
|
8
9
|
end
|
9
10
|
|
10
|
-
def initialize(item_id)
|
11
|
-
@item_id = item_id
|
12
|
-
end
|
13
|
-
|
14
|
-
def api_version
|
15
|
-
self.class.api_version
|
16
|
-
end
|
17
|
-
|
18
11
|
def image_url
|
19
|
-
"#{LolStatic.base_uri}/#{api_version}/img/item/#{@
|
12
|
+
"#{LolStatic.base_uri}/#{api_version}/img/item/#{@id}.png"
|
20
13
|
end
|
21
14
|
|
22
15
|
end
|
data/lib/lol_static/realm.rb
CHANGED
data/lib/lol_static/version.rb
CHANGED
data/lib/lol_static.rb
CHANGED
@@ -4,8 +4,8 @@ require 'lol_static/item'
|
|
4
4
|
|
5
5
|
module LolStatic
|
6
6
|
class << self
|
7
|
-
def api_version(
|
8
|
-
realm.api_version(
|
7
|
+
def api_version(*args)
|
8
|
+
realm.api_version(*args)
|
9
9
|
end
|
10
10
|
|
11
11
|
def base_uri
|
@@ -16,6 +16,10 @@ module LolStatic
|
|
16
16
|
Item.new(id)
|
17
17
|
end
|
18
18
|
|
19
|
+
def spell(id)
|
20
|
+
Spell.new(id)
|
21
|
+
end
|
22
|
+
|
19
23
|
private
|
20
24
|
|
21
25
|
def realm
|
@@ -3,12 +3,22 @@ require 'spec_helper'
|
|
3
3
|
require 'lol_static/item'
|
4
4
|
|
5
5
|
describe LolStatic::Item do
|
6
|
+
|
7
|
+
use_vcr_cassette 'realm'
|
8
|
+
|
9
|
+
let(:id) { 1 }
|
10
|
+
let(:item) { LolStatic::Item.new(id) }
|
11
|
+
|
12
|
+
describe '.api_version' do
|
13
|
+
it 'returns api version' do
|
14
|
+
expect(LolStatic::Item.api_version).to eq('4.4.3')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
6
18
|
describe '#image_url' do
|
7
19
|
it 'returns image url' do
|
8
|
-
|
9
|
-
|
10
|
-
expect(item.image_url).to eq('http://ddragon.leagueoflegends.com/cdn/4.4.3/img/item/1.png')
|
11
|
-
end
|
20
|
+
item = LolStatic::Item.new(1)
|
21
|
+
expect(item.image_url).to eq("http://ddragon.leagueoflegends.com/cdn/4.4.3/img/item/#{id}.png")
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'lol_static/spell'
|
4
|
+
|
5
|
+
describe LolStatic::Spell do
|
6
|
+
|
7
|
+
use_vcr_cassette 'realm'
|
8
|
+
|
9
|
+
let(:id) { }
|
10
|
+
|
11
|
+
let(:spell) { LolStatic::Spell.new('Spell') }
|
12
|
+
|
13
|
+
describe '.api_version' do
|
14
|
+
it 'returns api version' do
|
15
|
+
expect(LolStatic::Spell.api_version).to eq('4.4.3')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#image_url' do
|
20
|
+
it 'returns image url' do
|
21
|
+
expect(spell.image_url).to eq('http://ddragon.leagueoflegends.com/cdn/4.4.3/img/spell/Spell.png')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lol_static
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,13 +107,16 @@ files:
|
|
107
107
|
- README.md
|
108
108
|
- Rakefile
|
109
109
|
- lib/lol_static.rb
|
110
|
+
- lib/lol_static/endpoint.rb
|
110
111
|
- lib/lol_static/item.rb
|
111
112
|
- lib/lol_static/realm.rb
|
113
|
+
- lib/lol_static/spell.rb
|
112
114
|
- lib/lol_static/version.rb
|
113
115
|
- lol_static.gemspec
|
114
116
|
- spec/fixtures/realm.yml
|
115
117
|
- spec/lol_static/item_spec.rb
|
116
118
|
- spec/lol_static/realm_spec.rb
|
119
|
+
- spec/lol_static/spell_spec.rb
|
117
120
|
- spec/spec_helper.rb
|
118
121
|
homepage: ''
|
119
122
|
licenses:
|
@@ -143,5 +146,6 @@ test_files:
|
|
143
146
|
- spec/fixtures/realm.yml
|
144
147
|
- spec/lol_static/item_spec.rb
|
145
148
|
- spec/lol_static/realm_spec.rb
|
149
|
+
- spec/lol_static/spell_spec.rb
|
146
150
|
- spec/spec_helper.rb
|
147
151
|
has_rdoc:
|