mwo 0.1.0 → 0.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: 138ad0e213c97cacd163a6b3df3697839d3d8bae
4
- data.tar.gz: 13a3d6a96bcd4f383f5fba430af60e51a2f0aecf
3
+ metadata.gz: 8dfa6974e19a7d3d1f5328a707c6d5ca1fd17c2a
4
+ data.tar.gz: 7ab2aa704f3a3d46f84791fcb9699a1f6302546c
5
5
  SHA512:
6
- metadata.gz: 8132b50dd4d39e24f3682e41e8986513a702fb798a753e3777096d60cad54b0233313eb6361afb26ab6bb7d9051aa414575b681010a59a05d26b7f95daf4580b
7
- data.tar.gz: 138860702389aef49a29d5b43c4bcc5874a671fa67d583dd41ffcb94cdabfb0ecf80e9d5263cd429e5978e8942d558d68f2024c7896b7ab55ea4fcc8a4237460
6
+ metadata.gz: 3332f0ae91e9e62957795483161f55708a0c27e7547a9a1911fc1d697880a095d76d25bfe6bb1c7a3bf32ca9b81f03b78302472bb6355c20723efde2ce1584bd
7
+ data.tar.gz: b1fbbaa29f97beae3ddddcbbb029f9a23939be8ddec33684940bdcd453ccdcdabb4f310d951e8f20c9abe3afdff97847330e96eefb1d38c99c92ca6b9dad9bf6
data/README.md CHANGED
@@ -58,15 +58,10 @@ List all Mechs
58
58
 
59
59
  #### By Weight class
60
60
 
61
- - [ ] MWO::Mech.lights
62
- - [ ] MWO::Mech.mediums
63
- - [ ] MWO::Mech.heavies
64
- - [ ] MWO::Mech.assaults
65
-
66
- #### Chain em
67
-
68
- MWO::Mech.clan.lights
69
- MWO::Mech.inner_sphere.assaults
61
+ - [x] MWO::Mech.lights
62
+ - [x] MWO::Mech.mediums
63
+ - [x] MWO::Mech.heavies
64
+ - [x] MWO::Mech.assaults
70
65
 
71
66
  ### Omniparts
72
67
 
data/lib/mwo/mech.rb CHANGED
@@ -17,6 +17,21 @@ class MWO::Mech < OpenStruct
17
17
  # Remove the loadout from the index.
18
18
  attrs.delete('Loadout')
19
19
 
20
+ # The mech classification value is broken in the API
21
+ attrs.delete('Class')
22
+ attrs["WeightClass"] = case attrs['MaxTons']
23
+ when 0..35
24
+ 'Light'
25
+ when 36..55
26
+ 'Medium'
27
+ when 56..75
28
+ 'Heavy'
29
+ when 76..100
30
+ 'Assault'
31
+ when 101.300
32
+ 'Experimental'
33
+ end
34
+
20
35
  # Remove the 'class' attribute, it is bugged from the API
21
36
  attrs.delete('Loadout')
22
37
 
@@ -25,9 +40,27 @@ class MWO::Mech < OpenStruct
25
40
  mech[to_symbol(k)] = v
26
41
  end
27
42
 
43
+ # set override the invalid classification
28
44
  mechs << new(mech)
29
45
  end
30
- mechs
46
+
47
+ return mechs.extend MWO::CollectionUtils
48
+ end
49
+
50
+ def self.lights
51
+ all.filter({weight_class: 'Light'})
52
+ end
53
+
54
+ def self.mediums
55
+ all.filter({weight_class: 'Medium'})
56
+ end
57
+
58
+ def self.heavies
59
+ all.filter({weight_class: 'Heavy'})
60
+ end
61
+
62
+ def self.assaults
63
+ all.filter({weight_class: 'Assault'})
31
64
  end
32
65
 
33
66
  def self.dictionary
data/lib/mwo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mwo
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -3,11 +3,43 @@ require 'spec_helper'
3
3
  describe MWO::Mech do
4
4
  describe '.all', vcr: {cassette_name: 'all_mechs'} do
5
5
  let (:subject) { described_class.all }
6
- let (:hbk4g) { an_object_having_attributes(name: 'hbk-4g', max_armor: 338, mech_id: 1, total_tons: 50) }
6
+ let (:hbk4g) { an_object_having_attributes(name: 'hbk-4g', max_armor: 338, mech_id: 1, total_tons: 50, weight_class: 'Medium') }
7
+ let (:com3a) { an_object_having_attributes(name: 'com-3a', max_armor: 178, mech_id: 6, total_tons: 25, weight_class: 'Light') }
7
8
  it "returns a collection of mechs collection" do
8
9
  expect(subject).to_not be_empty
9
10
  expect(subject).to include(an_instance_of(described_class))
10
- expect(subject).to include(hbk4g)
11
+ expect(subject).to include(hbk4g, com3a)
12
+ end
13
+ end
14
+
15
+ describe 'Weight class scoping', vcr: {cassette_name: 'all_mechs'} do
16
+ let(:light_mech) {an_object_having_attributes(weight_class: 'Light')}
17
+ let(:medium_mech) {an_object_having_attributes(weight_class: 'Medium')}
18
+ let(:heavy_mech) {an_object_having_attributes(weight_class: 'Heavy')}
19
+ let(:assault_mech) {an_object_having_attributes(weight_class: 'Assault')}
20
+
21
+ describe '.light' do
22
+ subject {described_class.lights}
23
+ it { is_expected.to include(light_mech) }
24
+ it { is_expected.to_not include(medium_mech, heavy_mech, assault_mech) }
25
+ end
26
+
27
+ describe '.mediums' do
28
+ subject {described_class.mediums}
29
+ it { is_expected.to include(medium_mech) }
30
+ it { is_expected.to_not include(light_mech, heavy_mech, assault_mech) }
31
+ end
32
+
33
+ describe '.heavies' do
34
+ subject {described_class.heavies}
35
+ it { is_expected.to include(heavy_mech) }
36
+ it { is_expected.to_not include(light_mech, medium_mech, assault_mech) }
37
+ end
38
+
39
+ describe '.assaults' do
40
+ subject {described_class.assaults}
41
+ it { is_expected.to include(assault_mech) }
42
+ it { is_expected.to_not include(light_mech, medium_mech, heavy_mech) }
11
43
  end
12
44
  end
13
45
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mwo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Buddy Magsipoc