vscripts 0.0.1 → 0.0.2

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: 0d38d36783f6824793b72877c41ed04da154c492
4
- data.tar.gz: e16339dde0ebe97ccba08c2698713a04b9f73431
3
+ metadata.gz: 284b7ce118690580cd9971867304a34b6c488446
4
+ data.tar.gz: cf23021865d435cc5e18925343ab3bb6fa06e743
5
5
  SHA512:
6
- metadata.gz: ffb1d84f8a7c17162fa951b115579ac862503fda12662380db96d06af0afae7ed494d13ec6657cbf454efced85aa04eba5c6e5afe710547fd0033896e4a50668
7
- data.tar.gz: 96f561e9331fbcf87a3738c46fea0729a642a8bcf6c2d55b5fcbc70dedab1aa3759a031a7ddcb353c6e23afa873e0f8eaa045ded9579ea4ca911218431533857
6
+ metadata.gz: 4dc8f5dc252f51cd35d1b5d2a5f9b167426f801a2fa6e677bf19c391d9e7907aa13005e83372a82dc269daac167962d1ce1b964a1fd1dfc0a580ba50a7662ba4
7
+ data.tar.gz: 298543beafca0f797fe2a0702a882fe249edce68887f7ca4dc53df6c42ef2953929dab90d10b65c27fcfa271b600172c4c680fdf757810e97549c7b250c4d4f6
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ /TODO
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.0.2
2
+ ---
3
+ * Fix command line options ([Vlad - efa8c95](https://github.com/vghn/vscripts/commit/efa8c959176da8ca95f13ef4433eb7468ecfaea8))
4
+ * Minor fixes ([Vlad - b3cecf1](https://github.com/vghn/vscripts/commit/b3cecf14a614ce561e98345378c4cfc25f9b0c44))
5
+
1
6
  Version 0.0.1
2
7
  ---
3
8
  * Create gem structure ([Vlad - 635a06d](https://github.com/vghn/vscripts/commit/635a06d33fab5e8dbee39991ffc1e7bbf4ef4e6f))
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # VScripts
2
2
  [![Build Status](https://travis-ci.org/vghn/vscripts.svg?branch=master)](https://travis-ci.org/vghn/vscripts)
3
3
  [![Code Climate](https://codeclimate.com/github/vghn/vscripts.png)](https://codeclimate.com/github/vghn/vscripts)
4
+ [![Gem Version](https://badge.fury.io/rb/vscripts.svg)](http://badge.fury.io/rb/vscripts)
4
5
 
5
6
  Automation daemon.
6
7
 
@@ -23,14 +24,14 @@ vscripts GLOBAL-OPTIONS COMMAND OPTIONS
23
24
  ```
24
25
 
25
26
 
26
- ### Global Options:
27
+ ### Global Options
27
28
  ```
28
29
  -h|--help: Displays VScripts help.
29
30
  -v|--version: Displays the version number.
30
31
  ```
31
32
 
32
33
 
33
- ### Commands:
34
+ ### Commands
34
35
 
35
36
  1. **Tags2Facts**
36
37
  This command can only be run on an AWS EC2 instance. It looks for all tags
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/lib/vscripts.rb CHANGED
@@ -4,9 +4,9 @@ require 'vscripts/command_line'
4
4
  # Main VScripts module
5
5
  module VScripts
6
6
  # Gets the command name from command line and calls the right class.
7
- def self.run(*args)
8
- cli = CommandLine.new(*args)
9
- command = VScripts::Commands.const_get(cli.command).new(*cli.extra)
7
+ def self.run(argv)
8
+ cli = CommandLine.new(argv)
9
+ command = VScripts::Commands.const_get(cli.command).new(cli.arguments)
10
10
  command.execute
11
11
  end
12
12
  end # module VScripts
@@ -4,32 +4,32 @@ require 'vscripts/command'
4
4
  module VScripts
5
5
  # Global Command Line
6
6
  class CommandLine
7
+ # @return [Array] All the command line arguments
8
+ attr_accessor :arguments
7
9
  # @return [Hash] Global command line arguments
8
10
  attr_reader :global
9
11
  # @return [String] Command name
10
12
  attr_reader :command
11
- # @return [Array] Extra arguments passed to the command
12
- attr_reader :extra
13
13
 
14
14
  # Build command line arguments
15
- def initialize(*args)
16
- @global ||= parse(*args)
17
- @command ||= check_command(*args)
18
- @extra ||= rest(*args)
15
+ def initialize(argv = [])
16
+ @arguments ||= argv
17
+ @global ||= parse_cli_options
18
+ @command ||= verify_command
19
19
  end
20
20
 
21
21
  # Specifies command line options
22
22
  # This method smells of :reek:NestedIterators but ignores them
23
23
  # This method smells of :reek:TooManyStatements but ignores them
24
24
  def parser # rubocop:disable MethodLength
25
- available = Command.list
26
- Trollop::Parser.new do
25
+ available = Command.list.map { |cmd| cmd.to_s.downcase }
26
+ @parser ||= Trollop::Parser.new do
27
27
  version VScripts::VERSION_C
28
28
  banner <<-EOS
29
29
  VScripts automation daemon.
30
30
 
31
31
  Available commands:
32
- #{available.map { |cmd| cmd.to_s.downcase }}
32
+ #{available}
33
33
 
34
34
  Usage:
35
35
  vscripts GLOBAL-OPTIONS COMMAND OPTIONS
@@ -44,29 +44,23 @@ EOS
44
44
  end
45
45
 
46
46
  # Parses command line arguments
47
- def parse(*args)
47
+ def parse_cli_options
48
48
  Trollop.with_standard_exception_handling parser do
49
- fail Trollop::HelpNeeded if args.empty?
50
- parser.parse args
49
+ fail Trollop::HelpNeeded if arguments.empty?
50
+ parser.parse arguments
51
51
  end
52
52
  end
53
53
 
54
54
  # Ensure command is available
55
55
  # @return [String] Command name
56
- def check_command(args)
57
- command_cli = args.shift
56
+ def verify_command
57
+ command_cli = arguments.shift
58
58
  command_cls = command_cli.capitalize.to_sym
59
- if command_cli && Command.list.include?(command_cls)
59
+ if Command.list.include?(command_cls)
60
60
  return command_cls
61
61
  else
62
- puts "Error: Unknown subcommand '#{command_cli}'\nTry --help for help."
63
- exit 1
62
+ abort "Error: Unknown subcommand '#{command_cli}'\nTry --help."
64
63
  end
65
64
  end
66
-
67
- # @return [Array] The rest of the arguments
68
- def rest(args)
69
- args
70
- end
71
65
  end # class CommandLine
72
66
  end # module VScripts
@@ -29,13 +29,13 @@ module VScripts
29
29
  Options:
30
30
  EOS
31
31
 
32
- # @return [Hash] Command specific arguments
33
- attr_reader :cli
32
+ # @return [Array] Command specific arguments
33
+ attr_reader :arguments
34
34
  # @return [AWS::EC2] EC2 SDK
35
35
  attr_reader :ec2
36
36
 
37
- def initialize(*args)
38
- @cli ||= parse(*args)
37
+ def initialize(argv = [])
38
+ @arguments ||= argv
39
39
  @ec2 ||= VScripts::AWS::EC2.new
40
40
  end
41
41
 
@@ -51,9 +51,9 @@ module VScripts
51
51
  end
52
52
 
53
53
  # Parses command line arguments
54
- def parse(*args)
55
- Trollop.with_standard_exception_handling parser do
56
- parser.parse args
54
+ def cli
55
+ @cli ||= Trollop.with_standard_exception_handling parser do
56
+ parser.parse arguments
57
57
  end
58
58
  end
59
59
 
@@ -27,8 +27,8 @@ describe VScripts::CommandLine do
27
27
 
28
28
  describe '#extra' do
29
29
  it 'returns the rest of the arguments as an Array' do
30
- expect(@cli.extra).to be_an_instance_of Array
31
- expect(@cli.extra).to eql ['extra_args']
30
+ expect(@cli.arguments).to be_an_instance_of Array
31
+ expect(@cli.arguments).to eql ['extra_args']
32
32
  end
33
33
  end
34
34
  end
data/tasks/deploy.rake CHANGED
@@ -1,4 +1,4 @@
1
- DEV_BRANCH = 'develop'
1
+ DEV_BRANCH = 'development'
2
2
  LOG_RANGE = "master...#{DEV_BRANCH}"
3
3
  VERSION_FILE = 'VERSION'
4
4
  CHANGELOG_FILE = 'CHANGELOG.md'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vscripts
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
  - Vlad Ghinea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-22 00:00:00.000000000 Z
11
+ date: 2014-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk