unchained 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +20 -0
  3. data/README.md +38 -0
  4. data/lib/unchained/client.rb +4 -0
  5. data/lib/unchained/client/archetypes.rb +5 -6
  6. data/lib/unchained/client/attributes.rb +35 -0
  7. data/lib/unchained/client/factions.rb +5 -6
  8. data/lib/unchained/client/mixins/resource.rb +110 -16
  9. data/lib/unchained/client/motd.rb +19 -0
  10. data/lib/unchained/client/patcher.rb +11 -13
  11. data/lib/unchained/client/races.rb +5 -6
  12. data/lib/unchained/client/servers.rb +11 -10
  13. data/lib/unchained/error.rb +2 -0
  14. data/lib/unchained/request.rb +5 -1
  15. data/lib/unchained/version.rb +1 -1
  16. data/test/_fixtures/vcr_cassettes/archetypes.yml +51 -0
  17. data/test/_fixtures/vcr_cassettes/attribute_offsets.yml +36 -0
  18. data/test/_fixtures/vcr_cassettes/attributes.yml +100 -0
  19. data/test/_fixtures/vcr_cassettes/factions.yml +45 -0
  20. data/test/_fixtures/vcr_cassettes/motd.yml +36 -0
  21. data/test/_fixtures/vcr_cassettes/patcher_alerts.yml +36 -0
  22. data/test/_fixtures/vcr_cassettes/patcher_hero_contents.yml +104 -0
  23. data/test/_fixtures/vcr_cassettes/races.yml +38 -0
  24. data/test/_fixtures/vcr_cassettes/servers.yml +36 -0
  25. data/test/test_helper.rb +7 -0
  26. data/test/unchained/client/archetypes_test.rb +27 -0
  27. data/test/unchained/client/attributes_test.rb +29 -0
  28. data/test/unchained/client/factions_test.rb +20 -0
  29. data/test/unchained/client/mixins/resource_test.rb +38 -0
  30. data/test/unchained/client/motd_test.rb +23 -0
  31. data/test/unchained/client/patcher_test.rb +29 -0
  32. data/test/unchained/client/races_test.rb +20 -0
  33. data/test/unchained/client/servers_test.rb +20 -0
  34. data/test/unchained/client_test.rb +0 -5
  35. data/unchained.gemspec +4 -2
  36. metadata +66 -2
@@ -0,0 +1,36 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.camelotunchained.com/v1/servers
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Logintoken:
15
+ - ''
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Content-Length:
24
+ - '471'
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Server:
28
+ - Microsoft-HTTPAPI/2.0
29
+ Date:
30
+ - Fri, 22 Apr 2016 15:47:37 GMT
31
+ body:
32
+ encoding: UTF-8
33
+ string: '[{"accessLevel":6,"channelID":4,"host":"wyrmlingprep.camelotunchained.com","name":"WyrmlingPrep","playerMaximum":1000,"shardID":1},{"accessLevel":6,"channelID":4,"host":"castle.camelotunchained.com","name":"Castle","playerMaximum":1492,"shardID":1},{"accessLevel":5,"channelID":4,"host":"hatchery.camelotunchained.com","name":"Hatchery","playerMaximum":1492,"shardID":1},{"accessLevel":6,"channelID":4,"host":"localhost","name":"localhost","playerMaximum":0,"shardID":0}]'
34
+ http_version:
35
+ recorded_at: Fri, 22 Apr 2016 15:47:58 GMT
36
+ recorded_with: VCR 3.0.1
@@ -1,3 +1,10 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'unchained'
3
3
  require 'minitest/autorun'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |config|
7
+ config.cassette_library_dir = "test/_fixtures/vcr_cassettes"
8
+ config.hook_into :webmock
9
+ end
10
+
@@ -0,0 +1,27 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Archetypes do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.archetypes' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('archetypes') do
12
+ archetypes = @client.archetypes
13
+ assert_equal(9, archetypes.count, "Expected 9 archetypes")
14
+
15
+ archetype = archetypes.first
16
+ assert_equal('The Dark Knight', archetype.description)
17
+ assert_equal(3, archetype.faction)
18
+ assert_equal(7, archetype.id)
19
+ assert_equal('Black Knight', archetype.name)
20
+ end
21
+ end
22
+ end
23
+
24
+
25
+ end
26
+
27
+
@@ -0,0 +1,29 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Attributes do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.attributes' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('attributes') do
12
+ attributes = @client.attributes(1)
13
+ assert_equal(37, attributes.count)
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '.attribute_offsets' do
19
+ it 'should fetch from the API' do
20
+ VCR.use_cassette('attribute_offsets') do
21
+ offsets = @client.attribute_offsets(1)
22
+ assert_equal(12, offsets.count)
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+
@@ -0,0 +1,20 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Factions do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.factions' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('factions') do
12
+ factions = @client.factions
13
+ assert_equal(4, factions.count)
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,38 @@
1
+ require_relative '../../../test_helper'
2
+
3
+ describe 'Resource Mixin' do
4
+
5
+ class SampleResource
6
+ include Unchained::Client::Mixins::Resource
7
+
8
+ attribute :company, String, allow_nil: true
9
+ attribute :name, String, allow_nil: false
10
+ attribute :city, String
11
+ end
12
+
13
+ describe 'nil attributes' do
14
+ it 'should allow nil values' do
15
+ resource = SampleResource.from_json(company: nil)
16
+ assert_nil(resource.company, 'Expected `company` to be nil')
17
+ end
18
+
19
+ it 'should parse non-nil values correctly' do
20
+ resource = SampleResource.from_json(company: 'CSE')
21
+ assert_equal('CSE', resource.company, 'Expected `company` to be set.')
22
+ end
23
+
24
+ it 'should allow you to disable nil explicitly' do
25
+ assert_raises(Unchained::InvalidValue) do
26
+ SampleResource.from_json(name: nil)
27
+ end
28
+ end
29
+
30
+ it 'should default to not allow nil' do
31
+ assert_raises(Unchained::InvalidValue) do
32
+ SampleResource.from_json(city: nil)
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+
@@ -0,0 +1,23 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::MOTD do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.motd' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('motd') do
12
+ motd = @client.motd
13
+
14
+ assert_equal('56ff1eeda7b0a02aa0e464cb', motd.id)
15
+ assert_equal('Welcome to Camelot Unchained!', motd.message)
16
+ assert_equal(30, motd.duration)
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+
@@ -0,0 +1,29 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Patcher do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.patcher_hero_contents' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('patcher_hero_contents') do
12
+ contents = @client.patcher_hero_contents
13
+ assert_equal(4, contents.count)
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '.patcher_alerts' do
19
+ it 'should fetch from the API' do
20
+ VCR.use_cassette('patcher_alerts') do
21
+ alerts = @client.patcher_alerts
22
+ assert_equal(1, alerts.count)
23
+ end
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+
@@ -0,0 +1,20 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Races do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.races' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('races') do
12
+ races = @client.races
13
+ assert_equal(6, races.count)
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+
@@ -0,0 +1,20 @@
1
+ require_relative '../../test_helper'
2
+
3
+ describe Unchained::Client::Servers do
4
+
5
+ before do
6
+ @client = Unchained::Client.new
7
+ end
8
+
9
+ describe '.servers' do
10
+ it 'should fetch from the API' do
11
+ VCR.use_cassette('servers') do
12
+ servers = @client.servers
13
+ assert_equal(4, servers.count)
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+
20
+
@@ -1,9 +1,4 @@
1
1
  require_relative '../test_helper'
2
2
 
3
3
  describe Unchained::Client do
4
-
5
- it 'should do a thing' do
6
- skip 'Not implemented'
7
- end
8
-
9
4
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = 'andrewpthorp@gmail.com'
11
11
  s.homepage = 'http://github.com/andrewpthorp/unchained'
12
12
 
13
- s.license = 'MIT'
13
+ s.licenses = ['MIT']
14
14
  s.summary = "Client library for Camelot Unchained API."
15
15
  s.description = <<-DESC
16
16
  A gem that lets you call into the Camelot Unchained API. You can see the API
@@ -25,7 +25,9 @@ Gem::Specification.new do |s|
25
25
  s.require_paths = ["lib"]
26
26
 
27
27
  s.add_development_dependency 'rake', '~> 11.0'
