aws-ec2-instance_types 1.0.3 → 1.0.4

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
- NTYxZTFlM2U5MWMyMDNhZjNmM2M5MjhmODcxYWQ2Yzk2MTkxYjkzNQ==
4
+ OGEyNTViMmMxZDgwMDMyZjExMTA2YjgwZWRmYjAwMTY0MGVhYjgwYg==
5
5
  data.tar.gz: !binary |-
6
- OTdmY2EyNTRkNWE4Y2JlOTE3OTJjZDA1Y2FkNTNjMTUwMzQ1Yjk5OA==
6
+ NGFiZjM3MmM5NTlmOWE2NmRlYmRiYWMwOThlMGEyYmQ0ZTU3YTVkMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWFiZWFjMzI0YzZkNTkzZTljNWQ1MWQ4MzhkNjA4ODE3ZDMzNmVkZWRhZjli
10
- NDgxZTgyZTkzOTIxNzI5YTMyZDdlM2NiMmM0MGVkYTc2Y2RjYTk3MzM0NTY4
11
- MzllNTcyNzA5NDk3ZjRlZjc3NTNkMGRjODNhNmU0MGIwNjMxNDU=
9
+ MjU1YTA2Mjg4M2IwMjU1OTBmZDkyMGFmMmNhZTc3NzFhNGQ2MzNmYWE2YWI4
10
+ YzNhNTczNTcwMjAxMjZhMzZmYTRlNDM3Y2Q0NGEwZmNmOWRlYTg4ZWY4ZGZl
11
+ OGQ0Y2E5NWMzMzU3ZmEzNDk5MDM5YWVmMzJmNDQzNjk3MTBlYjE=
12
12
  data.tar.gz: !binary |-
13
- MjRlZjY0NDg0OWU3YzNjNzk2NzEzYjg1YmU3NzU0MTUxNjAzN2E2ZmUzMTNm
14
- M2MwMDBiZTIzOTAzZWM2YTE5ZDhiODE0NWUxZTk5OTEwOGVjNjJmNzllZmQx
15
- OGMzOTk1MzRkM2IwYjQ4OGU2NTJhMjYzMWE3MTI4MDFlMzU3Mjc=
13
+ MGY1NmFhYzliYTZhMTdlOWIwOTU2ZjI0M2NlODljNjMxNGM3ZDUzYWI3MjY2
14
+ OWY3MTI5NDdiZDIxYThkZjdhNzk1MTI3YzYwNGU1OGFlZDE0MGE5MzIwZTE1
15
+ MWJjM2RkNDk2MGMyYWViY2Q0MDA1M2I1MzVlM2ZiODFhNGMwNzY=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.4
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: aws-ec2-instance_types 1.0.3 ruby lib
5
+ # stub: aws-ec2-instance_types 1.0.4 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "aws-ec2-instance_types"
9
- s.version = "1.0.3"
9
+ s.version = "1.0.4"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Christo De Lange"]
@@ -16,7 +16,7 @@ require "awesome_print"
16
16
  require "colorize"
17
17
 
18
18
  begin
19
- puts getInstanceTypes(:mechanize => mechanize).ai
19
+ puts getInstanceTypes(:mechanize => mechanize)[:instance_type_details].ai
20
20
  rescue Timeout::Error => e
21
21
  puts "Unable to retrieve instance type details in a reasonable time (#{mechanize.open_timeout}s). Giving up ...".light_red
22
22
  end
@@ -1,6 +1,7 @@
1
1
  module DLDInternet
2
2
  module AWS
3
3
  module EC2
4
+ class Error < StandardError ; end
4
5
  HEADINGS = [
5
6
  :instance_family, # [0]
6
7
  :instance_type, # [1]
@@ -12,9 +13,22 @@ module DLDInternet
12
13
  :EBS_optimized_available, # [7]
13
14
  :network_performance # [8]
14
15
  ]
16
+ HEADINGS_CPU = [
17
+ :instance_family, # [0]
18
+ :instance_type, # [1]
19
+ :processor_arch, # [2]
20
+ :vCPU, # [3]
21
+ :ECU, # [4]
22
+ :physical_processor, # [5]
23
+ :Intel_AES_NI, # [6]
24
+ :Intel_AVX, # [7]
25
+ :Intel_Turbo, # [8]
26
+
27
+ ]
15
28
 
16
29
  attr_reader :instance_types
17
30
 
31
+ # ---------------------------------------------------------------------------------------------------------------
18
32
  def getInstanceTypes(options={})
19
33
  unless @instance_types
20
34
  @instance_types = {}
@@ -30,34 +44,43 @@ module DLDInternet
30
44
 
31
45
  require "nokogiri"
32
46
  nk = Nokogiri::HTML(page.body)
33
- table = nk.css("div#yui-main div.yui-b table")
34
- raise AWSEC2Error.new "Cannot find instance type table" unless table.is_a?(Nokogiri::XML::NodeSet)
35
- rows = table.search('tr')[0..-1]
36
- head = rows.shift
47
+ div = nk.css("div#yui-main div.yui-b")
48
+ tables = div.search('table')
37
49
 
38
- cols = head.search('td').collect { |td|
39
- text = td.text.to_s
40
- text = text.gsub(%r/(\r?\n)+/, ' ').strip
41
- CGI.unescapeHTML(text)
42
- }
50
+ @instance_types[:instance_type_details] = scrapeTable(HEADINGS, tables[0])
51
+ @instance_types[:processor_details] = scrapeTable(HEADINGS_CPU, tables[1])
52
+ end
53
+ @instance_types
54
+ end
43
55
 
44
- @instance_types[:headings] = {}
45
- (0..cols.size-1).map{|i| @instance_types[:headings][HEADINGS[i]] = cols[i] }
56
+ # ---------------------------------------------------------------------------------------------------------------
57
+ def scrapeTable(cHeadings,table)
58
+ raise Error.new "Cannot find instance type table" unless table.is_a?(Nokogiri::XML::Element)
59
+ rows = table.search('tr')[0..-1]
60
+ head = rows.shift
46
61
 
47
- @instance_types[:details] = []
48
- rows.each do |row|
62
+ cols = head.search('td').collect { |td|
63
+ text = td.text.to_s
64
+ text = text.gsub(%r/(\r?\n)+/, ' ').strip
65
+ CGI.unescapeHTML(text)
66
+ }
67
+ instance_types = {
68
+ :headings => {},
69
+ :details => []
70
+ }
71
+ (0..cols.size-1).map { |i| instance_types[:headings][cHeadings[i]] = cols[i] }
49
72
 
50
- cells = row.search('td').collect { |td|
51
- CGI.unescapeHTML(td.text.to_s.gsub(%r/(\r?\n)+/, ' ').strip.gsub('32-bit or64-bit', '32-bit or 64-bit'))
52
- }
53
- raise StandardError.new "This row does not have the same number of cells as the table header: #{row.text.to_s.strip}" unless cells.size == cols.size
54
- instance = {}
55
- (0..cells.size-1).map{|i| instance[HEADINGS[i]] = cells[i] }
56
- @instance_types[:details] << instance
73
+ rows.each do |row|
57
74
 
58
- end
75
+ cells = row.search('td').collect { |td|
76
+ CGI.unescapeHTML(td.text.to_s.gsub(%r/(\r?\n)+/, ' ').strip.gsub('32-bit or64-bit', '32-bit or 64-bit'))
77
+ }
78
+ raise StandardError.new "This row does not have the same number of cells as the table header: #{row.text.to_s.strip}" unless cells.size == cols.size
79
+ instance = {}
80
+ (0..cells.size-1).map { |i| instance[cHeadings[i]] = cells[i] }
81
+ instance_types[:details] << instance
59
82
  end
60
- @instance_types
83
+ instance_types
61
84
  end
62
85
  end
63
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-ec2-instance_types
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christo De Lange