amazon-pricing 0.1.45 → 0.1.46

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWEyNTk2NzExMjdlZTFlZmI4NDBmODEwOWI2OGI3OTcyZWNlOTExZg==
4
+ OGUyODcyODBiMTVhNGUxNTY5MDgwMzdjODkxNGMwOGFmNGY0ODA4OA==
5
5
  data.tar.gz: !binary |-
6
- ZmIzYjBlMGU3ODI0OGM1MmI5MDRhZjY0Y2YzMzRiYjhjYzUzZjI2Mw==
6
+ YjRlZjY1YWQ3YzVmZDgyN2EwZDE5N2Q3ZGRmMmFkYzJlZDA1NTA2Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NGYxNGI4ZGNjMmM4NDUwN2U5YzFkMTg3MDZmZjM3OTYwNGI4NzRhYWZkY2Ix
10
- NWY1Yjk1NGFmODYyZmFkNDg5YzExYjc2NjZlNDkxMTE4OTY4ODEyZWMzYzU5
11
- ZTlmZTZkMWY5OTIwNGI2ZmIyZTBlNWNlNjhlZjQ0OTZiN2M4NmE=
9
+ ZWEyYjkwYmFhNDU5Y2I0ZjI5ZGVjZWMxODI4YTllYmZmNWQ4MjRhMmNiY2Q4
10
+ ZTdlYzM5YzkyZGIyMWE5OGNkMTcxN2QwNGQ2NWNiZmYyNDQ0ZTAwN2RkNjYw
11
+ MDIyZGJkYmQ0ZjU1NWQ2NDkyNzhmOTFiZjZiZDU3ZTExNjJjMzI=
12
12
  data.tar.gz: !binary |-
13
- ZjcyYmUwNDczZTIzNThkZTZjOTgxYTdmY2VlZjZhOWJjOTNjNjlhZmNiMTMy
14
- NDQ0MzJmOWVlNmNkNGQxYTQ5Y2U5OTM2ZjNjODAyYzI1MDM1NWUzYTY3ODE2
15
- M2EwMmE5ZWE2NzQ4OWIzYjM2MWY2NDkxYjBlNTkwYzU0ZjczYTM=
13
+ MmE2ZTk3NzczODU1OTJjZmIxYmQ5NTYyNWEzNjEzNmE1MGRkY2I0MzZkOTNh
14
+ YTUxMTk4YzU1NjM0NGUzMWU2MTE2MGI3ZDQxYzVhN2ExODU2NTdkODQwMDIz
15
+ NjE3ZmM3NDkwYTY4ODMyYmQ0MGVjNjRkM2IyZjFlOTk1OTcwNmU=
@@ -52,7 +52,7 @@ module AwsPricing
52
52
  end
53
53
  end
54
54
 
55
- def update_pricing2(operating_system, type_of_instance, ondemand_pph = nil, year1_prepay = nil, year3_prepay = nil, year1_pph = nil, year3_pph = nil)
55
+ def update_pricing2(operating_system, res_type, ondemand_pph = nil, year1_prepay = nil, year3_prepay = nil, year1_pph = nil, year3_pph = nil)
56
56
 
57
57
  os = get_category_type(operating_system)
58
58
  if os.nil?
@@ -60,11 +60,11 @@ module AwsPricing
60
60
  @category_types[operating_system] = os
61
61
  end
62
62
 
63
- os.set_price_per_hour(type_of_instance, nil, coerce_price(ondemand_pph)) unless ondemand_pph.nil?
64
- os.set_prepay(type_of_instance, :year1, coerce_price(year1_prepay)) unless year1_prepay.nil?
65
- os.set_prepay(type_of_instance, :year3, coerce_price(year3_prepay)) unless year3_prepay.nil?
66
- os.set_price_per_hour(type_of_instance, :year1, coerce_price(year1_pph)) unless year1_pph.nil?
67
- os.set_price_per_hour(type_of_instance, :year3, coerce_price(year3_pph)) unless year3_pph.nil?
63
+ os.set_price_per_hour(res_type, nil, coerce_price(ondemand_pph)) unless ondemand_pph.nil?
64
+ os.set_prepay(res_type, :year1, coerce_price(year1_prepay)) unless year1_prepay.nil?
65
+ os.set_prepay(res_type, :year3, coerce_price(year3_prepay)) unless year3_prepay.nil?
66
+ os.set_price_per_hour(res_type, :year1, coerce_price(year1_pph)) unless year1_pph.nil?
67
+ os.set_price_per_hour(res_type, :year3, coerce_price(year3_pph)) unless year3_pph.nil?
68
68
  end
69
69
 
70
70
  # Maintained for backward compatibility reasons
@@ -88,5 +88,5 @@ module AwsPricing
88
88
  [api_name, name]
89
89
  end
90
90
 
91
- end
91
+ end
92
92
  end
@@ -8,5 +8,5 @@
8
8
  # Home:: http://github.com/CloudHealth/amazon-pricing
9
9
  #++
10
10
  module AwsPricing
11
- VERSION = '0.1.45'
11
+ VERSION = '0.1.46'
12
12
  end
@@ -19,23 +19,25 @@ module AwsPricing
19
19
  client = Mechanize.new
20
20
  page = client.get(GOV_CLOUD_URL)
21
21
  tables = page.search("//div[@class='aws-table ']")
22
- create_ondemand_instances(get_rows(tables[0]))
23
- create_ondemand_instances(get_rows(tables[1]))
22
+ for i in 0..3
23
+ create_ondemand_instances(tables[i])
24
+ end
24
25
 
25
- for i in 2..7
26
- create_reserved_instances(get_rows(tables[i]), :light)
26
+ for i in 4..9
27
+ create_reserved_instances(tables[i], :light)
27
28
  end
28
- for i in 8..13
29
- create_reserved_instances(get_rows(tables[i]), :medium)
29
+ for i in 9..22
30
+ create_reserved_instances(tables[i], :medium)
30
31
  end
31
- for i in 14..19
32
- create_reserved_instances(get_rows(tables[i]), :heavy)
32
+ for i in 23..33
33
+ create_reserved_instances(tables[i], :heavy)
33
34
  end
34
35
 
35
36
  end
36
37
 
37
38
  # e.g. [["Prices / Hour", "Amazon Linux", "RHEL", "SLES"], ["m1.small", "$0.053", "$0.083", "$0.083"]]
38
- def create_ondemand_instances(rows)
39
+ def create_ondemand_instances(table)
40
+ rows = get_rows(table)
39
41
  header = rows[0]
40
42
  @_regions.values.each do |region|
41
43
 
@@ -54,16 +56,17 @@ module AwsPricing
54
56
  end
55
57
 
56
58
  # e.g. [["RHEL", "1 yr Term Upfront", "1 yr TermHourly", "3 yr TermUpfront", "3 yr Term Hourly"], ["m1.small", "$68.00", "$0.099", "$105.00", "$0.098"]]
57
- def create_reserved_instances(rows, res_type)
58
- header = rows[0]
59
- operating_system = get_os(header[0])
59
+ def create_reserved_instances(table, res_type)
60
+ rows = get_rows(table)
61
+ operating_system = get_os(table.search(".//td/p").last.inner_text.strip) # Wow...
62
+
60
63
  @_regions.values.each do |region|
61
64
 
62
65
  rows.slice(1, rows.size).each do |row|
63
66
  api_name = row[0]
64
67
  instance_type = region.get_instance_type(api_name)
65
68
  if instance_type.nil?
66
- api_name, name = Ec2InstanceType.get_name(nil, row[0], true)
69
+ api_name, name = Ec2InstanceType.get_name(nil, api_name, true)
67
70
  instance_type = region.add_or_update_ec2_instance_type(api_name, name)
68
71
  end
69
72
  instance_type.update_pricing2(operating_system, res_type, nil, row[1], row[3], row[2], row[4])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-pricing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.45
4
+ version: 0.1.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Kinsella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby library for retrieving pricing for Amazon Web Services
14
14
  email: