aws-rikanjo 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db2d3d01c61253d1f8db3b929ed67d9a93109e28
4
- data.tar.gz: 78ca9a220637d4d719eea99fea9a4c7ca9f62d61
3
+ metadata.gz: daa77e004f4b668aef3d910d5b129efeb540e5ae
4
+ data.tar.gz: 481daec3b7273fbdc99fb4d88727a89dd4ecbbc2
5
5
  SHA512:
6
- metadata.gz: d83cb8bf705f0696673e4327266cc1dfb3c02899818ad537ff93b5ba0a44bcd9ac45a798cd45a6ed2fa248dfa8ab7504839b41d132f55dac0978a8cc9381deb4
7
- data.tar.gz: e1681fb5fbb41a63f5c86758e40cc43a09be31f7524a7b68370d66166058269e7181162c3c21f91ce2d9e7e8bc9656c4061cf783adbdb89f65ac8cbb19f4d5cf
6
+ metadata.gz: a50d3161f154d7e08793b58d58dd64aba54ebbc2c90b6c1d1d6ac0b2c6290c477b5a502d9edf3d9698c77e776fb3d36a0f078e90101c70e5685d7f6c5a407de8
7
+ data.tar.gz: 9649d72be60061a381a4e2559d4d5d9509d14b96a83631ed50ed16bbc3d8a58248b8da1d6cdbbeff9cc36cc82cadc64d77e35f9fc92c36592b75534c2b68482a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Aws::Rikanjo
2
2
 
3
- RI Cost Calc Tool.
3
+ RI Cost Calc Tool( Only new price ).
4
4
 
5
5
  ## Installation
6
6
 
@@ -21,9 +21,9 @@ Or install it yourself as:
21
21
  example
22
22
 
23
23
  ```
24
- require "./aws-rikanjo/lib/aws/rikanjo"
24
+ require "aws/rikanjo"
25
25
 
26
- a = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m1.large", ri_util = "light")
26
+ a = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m3.large", ri_util = "medium")
27
27
  a.total_cost_year
28
28
 
29
29
  # "region" : ap-northeast-1
@@ -36,7 +36,7 @@ a.total_cost_year
36
36
  # "reserved year price (doller)" : 2074.56
37
37
  # "reserved upfront (doller)" : 270
38
38
  # "sweet spot day (day)" : 78
39
- # "sweet spot date (date)" : 2014-07-16
39
+ # "sweet spot date (date)" : 2014-07-17
40
40
  # "sweet spot price (doller)" : 660.58
41
41
  ```
42
42
 
data/aws-rikanjo.gemspec CHANGED
@@ -5,7 +5,7 @@ require 'aws/rikanjo/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "aws-rikanjo"
8
- spec.version = "0.0.1"
8
+ spec.version = "0.0.2"
9
9
  spec.authors = ["kenjiskywalker"]
10
10
  spec.email = ["git@kenjiskywalker.org"]
11
11
  spec.description = %q{AWS RI Cost Calc Tool}
@@ -1,5 +1,5 @@
1
1
  module Aws
2
2
  module Rikanjo
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/lib/aws/rikanjo.rb CHANGED
@@ -40,25 +40,25 @@ module Aws
40
40
  end
41
41
 
42
42
  # TODO: merge om and ri
43
- uri = URI.parse('http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/ec2/linux-od.js')
43
+ uri = URI.parse('http://a0.awsstatic.com/pricing/1/ec2/linux-od.min.js')
44
44
  Net::HTTP.start(uri.host, uri.port) do |http|
45
45
  response = http.get(uri.request_uri)
46
46
  json = response.body
47
47
  end
48
48
 
49
49
  # parse
50
- json = json.gsub(/^callback\(\n /,'').gsub(/\n\)/, '')
51
- ondemandjson_data = Yajl::Parser.parse(json)
50
+ json = json.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({vers:0.01,",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
51
+ ondemand_json_data = Yajl::Parser.parse(json)
52
52
 
53
53
  # select 'region' and 'instance_type'
54
- ondemandjson_data["config"]["regions"].each do |r|
54
+ ondemand_json_data["config"]["regions"].each do |r|
55
55
  # r = {"region"=>"us-east", "instanceTypes"=>[{"type"=>"generalCurrentGen", ...
56
56
  next unless r["region"] == region
57
57
  r["instanceTypes"].each do |type|
58
58
  # type = {"type"=>"generalCurrentGen", "sizes"=>[{"size"=>"m3.medium", "vCPU"=>"1" ...
59
59
  type["sizes"].each do |i|
60
60
  next unless i["size"] == instance_type
61
- @om_info = {:hr_price => i["valueColumns"][0]["prices"]["USD"] }
61
+ @om_info = {:hr_price => i["valueColumns"][0]["prices"]["USD"]}
62
62
  end
63
63
  end
64
64
  end
@@ -97,13 +97,13 @@ module Aws
97
97
  json = nil
98
98
  reservedjson_data = nil
99
99
 
100
- uri = URI.parse("http://aws-assets-pricing-prod.s3.amazonaws.com/pricing/ec2/linux-ri-#{ri_util}.js")
100
+ uri = URI.parse("http://a0.awsstatic.com/pricing/1/ec2/linux-ri-#{ri_util}.min.js")
101
101
  Net::HTTP.start(uri.host, uri.port) do |http|
102
102
  response = http.get(uri.request_uri)
103
103
  json = response.body
104
104
  end
105
105
 
106
- json = json.gsub(/callback\(\n/,'').gsub(/\n\)/, '')
106
+ json = json.gsub("/*\n * This file is intended for use only on aws.amazon.com. We do not guarantee its availability or accuracy.\n *\n * Copyright 2014 Amazon.com, Inc. or its affiliates. All rights reserved.\n */\ncallback({vers:0.01,",'{').gsub("\);", '').gsub(/([a-zA-Z]+):/, '"\1":')
107
107
  reservedjson_data = Yajl::Parser.parse(json)
108
108
 
109
109
  reservedjson_data["config"]["regions"].each do |r|
@@ -157,7 +157,6 @@ module Aws
157
157
  # exp. @om_info = {:hr_price=>"0.350", :yr_price=>3066.0}
158
158
  # exp. @ri_info = {"ri_util"=>{:upfront=>"NNN", :hr_price=>"NNN",
159
159
  # :sweet_spot_price=>NNN, :sweet_spot_start_day=>78, :yr_price=>2074.56}}
160
-
161
160
  return @om_info, @ri_info
162
161
  end
163
162
 
@@ -185,9 +184,8 @@ module Aws
185
184
  end
186
185
  end
187
186
 
188
- # m = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m1.large", ri_util = "light")
187
+ # m = Aws::RiKanjoo.new(region = "ap-northeast-1", instance_type = "m3.large", ri_util = "medium")
189
188
  # m.total_cost_year
190
- #
191
189
  # "region" : ap-northeast-1
192
190
  # "instance_type" : m1.large
193
191
  # "ri_util" : light
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-rikanjo
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
  - kenjiskywalker