lol_static 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd63390f5fd29ace9c415bad9e93121836151c1d
4
- data.tar.gz: a4db75b631e2a40137f14a634dfc8bcae4845dfc
3
+ metadata.gz: debfeb6efa88cc7fd0ce0959fb5be914ab7a595b
4
+ data.tar.gz: d861a73c7f8ed565e22f5b6c278266f0fad1aa03
5
5
  SHA512:
6
- metadata.gz: 54e99065a57b04948128a1aa4a1a42fde219dacdaf8c4bc2f95c0239543bdc05437325730396957acbd83fda382b6f38e6a6463400afa4ea7ab3904347eaa6dd
7
- data.tar.gz: f7916750278a3f435d8621d5184c7f09de9b68f6eebe349bb919cff86cef03ca01c6bfe19222d317af081f14f0bc5a7dd314e5ba65d6089e1a4b57f2ff068ff0
6
+ metadata.gz: 54e4c9229cab511274227938f5702f3b3e42e9121a657ae4a1b4eed311b63b1875428acd93ba947754df70c59aadca8c7fab7c0f6dd58b38b229290499b0cf3c
7
+ data.tar.gz: e5c9cae4bbfab3ea5d5d03d2f099853ab9b5a33e42d1c2e789524749f3b72518eb3d6f0392aaeaa2a3b06174dea36e25cbd4a892a76f18d0f88c4e770a69ae44
@@ -0,0 +1,11 @@
1
+ require 'lol_static/endpoint'
2
+
3
+ module LolStatic
4
+ class Champion < Endpoint
5
+
6
+ def self.key
7
+ 'champion'
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ module LolStatic
2
+ Config = Object.new.tap do |object|
3
+ class << object
4
+
5
+ def api_version(*args)
6
+ realm.api_version(*args)
7
+ end
8
+
9
+ def base_uri
10
+ realm.base_uri
11
+ end
12
+
13
+ private
14
+
15
+ def realm
16
+ @realm ||= Realm.new
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,18 +1,19 @@
1
1
  require 'open-uri'
2
+ require 'lol_static/config'
2
3
 
3
4
  module LolStatic
4
5
  class Endpoint
5
6
 
6
7
  def self.api_version
7
- LolStatic.api_version
8
+ LolStatic::Config.api_version(key)
8
9
  end
9
10
 
10
11
  def initialize(id)
11
12
  @id = id
12
13
  end
13
14
 
14
- def api_version
15
- self.class.api_version
15
+ def image_url
16
+ "#{LolStatic::Config.base_uri}/#{self.class.api_version}/img/#{self.class.key}/#{@id}.png"
16
17
  end
17
18
 
18
19
  def download(path)
@@ -1,15 +1,10 @@
1
- require 'lol_static'
2
1
  require 'lol_static/endpoint'
3
2
 
4
3
  module LolStatic
5
4
  class Item < Endpoint
6
5
 
7
- def self.api_version
8
- LolStatic.api_version('item')
9
- end
10
-
11
- def image_url
12
- "#{LolStatic.base_uri}/#{api_version}/img/item/#{@id}.png"
6
+ def self.key
7
+ 'item'
13
8
  end
14
9
 
15
10
  end
@@ -8,7 +8,7 @@ module LolStatic
8
8
  end
9
9
 
10
10
  def api_version(name=nil)
11
- name ? realm_data['n'][name.to_s] : realm_data['v']
11
+ realm_data['n'].has_key?(name.to_s) ? realm_data['n'][name.to_s] : realm_data['v']
12
12
  end
13
13
 
14
14
  private
@@ -1,11 +1,10 @@
1
- require 'lol_static'
2
1
  require 'lol_static/endpoint'
3
2
 
4
3
  module LolStatic
5
4
  class Spell < Endpoint
6
5
 
7
- def image_url
8
- "#{LolStatic.base_uri}/#{api_version}/img/spell/#{@id}.png"
6
+ def self.key
7
+ 'spell'
9
8
  end
10
9
 
11
10
  end
@@ -1,3 +1,3 @@
1
1
  module LolStatic
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
data/lib/lol_static.rb CHANGED
@@ -2,17 +2,11 @@ require 'lol_static/version'
2
2
  require 'lol_static/item'
3
3
  require 'lol_static/spell'
4
4
  require 'lol_static/realm'
5
+ require 'lol_static/champion'
5
6
 
6
7
 
7
8
  module LolStatic
8
9
  class << self
9
- def api_version(*args)
10
- realm.api_version(*args)
11
- end
12
-
13
- def base_uri
14
- realm.base_uri
15
- end
16
10
 
17
11
  def item(id)
18
12
  Item.new(id)
@@ -22,10 +16,8 @@ module LolStatic
22
16
  Spell.new(id)
23
17
  end
24
18
 
25
- private
26
-
27
- def realm
28
- @realm ||= Realm.new
19
+ def champion(id)
20
+ Champion.new(id)
29
21
  end
30
22
 
31
23
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ require 'lol_static/champion'
4
+
5
+ describe LolStatic::Champion do
6
+
7
+ use_vcr_cassette 'realm'
8
+
9
+ let(:id) { 'Champion' }
10
+
11
+ let(:spell) { LolStatic::Champion.new(id) }
12
+
13
+ describe '.api_version' do
14
+ it 'returns api version' do
15
+ expect(LolStatic::Champion.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/champion/#{id}.png")
22
+ end
23
+ end
24
+ end
@@ -6,9 +6,9 @@ describe LolStatic::Spell do
6
6
 
7
7
  use_vcr_cassette 'realm'
8
8
 
9
- let(:id) { }
9
+ let(:id) { 'Spell' }
10
10
 
11
- let(:spell) { LolStatic::Spell.new('Spell') }
11
+ let(:spell) { LolStatic::Spell.new(id) }
12
12
 
13
13
  describe '.api_version' do
14
14
  it 'returns api version' do
@@ -18,7 +18,7 @@ describe LolStatic::Spell do
18
18
 
19
19
  describe '#image_url' do
20
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')
21
+ expect(spell.image_url).to eq("http://ddragon.leagueoflegends.com/cdn/4.4.3/img/spell/#{id}.png")
22
22
  end
23
23
  end
24
24
  end
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.6
4
+ version: 0.0.7
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-21 00:00:00.000000000 Z
11
+ date: 2014-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,6 +107,8 @@ files:
107
107
  - README.md
108
108
  - Rakefile
109
109
  - lib/lol_static.rb
110
+ - lib/lol_static/champion.rb
111
+ - lib/lol_static/config.rb
110
112
  - lib/lol_static/endpoint.rb
111
113
  - lib/lol_static/item.rb
112
114
  - lib/lol_static/realm.rb
@@ -114,6 +116,7 @@ files:
114
116
  - lib/lol_static/version.rb
115
117
  - lol_static.gemspec
116
118
  - spec/fixtures/realm.yml
119
+ - spec/lol_static/champion_spec.rb
117
120
  - spec/lol_static/item_spec.rb
118
121
  - spec/lol_static/realm_spec.rb
119
122
  - spec/lol_static/spell_spec.rb
@@ -144,6 +147,7 @@ specification_version: 4
144
147
  summary: Fetches static content from the league of legends CDN
145
148
  test_files:
146
149
  - spec/fixtures/realm.yml
150
+ - spec/lol_static/champion_spec.rb
147
151
  - spec/lol_static/item_spec.rb
148
152
  - spec/lol_static/realm_spec.rb
149
153
  - spec/lol_static/spell_spec.rb