apidragon 1.3.0 → 1.4.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: e44b27d4c1f256b66c5b961033b08eacf4d5ac00
4
- data.tar.gz: d764e3b81b24c3217f0ba5985c290f4cf293d940
3
+ metadata.gz: dac7bab4ae3a2495da5282496c6ebc5c64f8d9ce
4
+ data.tar.gz: e78d579ee65e3d12c696a8960392b55b0416daba
5
5
  SHA512:
6
- metadata.gz: aa1cb300824858e9e4860483c16f511885ccb3501bba9f689dd3470e9258a6f55cf38b91f87f860f5b73d21a97265e63f6d256af71036ed3d0b94dd5000f4cf3
7
- data.tar.gz: 272087cb664a076c799a7e614001679c7027782ae0e8e5f4ccf289703ae89240cbeb2315dffb9d956398f2ef47e2334eef9625947b7bd6242f1015a8fdc7a90c
6
+ metadata.gz: f66d8cfee6c6e9b8f3fe6147d59823302ae4af20b409b60108d9d97e1e30ec832756f334d947f126bcb3bc0462c61ee0c3c5e84e8fb083abbef570ed7638e872
7
+ data.tar.gz: b690d4a98deeda9352b67dbd118e37fc560d768753f797aaa4caed1049478d85879dcaa133df0bd41e26fa537a244243bdf31aa4e869601a1ed7de4bf149bb51
data/bin/apidragon CHANGED
@@ -13,8 +13,9 @@ Commander.configure do
13
13
  command :do do |c|
14
14
  # c.syntax 'apidragon do'
15
15
  # c.description 'Runs the specified command, described in the config file.'
16
- c.action do |args|
17
- api = Api.new args.first
16
+ c.option '--config STRING', String, 'config file path'
17
+ c.action do |args, options|
18
+ api = Api.new args.first, options.config
18
19
  api.go
19
20
  end
20
21
  end
data/lib/apidragon/api.rb CHANGED
@@ -14,17 +14,17 @@ 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)
17
+ def initialize(macro_name, config=CONFIG)
18
18
  `mkdir #{PLUGINS}` unless Dir.exist? PLUGINS
19
19
  @arg_bucket = {}
20
- @config = load_config
20
+ @config = load_config config
21
21
  import @config['vars']
22
22
  @macro = @config['macros'][macro_name]
23
23
  if @macro.nil? then fail "Command: '#{macro_name}' is not defined." end
24
24
  end
25
25
 
26
- def load_config
27
- YAML.load_file CONFIG
26
+ def load_config(config)
27
+ YAML.load_file config
28
28
  end
29
29
 
30
30
  def go
@@ -0,0 +1,10 @@
1
+ ---
2
+ vars:
3
+ repo: /some/repo # define the repo location
4
+ directory: /some/directory/path # define the directory you want to clone to
5
+ macros:
6
+ myfirstmacro:
7
+ gitclone:
8
+ function: MyClass.new(@arg_bucket).run # instantiates MyClass with @arg_bucket (contains vars from config) and calls .run
9
+ mode: plugin
10
+ plugin: gitclone # causes the gitclone.rb file in /tmp/apidragonplugins/
@@ -0,0 +1,22 @@
1
+ require 'apidragon' # require the gem. you can use any gems you like!
2
+
3
+ class MyClass < ArgBucket # inherit from the ArgBucket class for the 'get' and 'set' methods on @arg_bucket
4
+ def initialize(args)
5
+ @arg_bucket = args
6
+ puts @arg_bucket
7
+ end
8
+
9
+ def run
10
+ directory = get 'directory'
11
+ repo_name = get 'repo'
12
+ repo = 'http://github.com/isand3r' << repo_name
13
+ puts repo
14
+ puts directory
15
+ if Dir.exist?(directory) && Dir.exist?("#{directory}/#{repo_name}/.git")
16
+ `cd #{directory}/#{repo_name}; git pull`
17
+ else
18
+ puts "cloning #{repo}"
19
+ `mkdir #{directory}; cd #{directory}; git clone #{repo}`
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apidragon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - isaiah thiessen
@@ -259,6 +259,8 @@ files:
259
259
  - lib/apidragon/log.rb
260
260
  - lib/apidragon/macro.rb
261
261
  - lib/apidragon/parser.rb
262
+ - plugin_examples/apidragonconf.yaml
263
+ - plugin_examples/gitclone.rb
262
264
  - test/helper.rb
263
265
  - test/test_apidragon.rb
264
266
  homepage: http://github.com/isand3r/apidragon