agent-s 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +3 -3
- data/agent.gemspec +2 -1
- data/bin/agent +91 -9
- data/lib/agent/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17971508b6e95224301422b309c25de2bb29b6aa
|
4
|
+
data.tar.gz: 59d690f6948c9abd3f9624b3d971beff94b3da51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59124aed60708dc3b1008d35711703e6e7ef3aed695369fdc5f045e43d9afc5551309e96773f5e7b208db2752d27358eb74d184636d9c48575976b0f041ce1c5
|
7
|
+
data.tar.gz: 8db2df11401a8d29d4fbbcbbba0e3e069c9cc34b763109a7f0264d043e7fec1a7565a96efb79942321a5df218348ef695a128f728420855137d6b104009babb1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,11 +11,11 @@ through the terminal.
|
|
11
11
|
* Displays JSON representaion of all/specific areas used in the ETM
|
12
12
|
* Displays simple/detailed JSON representation of any existing ETM Scenario
|
13
13
|
* TODO - Create new ETM Scenarios and update with your own settings/parameters
|
14
|
-
* TODO - See a collection of 'My Scenarios' for easy reference/access
|
14
|
+
* TODO - See a collection of 'My Scenarios' you have created for easy reference/access
|
15
|
+
* TODO - Add your favourite scenarios from others to your 'My Scenarios' collection
|
15
16
|
|
16
17
|
### Getting Started #
|
17
18
|
|
18
19
|
TODO
|
19
|
-
* Install gem
|
20
|
-
* Bundle
|
20
|
+
* Install with `gem install agent-s`
|
21
21
|
* `agent help` for info on commands
|
data/agent.gemspec
CHANGED
@@ -7,7 +7,8 @@ spec = Gem::Specification.new do |s|
|
|
7
7
|
s.email = 'twilkinson573@gmail.com'
|
8
8
|
s.homepage = 'http://github.com/twilkinson573/agent'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
|
-
s.summary = 'Allows users to interact with the Energy Transition Model
|
10
|
+
s.summary = 'Allows users to interact with the Energy Transition Model
|
11
|
+
(et-model.com) through the terminal'
|
11
12
|
s.files = `git ls-files`.split("
|
12
13
|
")
|
13
14
|
s.require_paths << 'lib'
|
data/bin/agent
CHANGED
@@ -12,16 +12,18 @@ version Agent::VERSION
|
|
12
12
|
subcommand_option_handling :normal
|
13
13
|
arguments :strict
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
# TODO Set global config author variable
|
16
|
+
# TODO Set glabal 'my scenarios' array/yml file etc
|
17
|
+
|
18
|
+
|
19
|
+
desc 'Lists all parameters of each market defined in the ETM'
|
20
|
+
arg_name 'area_code(OPTIONAL)'
|
17
21
|
command :areas do |c|
|
18
22
|
c.action do |global_options,options,args|
|
19
23
|
unless args.empty?
|
20
|
-
areas = %x(curl
|
21
|
-
areas = '{' + areas.split('{', 2).last
|
24
|
+
areas = %x(curl http://et-engine.com/api/v3/areas/"#{ args.first }")
|
22
25
|
else
|
23
|
-
areas = %x(curl
|
24
|
-
areas = "[" + areas.split('[').last
|
26
|
+
areas = %x(curl http://et-engine.com/api/v3/areas/)
|
25
27
|
end
|
26
28
|
|
27
29
|
puts JSON.pretty_generate(JSON.parse(areas))
|
@@ -38,15 +40,95 @@ command :show do |c|
|
|
38
40
|
c.action do |global_options,options,args|
|
39
41
|
exit_now!('id is required') if args.empty?
|
40
42
|
if options[:d]
|
41
|
-
scenario = %x(curl
|
43
|
+
scenario = %x(curl http://et-engine.com/api/v3/scenarios/"#{ args.first }"?detailed=true)
|
42
44
|
else
|
43
|
-
scenario = %x(curl
|
45
|
+
scenario = %x(curl http://et-engine.com/api/v3/scenarios/"#{ args.first }")
|
44
46
|
end
|
45
|
-
scenario = '{' + scenario.split('{', 2).last
|
46
47
|
puts JSON.pretty_generate(JSON.parse(scenario))
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
51
|
+
desc 'Creates a new ETM scenario'
|
52
|
+
command :create do |c|
|
53
|
+
c.action do |global_options,options,args|
|
54
|
+
|
55
|
+
puts 'New scenario'
|
56
|
+
puts 'Enter title:'
|
57
|
+
title = STDIN.gets.chomp
|
58
|
+
|
59
|
+
puts 'Starting Template: (leave blank to start from base scenario)'
|
60
|
+
template = STDIN.gets.chomp
|
61
|
+
if template.length == 0
|
62
|
+
puts 'Enter area code (default NL):'
|
63
|
+
area_code = STDIN.gets.chomp.downcase
|
64
|
+
%w(uk eu de pl fr es).include?(area_code) ? area_code : area_code = 'nl'
|
65
|
+
|
66
|
+
puts 'Enter end year (default 2030):'
|
67
|
+
end_year = STDIN.gets.chomp
|
68
|
+
end_year.to_i.between?(1900,3000) ? end_year : end_year = '2030'
|
69
|
+
|
70
|
+
%x(curl -i -X POST -H "Content-Type: application/json" -d '{"scenario":
|
71
|
+
{"title": "#{ title }", "area_code": "#{ area_code }",
|
72
|
+
"end_year": "#{ end_year }", "source": "agent"}}' http://et-engine.com/api/v3/scenarios)
|
73
|
+
else
|
74
|
+
|
75
|
+
template_data = JSON.parse(%x(curl http://et-engine.com/api/v3/scenarios/"#{ template }"))
|
76
|
+
|
77
|
+
%x(curl -i -X POST -H "Content-Type: application/json" -d '{"scenario":
|
78
|
+
{"title": "#{ title } -- Template: #{ template_data['title'] }", "area_code": "#{ template_data['area_code'] }",
|
79
|
+
"end_year": "#{ template_data['end_year'] }", "template": "#{ template }",
|
80
|
+
"source": "agent"}}' http://et-engine.com/api/v3/scenarios)
|
81
|
+
end
|
82
|
+
puts "Scenario #{ title} created"
|
83
|
+
|
84
|
+
# return scenario and URL
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#desc 'Update meta-data on an existing ETM scenario'
|
89
|
+
#arg_name 'scenario_id'
|
90
|
+
#arg_name 'update_key:value (e.g. end_year:2050)'
|
91
|
+
#command :update do |c|
|
92
|
+
# c.action do |global_options,options,args|
|
93
|
+
# exit_now!('id is required') if args.empty?
|
94
|
+
# exit_now!('at least one update_key:value is required (e.g. "end_year:2050")') if args.length == 1
|
95
|
+
#
|
96
|
+
# formatted_args = Hash[*args[1..-1].map{ |p| p.split(':') }.flatten].to_s.gsub('=>',': ')
|
97
|
+
# puts formatted_args
|
98
|
+
# update_params = %{ { "scenario": #{ formatted_args } } }
|
99
|
+
# puts update_params
|
100
|
+
#
|
101
|
+
## %x(curl -i -X PUT -H "Content-Type: application/json" -d '{"scenario": {"title": "Test scenario", "end_year": "2030"}}' http://et-engine.com/api/v3/scenarios/"#{ args.first }")
|
102
|
+
#
|
103
|
+
# s = %x(curl -i -X PUT -H "Content-Type: application/json" -d
|
104
|
+
# '%{ update_params }' http://et-engine.com/api/v3/scenarios/"#{ args.first }")
|
105
|
+
# #scenario = %x(curl -i -X PUT -H "Content-Type: application/json" -d '{"scenario": #{ update_params }' http://et-engine.com/api/v3/scenarios/#{ args.first })
|
106
|
+
# puts s
|
107
|
+
# end
|
108
|
+
#end
|
109
|
+
|
110
|
+
desc 'Lists all available inputs users can use to shape scenarios'
|
111
|
+
arg_name 'input_name(OPTIONAL)'
|
112
|
+
command :inputs do |c|
|
113
|
+
c.action do |global_options,options,args|
|
114
|
+
unless args.empty?
|
115
|
+
inputs = %x(curl http://et-engine.com/api/v3/inputs/"#{ args.first }")
|
116
|
+
else
|
117
|
+
inputs = %x(curl http://et-engine.com/api/v3/inputs/)
|
118
|
+
end
|
119
|
+
puts JSON.pretty_generate(JSON.parse(inputs))
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
desc 'Lists each available template users can use as a starting point for their scenarios'
|
124
|
+
command :templates do |c|
|
125
|
+
c.action do |global_options,options,args|
|
126
|
+
templates = %x(curl http://et-engine.com/api/v3/scenarios/templates)
|
127
|
+
|
128
|
+
puts JSON.pretty_generate(JSON.parse(templates))
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
50
132
|
pre do |global,command,options,args|
|
51
133
|
# Pre logic here
|
52
134
|
# Return true to proceed; false to abort and not call the
|
data/lib/agent/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agent-s
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Wilkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -110,5 +110,6 @@ rubyforge_project:
|
|
110
110
|
rubygems_version: 2.4.1
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
|
-
summary: Allows users to interact with the Energy Transition Model
|
113
|
+
summary: Allows users to interact with the Energy Transition Model (et-model.com)
|
114
|
+
through the terminal
|
114
115
|
test_files: []
|