apidragon 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02988e4bc7afe49b1d090d3357b8d3ae6cfb0e72
4
- data.tar.gz: 0d2bda2cfc335092c8f51595c8cbdf198191466f
3
+ metadata.gz: acb768a3cd899d976484f3512f5980991c528119
4
+ data.tar.gz: 1d9fcba41c065e6b6b1c62b00aef7b69af90031f
5
5
  SHA512:
6
- metadata.gz: e826bb276936ac04a0f60b85eeff6f41e69ac3ef533f2cd259df39c1ac579fe67496bac9998a30e7a2571f79e4c5bc19b7340a9c5bb05a7fdf438559f71e3fb6
7
- data.tar.gz: 9c7595c4dea984f05b3b487d1281eace439e674986dc171bbf9a781a143316397adeb56112a4b9e706ce996f5ec4c0e0dfab3151d2d9044f8d96f8e373f1e7eb
6
+ metadata.gz: 81fc3a0bd3bef83826c3ca21c21e919e67b52c90480111585f688b92dff6fba42720d37d149115f632a2da72169ff416ab250c5d721abe7cc984a7056ed1d395
7
+ data.tar.gz: 58374a6e4d1740c0681ff3150624e7ff6e9e8f163e9af859e7087f75b136a47179d697b2ba0bf9ec646dbae21e5c57906df93f5a62195f202294698fb618093f
data/README.md CHANGED
@@ -53,7 +53,6 @@ Currently supported modes:
53
53
  - `put`
54
54
  - `delete`
55
55
  - `curl_get`, `curl_post` (uses curl instead of the `rest-client` gem for special cases)
56
- - `eval` (not yet stable)
57
56
  - Planned: `curl_put`, `curl_delete`
58
57
 
59
58
  # Further Options
@@ -92,9 +91,30 @@ For each call, set `logging` to `true` to enable or `false` to disable.
92
91
  logging: true
93
92
  ```
94
93
 
94
+ ## plugin
95
+ Each call can refer to a plugin file. The Plugin class should follow the structure outlined below.
96
+ - e.g.:
97
+ - example.rb (@ /tmp/apidragonplugins/)
98
+ ```ruby
99
+ class Plugin # class must be named Plugin
100
+ def initialize(message) # pass only one parameter, which will be equal to the body of the call's http response
101
+ @message = message
102
+ end
103
+
104
+ def run # main function must be named run and take no parameters. Run all your operations from here
105
+ puts @message
106
+ end
107
+ end
108
+ ```
109
+ ```yaml
110
+ testcall:
111
+ plugin: example #name of file minus .rb extension
112
+ ```
113
+
95
114
 
96
115
  # Planned Features
97
116
  - The ability to include custom scripts at the end of a call for extensibility
117
+ - Support for multiple instances of variable names for different api's
98
118
 
99
119
  #License
100
120
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.0
data/apidragon.gemspec CHANGED
@@ -2,16 +2,16 @@
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: apidragon 1.1.2 ruby lib
5
+ # stub: apidragon 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "apidragon"
9
- s.version = "1.1.2"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["isaiah thiessen"]
14
- s.date = "2015-11-30"
14
+ s.date = "2015-12-01"
15
15
  s.description = "Ruby based CLI for accessing veracode's api"
16
16
  s.email = "isaiah.thiessen@live.ca"
17
17
  s.executables = ["apidragon"]
data/lib/apidragon/api.rb CHANGED
@@ -13,7 +13,6 @@ class Api < ArgBucket
13
13
  # Uses the configuration data in config.yaml to run a sequence of api calls.
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
- attr_accessor :macro
17
16
 
18
17
  def initialize(macro_name)
19
18
  @arg_bucket = {}
@@ -6,7 +6,13 @@ class Call < ArgBucket
6
6
 
7
7
  def initialize(input, output, mode, function, args, logging=false, plugin=nil)
8
8
  @arg_bucket = args
9
- require_relative "#{PLUGINS}#{plugin}" unless plugin.nil?
9
+ @plugin = plugin
10
+ begin
11
+ require_relative "#{PLUGINS}#{plugin}" unless plugin.nil?
12
+ rescue LoadError
13
+ puts 'Plugin failed to load. Custom functions will not be run.'
14
+ @plugin = nil
15
+ end
10
16
  username = get 'username'
11
17
  password = get 'password'
12
18
  check_constraints mode, function
@@ -76,12 +82,21 @@ class Call < ArgBucket
76
82
  puts 'Internal Error or requested resource was not found.'
77
83
  end
78
84
  if !@response.nil?
85
+ run_plugin_script unless @plugin.nil?
79
86
  log_response unless @logging == false
80
87
  parse_response unless @output.nil?
81
88
  end
82
89
  return @arg_bucket
83
90
  end
84
91
 
92
+ def run_plugin_script
93
+ if !@response.is_a? String
94
+ custom = Plugin.new(@response.body).run
95
+ else
96
+ custom = Plugin.new(@response).run
97
+ end
98
+ end
99
+
85
100
  def log_response
86
101
  logger = ResponseLogger.new
87
102
  if !@response.is_a? String
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.1.2
4
+ version: 1.2.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-11-30 00:00:00.000000000 Z
11
+ date: 2015-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport