apidragon 1.4.6 → 1.5.0

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: 596bb96c65ed9bbfcccc2003662443147d9346e4
4
- data.tar.gz: 4dfa61084e4c32fb25fd7207938673ce905c3463
3
+ metadata.gz: 1e0f39b383c33aa089b2dfec841bb0c1fbccab02
4
+ data.tar.gz: 722bb336398f57a3aa589ead8134b657a2981c2d
5
5
  SHA512:
6
- metadata.gz: cc58de1f39c0314fd3668a0e1b74421bf4784156d0f6a9aea5007d19b63396246ebfe399373cf5717860fc02d3ed31705005a40c654fdac9d14349718c35723b
7
- data.tar.gz: 25ccf6a2c14cc602343a00a557a640561a74e5ae459cd38ed9729e5438a84781acc02e0dde3f29efb9264c955d06b50d1e5586b3cd9211b0eb9767e0bd64d2cc
6
+ metadata.gz: 933e6b5c0377f74690915af568f781f2f2891f10b6ee367d869e318444c7421fcaaf0aa5402999f26d48d68ba792bfc1797658b743753d661f45d2f36f0a08f2
7
+ data.tar.gz: 64b0793f3aa9c7475391e9f58384c07dfd687d957c6264e9c3258be213f1c9bedfc9942370eaf4264d3239978616136be0d423ca15861af99b3e2db1a099ea8e
data/README.md CHANGED
@@ -17,6 +17,8 @@ These classes run a sequence of API calls using a configuration file.
17
17
  `[command]` is the name of one of the `macros` defined in the config file. So if I was using the config in the example,
18
18
  I could run `apidragon do macro_1`, which would then call `testcall` and `testcall2` in the order specified.
19
19
  - You can specify your own config file path by running `apidragon do [command] --config [filepath]`
20
+ - You can specify you password or username from the command line with `apidragon do [command] --username [username] --password [password]` (recommended if you don't want to store credentials in a file)
21
+
20
22
  # Configuration:
21
23
  Create `/tmp/apidragonconf.yaml`. It can contain any variables you need to access the API you are using, as well as `macros`.
22
24
  - Example config:
@@ -99,6 +101,14 @@ Evaluates the given line of ruby code through `eval()`.
99
101
 
100
102
  # Further Options
101
103
 
104
+ ## stdout
105
+ Setting `stdout: true` for any call will ouput its response to STDOUT. Defaults to false.
106
+ - e.g.:
107
+ ```yaml
108
+ testcall:
109
+ stdout: true
110
+ ```
111
+
102
112
  ## record
103
113
  Each call can have a `record` option, where you can specify what output variables you want to record to your config.
104
114
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.6
1
+ 1.5.0
data/bin/apidragon CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'commander'
4
- require 'apidragon'
4
+ #require 'apidragon'
5
5
  require_relative '../lib/apidragon.rb'
6
6
 
7
7
  Commander.configure do
8
8
  program :name, 'apidragon'
9
- program :version, '1.4.5'
9
+ program :version, '1.5.0'
10
10
  program :description, 'CLI for automating api requests'
11
11
  program :help, 'Author', 'Isaiah Thiessen <isaiah.thiessen@telus.com>'
12
12
 
@@ -14,8 +14,10 @@ Commander.configure do
14
14
  c.syntax = 'apidragon do [options]'
15
15
  c.description = 'Run "apidragon do [command]" to run the specified "command" defined in the config file.'
16
16
  c.option '--config STRING', String, 'config file path'
17
+ c.option '--username STRING', String, 'pass your api username as an option'
18
+ c.option '--password STRING', String, 'pass your api password as an option'
17
19
  c.action do |args, options|
18
- api = Api.new args.first, options.config
20
+ api = Api.new args.first, options.config, options.username, options.password
19
21
  api.go
20
22
  end
21
23
  end
data/lib/apidragon/api.rb CHANGED
@@ -14,10 +14,12 @@ class Api < ArgBucket
14
14
  # All variables are dumped into a variable bucket (@arg_bucket)
15
15
  # so that they can be used as parameters for function calls.
16
16
 
17
- def initialize(macro_name, config)
17
+ def initialize(macro_name, config, username, password)
18
18
  @config_file = config
19
19
  `mkdir #{PLUGINS}` unless Dir.exist? PLUGINS
20
20
  @arg_bucket = {}
21
+ set 'username', username unless username.nil?
22
+ set 'password', password unless password.nil?
21
23
  @config = load_config @config_file
22
24
  import @config['vars']
23
25
  @macro = @config['macros'][macro_name]
@@ -35,7 +37,7 @@ class Api < ArgBucket
35
37
  @arg_bucket = call.run
36
38
  if !value['record'].nil?
37
39
  value['record'].each do |var|
38
- add_config_var var, get(var)
40
+ add_config_var var, get(var) unless var=='function'
39
41
  end
40
42
  end
41
43
  end
@@ -19,6 +19,7 @@ class Call < ArgBucket
19
19
  check_constraints
20
20
  @output = value['output']
21
21
  @logging = value['logging']
22
+ @stdout = value['stdout']
22
23
  set_call_args value['input'] unless value['input'].nil?
23
24
  end
24
25
 
@@ -61,7 +62,7 @@ class Call < ArgBucket
61
62
  @code = @response.code unless @response.is_a? String
62
63
  xml_to_json
63
64
  run_plugin_script unless @plugin.nil?
64
- log_response unless @logging == false
65
+ log_response unless @logging == 'true'
65
66
  parse_response unless @output.nil?
66
67
  end
67
68
  return @arg_bucket
@@ -104,6 +105,7 @@ class Call < ArgBucket
104
105
 
105
106
  def parse_response
106
107
  @response = JSON.parse @response
108
+ if @stdout==true then puts JSON.pretty_generate @response end
107
109
  @output.each do |var|
108
110
  if var.is_a? String
109
111
  parser = Parser.new(var, nil, @response)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidragon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - isaiah thiessen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport