mwo 0.0.1 → 0.0.2
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/README.md +14 -4
- data/lib/mwo/collection_utils.rb +12 -0
- data/lib/mwo/version.rb +1 -1
- data/lib/mwo/weapon.rb +39 -8
- data/spec/mwo/collection_utils_spec.rb +31 -0
- data/spec/mwo/weapon_spec.rb +48 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4134f13a879cf08810cc439001d1f0e8b6aea5ef
|
4
|
+
data.tar.gz: 268567c0034838c086d37cf3aca3b2f191019fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2769e0d042310f0711d180bea44b0242036a24480b82de14dae60af2c7749edd35a458555d906a03ea029499e012e04f29846925a003c8d2fbe70a5d6f212c18
|
7
|
+
data.tar.gz: bd610f498c9c6d98bd1084ddf5564c2a66db59c525ed8a8470b12ca8adcef93d30e31aeb65e47aee450183a7c83e1f5bf601fa6f1ed9826ef1b30372371a6e69
|
data/README.md
CHANGED
@@ -30,15 +30,25 @@ Get a list of all weapons
|
|
30
30
|
|
31
31
|
Scoped weapons
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
- [
|
33
|
+
### By Category
|
34
|
+
|
35
|
+
- [x] MWO::Weapon.ballistic
|
36
|
+
- [x] MWO::Weapon.energy
|
37
|
+
- [x] MWO::Weapon.missile
|
38
|
+
|
39
|
+
### By Faction
|
40
|
+
|
41
|
+
- [x] MWO::Weapon.clan
|
42
|
+
- [x] MWO::Weapon.innersphere
|
36
43
|
|
37
44
|
### Mechs
|
38
45
|
|
39
|
-
|
46
|
+
List all Mechs
|
40
47
|
|
41
48
|
- [ ] MWO::Mech.all
|
49
|
+
|
50
|
+
#### By Faction
|
51
|
+
|
42
52
|
- [ ] MWO::Mech.inner_sphere
|
43
53
|
- [ ] MWO::Mech.clan
|
44
54
|
|
data/lib/mwo/version.rb
CHANGED
data/lib/mwo/weapon.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
class MWO::Weapon
|
2
|
-
|
2
|
+
|
3
|
+
attr_accessor :weapon_id, :name, :type, :num_firing, :damage, :heatpenalty, :heat, :inner_sphere, :clan,
|
4
|
+
:category, :health, :slots, :projectileclass, :heatdamage,
|
5
|
+
:minheatpenaltylevel, :impulse, :cooldown, :ammo_type, :ammo_per_shot,
|
6
|
+
:min_range, :long_range, :max_range, :tons, :duration, :lifetime,
|
7
|
+
:speed, :volleydelay, :gravity, :max_depth, :vis_range, :heat_penalty_id,
|
8
|
+
:maxheight, :radius, :artemis_ammo_type, :formation_size,
|
9
|
+
:formation_size_per_index, :spread,:null_range, :peakdist, :peaktime,
|
10
|
+
:minheight, :uselock, :trackingstrength, :hitpoints, :use_tag, :formation_speed, :emp, :coneoffire,
|
11
|
+
:heatinctime, :trgheatinctime, :crit_dam_mult, :crit_chance_increase, :rof,
|
12
|
+
:groupedlocally, :explode_chance, :internal_explosion_dmg, :num_per_shot,
|
13
|
+
:tag, :tag_spread_factor, :tag_decay, :tag_duration, :needlock,
|
14
|
+
:shots_during_cooldown, :jamming_chance, :jammed_time, :splash_percent,
|
15
|
+
:volleysize, :falloffexponent
|
3
16
|
|
4
17
|
extend MWO::Utils
|
5
18
|
|
@@ -21,14 +34,12 @@ class MWO::Weapon
|
|
21
34
|
|
22
35
|
weapon = {weapon_id: weapon_id.to_i,
|
23
36
|
name: attrs["name"],
|
24
|
-
category: attrs["category"]
|
25
|
-
|
37
|
+
category: attrs["category"]
|
38
|
+
}
|
26
39
|
|
27
40
|
if attrs["factions"]
|
28
|
-
weapon[:
|
29
|
-
attrs["factions"]
|
30
|
-
weapon[:factions][to_symbol(k)] = v
|
31
|
-
end
|
41
|
+
weapon[:clan] = attrs["factions"]["Clan"]
|
42
|
+
weapon[:inner_sphere] = attrs["factions"]["InnerSphere"]
|
32
43
|
end
|
33
44
|
|
34
45
|
attrs["stats"].each do |k,v|
|
@@ -40,7 +51,27 @@ class MWO::Weapon
|
|
40
51
|
|
41
52
|
end
|
42
53
|
|
43
|
-
return weapons
|
54
|
+
return weapons.extend MWO::CollectionUtils
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.energy
|
59
|
+
all.filter({type: 'Energy'})
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.ballistic
|
63
|
+
all.filter({type: 'Ballistic'})
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.missile
|
67
|
+
all.filter({type: 'Missile'})
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.inner_sphere
|
71
|
+
all.filter({inner_sphere: true})
|
72
|
+
end
|
44
73
|
|
74
|
+
def self.clan
|
75
|
+
all.filter({clan: true})
|
45
76
|
end
|
46
77
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Something
|
4
|
+
attr_accessor :name, :material, :color
|
5
|
+
def initialize args = {}
|
6
|
+
args.each do |k,v|
|
7
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe MWO::CollectionUtils do
|
13
|
+
let(:a) { Something.new(name: 'a', material: 'wood', color: 'red')}
|
14
|
+
let(:b) { Something.new(name: 'b', material: 'plastic', color: 'green')}
|
15
|
+
let(:c) { Something.new(name: 'c', material: 'plastic', color: 'blue')}
|
16
|
+
let(:collection) {[a,b,c]}
|
17
|
+
let(:unextended_collection) {[1,2,3]}
|
18
|
+
|
19
|
+
describe '#filter' do
|
20
|
+
it "filters extended collections " do
|
21
|
+
collection.extend MWO::CollectionUtils
|
22
|
+
expect(collection.filter({name:'a'})).to match([a])
|
23
|
+
expect(collection.filter({material:'plastic'})).to match([b,c])
|
24
|
+
end
|
25
|
+
|
26
|
+
it "does not filter unextended collections" do
|
27
|
+
expect{unextended_collection.filter}.to raise_error(NameError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/spec/mwo/weapon_spec.rb
CHANGED
@@ -6,9 +6,55 @@ describe MWO::Weapon do
|
|
6
6
|
subject(:weapons) {described_class.all}
|
7
7
|
it "returns a collection of weapons", vcr: {cassette_name: 'all_weapons'} do
|
8
8
|
expect(weapons).to include(
|
9
|
-
an_object_having_attributes(weapon_id: 1000, name: "AutoCannon20", type: 'Ballistic', num_firing: 1, damage: 20, heatpenalty: 24, heat: 6,
|
10
|
-
an_object_having_attributes(weapon_id: 1241, name: "ClanAutoCannon20", type: 'Ballistic', num_firing: 5, damage: 4, heatpenalty: 30, heat: 6,
|
9
|
+
an_object_having_attributes(weapon_id: 1000, name: "AutoCannon20", type: 'Ballistic', num_firing: 1, damage: 20, heatpenalty: 24, heat: 6, clan: false, inner_sphere: true),
|
10
|
+
an_object_having_attributes(weapon_id: 1241, name: "ClanAutoCannon20", type: 'Ballistic', num_firing: 5, damage: 4, heatpenalty: 30, heat: 6, clan: true, inner_sphere: false)
|
11
11
|
)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
describe ".energy", vcr: {cassette_name: 'all_weapons'} do
|
16
|
+
subject(:energy_weapons) {described_class.energy }
|
17
|
+
it "returns a collection of energy weapons" do
|
18
|
+
expect(energy_weapons).to_not be_empty
|
19
|
+
expect(energy_weapons.collect(&:type)).to include('Energy')
|
20
|
+
expect(energy_weapons.collect(&:type)).to_not include('Ballistic', 'Missile')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ".ballistic", vcr: {cassette_name: 'all_weapons'} do
|
25
|
+
subject(:ballistic_weapons) {described_class.ballistic }
|
26
|
+
it "returns a collection of energy weapons" do
|
27
|
+
expect(ballistic_weapons).to_not be_empty
|
28
|
+
expect(ballistic_weapons.collect(&:type)).to include('Ballistic')
|
29
|
+
expect(ballistic_weapons.collect(&:type)).to_not include('Energy', 'Missile')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".missile", vcr: {cassette_name: 'all_weapons'} do
|
34
|
+
subject(:missile_weapons) {described_class.missile }
|
35
|
+
it "returns a collection of energy weapons" do
|
36
|
+
expect(missile_weapons).to_not be_empty
|
37
|
+
expect(missile_weapons).to include( an_object_having_attributes(type: 'Missile'))
|
38
|
+
expect(missile_weapons).to_not include( an_object_having_attributes(type: 'Ballistic'))
|
39
|
+
expect(missile_weapons).to_not include( an_object_having_attributes(type: 'Energy'))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".inner_sphere", vcr: {cassette_name: 'all_weapons'} do
|
44
|
+
subject(:inner_sphere_weapons) {described_class.inner_sphere }
|
45
|
+
it "returns a collection of energy weapons" do
|
46
|
+
expect(inner_sphere_weapons).to_not be_empty
|
47
|
+
expect(inner_sphere_weapons).to include(an_object_having_attributes(inner_sphere: true))
|
48
|
+
expect(inner_sphere_weapons).to_not include(an_object_having_attributes(inner_sphere: false))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ".clan", vcr: {cassette_name: 'all_weapons'} do
|
53
|
+
subject(:clan_weapons) {described_class.clan }
|
54
|
+
it "returns a collection of energy weapons" do
|
55
|
+
expect(clan_weapons).to_not be_empty
|
56
|
+
expect(clan_weapons).to include(an_object_having_attributes(clan: true))
|
57
|
+
expect(clan_weapons).to_not include(an_object_having_attributes(clan: false))
|
58
|
+
end
|
59
|
+
end
|
14
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mwo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buddy Magsipoc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -211,11 +211,13 @@ files:
|
|
211
211
|
- fixtures/cassettes/utils_fetch_url.yml
|
212
212
|
- lib/mwo.rb
|
213
213
|
- lib/mwo/client.rb
|
214
|
+
- lib/mwo/collection_utils.rb
|
214
215
|
- lib/mwo/utils.rb
|
215
216
|
- lib/mwo/version.rb
|
216
217
|
- lib/mwo/weapon.rb
|
217
218
|
- mwo.gemspec
|
218
219
|
- spec/mwo/client_spec.rb
|
220
|
+
- spec/mwo/collection_utils_spec.rb
|
219
221
|
- spec/mwo/utils_spec.rb
|
220
222
|
- spec/mwo/weapon_spec.rb
|
221
223
|
- spec/spec_helper.rb
|
@@ -245,6 +247,7 @@ specification_version: 4
|
|
245
247
|
summary: Ruby gem for interfacing with Mechwarrior Online's Public API
|
246
248
|
test_files:
|
247
249
|
- spec/mwo/client_spec.rb
|
250
|
+
- spec/mwo/collection_utils_spec.rb
|
248
251
|
- spec/mwo/utils_spec.rb
|
249
252
|
- spec/mwo/weapon_spec.rb
|
250
253
|
- spec/spec_helper.rb
|