28
+ s.add_development_dependency 'webmock', '~> 1.24'
29
+ s.add_development_dependency 'vcr', '~> 3.0'
28
30
  s.add_development_dependency 'minitest', '~> 5.8'
29
- s.add_dependency 'pry', '~> 0.10'
31
+ s.add_development_dependency 'pry', '~> 0.10'
30
32
  s.add_dependency 'rest-client', '~> 1.8'
31
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unchained
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Thorp
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '11.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: webmock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.24'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.24'
41
+ - !ruby/object:Gem::Dependency
42
+ name: vcr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: minitest
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -45,7 +73,7 @@ dependencies:
45
73
  - - "~>"
46
74
  - !ruby/object:Gem::Version
47
75
  version: '0.10'
48
- type: :runtime
76
+ type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
@@ -79,8 +107,10 @@ files:
79
107
  - lib/unchained.rb
80
108
  - lib/unchained/client.rb
81
109
  - lib/unchained/client/archetypes.rb
110
+ - lib/unchained/client/attributes.rb
82
111
  - lib/unchained/client/factions.rb
83
112
  - lib/unchained/client/mixins/resource.rb
113
+ - lib/unchained/client/motd.rb
84
114
  - lib/unchained/client/patcher.rb
85
115
  - lib/unchained/client/races.rb
86
116
  - lib/unchained/client/servers.rb
@@ -88,7 +118,24 @@ files:
88
118
  - lib/unchained/error.rb
89
119
  - lib/unchained/request.rb
90
120
  - lib/unchained/version.rb
121
+ - test/_fixtures/vcr_cassettes/archetypes.yml
122
+ - test/_fixtures/vcr_cassettes/attribute_offsets.yml
123
+ - test/_fixtures/vcr_cassettes/attributes.yml
124
+ - test/_fixtures/vcr_cassettes/factions.yml
125
+ - test/_fixtures/vcr_cassettes/motd.yml
126
+ - test/_fixtures/vcr_cassettes/patcher_alerts.yml
127
+ - test/_fixtures/vcr_cassettes/patcher_hero_contents.yml
128
+ - test/_fixtures/vcr_cassettes/races.yml
129
+ - test/_fixtures/vcr_cassettes/servers.yml
91
130
  - test/test_helper.rb
131
+ - test/unchained/client/archetypes_test.rb
132
+ - test/unchained/client/attributes_test.rb
133
+ - test/unchained/client/factions_test.rb
134
+ - test/unchained/client/mixins/resource_test.rb
135
+ - test/unchained/client/motd_test.rb
136
+ - test/unchained/client/patcher_test.rb
137
+ - test/unchained/client/races_test.rb
138
+ - test/unchained/client/servers_test.rb
92
139
  - test/unchained/client_test.rb
93
140
  - test/unchained_test.rb
94
141
  - unchained.gemspec
@@ -117,7 +164,24 @@ signing_key:
117
164
  specification_version: 4
118
165
  summary: Client library for Camelot Unchained API.
119
166
  test_files:
167
+ - test/_fixtures/vcr_cassettes/archetypes.yml
168
+ - test/_fixtures/vcr_cassettes/attribute_offsets.yml
169
+ - test/_fixtures/vcr_cassettes/attributes.yml
170
+ - test/_fixtures/vcr_cassettes/factions.yml
171
+ - test/_fixtures/vcr_cassettes/motd.yml
172
+ - test/_fixtures/vcr_cassettes/patcher_alerts.yml
173
+ - test/_fixtures/vcr_cassettes/patcher_hero_contents.yml
174
+ - test/_fixtures/vcr_cassettes/races.yml
175
+ - test/_fixtures/vcr_cassettes/servers.yml
120
176
  - test/test_helper.rb
177
+ - test/unchained/client/archetypes_test.rb
178
+ - test/unchained/client/attributes_test.rb
179
+ - test/unchained/client/factions_test.rb
180
+ - test/unchained/client/mixins/resource_test.rb
181
+ - test/unchained/client/motd_test.rb
182
+ - test/unchained/client/patcher_test.rb
183
+ - test/unchained/client/races_test.rb
184
+ - test/unchained/client/servers_test.rb
121
185
  - test/unchained/client_test.rb
122
186
  - test/unchained_test.rb
123
187
  has_rdoc: