hobo-inviqa 0.0.4 → 0.0.6

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.
Files changed (55) hide show
  1. data/Gemfile.lock +27 -6
  2. data/README.md +1 -10
  3. data/bin/hobo +20 -0
  4. data/features/hobo/help.feature +5 -1
  5. data/hobo.gemspec +4 -0
  6. data/lib/hobo.rb +17 -14
  7. data/lib/hobo/asset_applicator.rb +16 -0
  8. data/lib/hobo/cli.rb +40 -20
  9. data/lib/hobo/config.rb +5 -0
  10. data/lib/hobo/config/file.rb +3 -1
  11. data/lib/hobo/errors.rb +8 -1
  12. data/lib/hobo/help_formatter.rb +8 -1
  13. data/lib/hobo/helper/file_locator.rb +8 -5
  14. data/lib/hobo/helper/shell.rb +12 -4
  15. data/lib/hobo/helper/vm_command.rb +67 -0
  16. data/lib/hobo/lib/host_check.rb +23 -0
  17. data/lib/hobo/lib/host_check/deps.rb +21 -0
  18. data/lib/hobo/lib/host_check/git.rb +52 -0
  19. data/lib/hobo/lib/host_check/ruby.rb +42 -0
  20. data/lib/hobo/lib/host_check/vagrant.rb +15 -0
  21. data/lib/hobo/lib/s3sync.rb +233 -0
  22. data/lib/hobo/lib/seed/project.rb +12 -0
  23. data/lib/hobo/lib/seed/seed.rb +19 -0
  24. data/lib/hobo/logging.rb +22 -0
  25. data/lib/hobo/metadata.rb +7 -1
  26. data/lib/hobo/null.rb +31 -0
  27. data/lib/hobo/patches/deepstruct.rb +23 -0
  28. data/lib/hobo/patches/rake.rb +14 -1
  29. data/lib/hobo/patches/slop.rb +11 -1
  30. data/lib/hobo/paths.rb +8 -3
  31. data/lib/hobo/tasks/assets.rb +96 -0
  32. data/lib/hobo/tasks/console.rb +18 -0
  33. data/lib/hobo/tasks/debug.rb +2 -2
  34. data/lib/hobo/tasks/deps.rb +1 -1
  35. data/lib/hobo/tasks/host.rb +17 -0
  36. data/lib/hobo/tasks/vm.rb +2 -2
  37. data/lib/hobo/ui.rb +21 -16
  38. data/lib/hobo/version.rb +1 -1
  39. data/spec/hobo/asset_applicator_spec.rb +31 -0
  40. data/spec/hobo/cli_spec.rb +115 -97
  41. data/spec/hobo/config/file_spec.rb +13 -3
  42. data/spec/hobo/help_formatter_spec.rb +50 -18
  43. data/spec/hobo/helpers/file_locator_spec.rb +5 -1
  44. data/spec/hobo/helpers/shell_spec.rb +15 -1
  45. data/spec/hobo/helpers/vm_command_spec.rb +85 -0
  46. data/spec/hobo/lib/s3sync_spec.rb +13 -0
  47. data/spec/hobo/lib/seed/project_spec.rb +7 -8
  48. data/spec/hobo/lib/seed/seed_spec.rb +3 -4
  49. data/spec/hobo/logging_spec.rb +28 -0
  50. data/spec/hobo/metadata_spec.rb +10 -0
  51. data/spec/hobo/null_spec.rb +31 -0
  52. data/spec/hobo/paths_spec.rb +6 -6
  53. data/spec/hobo/ui_spec.rb +4 -0
  54. metadata +93 -6
  55. data/features/vm.feature +0 -0
@@ -1,11 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hobo-inviqa (0.0.4)
4
+ hobo-inviqa (0.0.6)
5
+ aws-sdk (~> 1.34.0)
5
6
  bundler (~> 1.5.2)
7
+ deepstruct (~> 0.0.5)
6
8
  highline (~> 1.6.20)
7
9
  rake (~> 10.1.1)
8
10
  rake-hooks (~> 1.2.3)
11
+ ruby-progressbar (~> 1.4.1)
12
+ semantic (~> 1.3.0)
9
13
  slop (~> 3.4.7)
10
14
 
11
15
  GEM
@@ -15,10 +19,17 @@ GEM
15
19
  childprocess (>= 0.3.6)
16
20
  cucumber (>= 1.1.1)
17
21
  rspec-expectations (>= 2.7.0)
22
+ aws-sdk (1.34.0)
23
+ json (~> 1.4)
24
+ nokogiri (>= 1.4.4)
25
+ uuidtools (~> 2.1)
18
26
  builder (3.2.2)
19
27
  celluloid (0.15.2)
20
28
  timers (~> 1.1.0)
21
- childprocess (0.4.0)
29
+ celluloid-io (0.15.0)
30
+ celluloid (>= 0.15.0)
31
+ nio4r (>= 0.5.0)
32
+ childprocess (0.5.1)
22
33
  ffi (~> 1.0, >= 1.0.11)
23
34
  coderay (1.1.0)
24
35
  cucumber (1.3.10)
@@ -27,6 +38,7 @@ GEM
27
38
  gherkin (~> 2.12)
28
39
  multi_json (>= 1.7.5, < 2.0)
29
40
  multi_test (>= 0.0.2)
41
+ deepstruct (0.0.5)
30
42
  diff-lcs (1.2.5)
31
43
  fakefs (0.5.0)
32
44
  ffi (1.9.3)
@@ -42,18 +54,24 @@ GEM
42
54
  guard-cucumber (1.4.1)
43
55
  cucumber (>= 1.2.0)
44
56
  guard (>= 1.1.0)
45
- guard-rspec (4.2.5)
57
+ guard-rspec (4.2.6)
46
58
  guard (~> 2.1)
47
59
  rspec (>= 2.14, < 4.0)
48
60
  highline (1.6.20)
49
- listen (2.4.0)
61
+ json (1.8.1)
62
+ listen (2.5.0)
50
63
  celluloid (>= 0.15.2)
64
+ celluloid-io (>= 0.15.0)
51
65
  rb-fsevent (>= 0.9.3)
52
66
  rb-inotify (>= 0.9)
53
67
  lumberjack (1.0.4)
54
68
  method_source (0.8.2)
69
+ mini_portile (0.5.2)
55
70
  multi_json (1.8.4)
56
71
  multi_test (0.0.3)
72
+ nio4r (1.0.0)
73
+ nokogiri (1.6.1)
74
+ mini_portile (~> 0.5.0)
57
75
  pry (0.9.12.6)
58
76
  coderay (~> 1.0)
59
77
  method_source (~> 0.8)
@@ -70,12 +88,15 @@ GEM
70
88
  rspec-expectations (~> 2.14.0)
71
89
  rspec-mocks (~> 2.14.0)
72
90
  rspec-core (2.14.7)
73
- rspec-expectations (2.14.4)
91
+ rspec-expectations (2.14.5)
74
92
  diff-lcs (>= 1.1.3, < 2.0)
75
- rspec-mocks (2.14.4)
93
+ rspec-mocks (2.14.5)
94
+ ruby-progressbar (1.4.1)
95
+ semantic (1.3.0)
76
96
  slop (3.4.7)
77
97
  thor (0.18.1)
78
98
  timers (1.1.0)
99
+ uuidtools (2.1.4)
79
100
 
80
101
  PLATFORMS
81
102
  ruby
data/README.md CHANGED
@@ -50,16 +50,7 @@ hobo my-project download-files
50
50
  ```
51
51
 
52
52
  # Rake DSL enhancements
53
- This section is yet to be written; please see lib/hobo/patches/rake.rb and the internal tasks (for usage) under lib/hobo/tasks for the time being.
54
-
55
- - long_desc - Long description provided by help
56
- - option - Specify command line option
57
- - hidden - Hide task
58
- - replace - Replace a task with a new one
59
- - before - Execute task before other task
60
- - after - Execute task after other task
61
-
62
- Please note that replace, before and after should be used sparingly to augment or modify the internal tasks provided by hobo on a per project level.
53
+ Please see https://github.com/inviqa/hobo-gem/wiki/Hobofile-DSL for comprehensive examples.
63
54
 
64
55
  # Contributing
65
56
  If you wish to contribute to hobo:
data/bin/hobo CHANGED
@@ -8,6 +8,16 @@ require 'slop'
8
8
 
9
9
  error_handler = Hobo::ErrorHandlers::Friendly.new
10
10
  Hobo.ui = Hobo::Ui.new
11
+ Hobo.logger = Logger.new(STDOUT)
12
+ Hobo.logger.level = Logger::WARN
13
+ Hobo.logger.formatter = proc do |severity, datetime, progname, msg|
14
+ "#{datetime.strftime("%Y-%m-%d %H:%M:%S")}: #{severity}: #{msg}\n"
15
+ end
16
+
17
+ # win32console unfortunately has issues with Open3
18
+ # Simply disabling color for now; --ansi can be explicitly passed if required
19
+ # We also take the opportunity to disable ansi for pipes
20
+ Hobo.ui.use_color false if Gem.win_platform? || !STDOUT.tty?
11
21
 
12
22
  # win32console unfortunately has issues with Open3
13
23
  # Simply disabling color for now; --ansi can be explicitly passed if required
@@ -18,6 +28,16 @@ Hobo.ui.use_color false if Gem.win_platform? || !STDOUT.tty?
18
28
  slop = Slop.parse! do
19
29
  on '--debug', 'Enable debugging' do
20
30
  error_handler = Hobo::ErrorHandlers::Debug.new
31
+ Hobo.logger.level = Logger::DEBUG
32
+ end
33
+
34
+ on '--ansi', 'Enable / disable ansi output', :invertable => true do
35
+ Hobo.ui.use_color self.to_hash[:ansi]
36
+ end
37
+
38
+ on '--log-level=', 'Set log level' do
39
+ level = self.to_hash[:'log-level'].upcase
40
+ Hobo.logger.level = Logger.const_get(level) if [ 'DEBUG', 'INFO' ].include? level
21
41
  end
22
42
 
23
43
  on '--ansi', 'Enable / disable ansi output' do |*args|
@@ -9,4 +9,8 @@ Feature: Hobo help
9
9
  When I run `hobo --help`
10
10
  Then the output should contain "Usage:"
11
11
  And the output should contain "Global options:"
12
- And the output should contain "Commands:"
12
+ And the output should contain "Commands:"
13
+
14
+ Scenario: --ansi should show invertable help
15
+ When I run `hobo --help`
16
+ Then the output should contain "(Disable with --no-ansi)"
@@ -23,6 +23,10 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "rake", "~> 10.1.1"
24
24
  spec.add_dependency "rake-hooks", "~> 1.2.3"
25
25
  spec.add_dependency "bundler", "~> 1.5.2"
26
+ spec.add_dependency "deepstruct", "~> 0.0.5"
27
+ spec.add_dependency "semantic", "~> 1.3.0"
28
+ spec.add_dependency "aws-sdk", "~> 1.34.0"
29
+ spec.add_dependency "ruby-progressbar", "~> 1.4.1"
26
30
 
27
31
  spec.add_development_dependency "aruba", "~> 0.5.4"
28
32
  spec.add_development_dependency "rspec", "~> 2.14.1"
@@ -1,24 +1,19 @@
1
1
  # External deps
2
2
  require 'rake'
3
3
  require 'rake/hooks'
4
- require 'slop'
5
- require 'highline'
6
- require 'open3'
7
4
  require 'tempfile'
8
5
  require 'shellwords'
9
- require 'find'
6
+ require 'deepstruct'
10
7
 
11
8
  # DSL enhancements
12
9
  require 'hobo/metadata'
13
10
  require 'hobo/patches/rake'
14
11
  require 'hobo/patches/slop'
15
-
16
- # Task helpers
17
- require 'hobo/helper/shell'
18
- require 'hobo/helper/file_locator'
12
+ require 'hobo/patches/deepstruct'
19
13
 
20
14
  # Basics
21
15
  require 'hobo/version'
16
+ require 'hobo/null'
22
17
  require 'hobo/paths'
23
18
  require 'hobo/errors'
24
19
  require 'hobo/ui'
@@ -27,18 +22,26 @@ require 'hobo/help_formatter'
27
22
  require 'hobo/error_handlers/debug'
28
23
  require 'hobo/error_handlers/friendly'
29
24
  require 'hobo/config/file'
25
+ require 'hobo/logging'
26
+ require 'hobo/config'
27
+ require 'hobo/asset_applicator'
28
+
29
+ # Task helpers
30
+ require 'hobo/helper/shell'
31
+ require 'hobo/helper/file_locator'
32
+ require 'hobo/helper/vm_command'
30
33
 
31
34
  # Libs
32
35
  require 'hobo/lib/seed/project'
33
36
  require 'hobo/lib/seed/replacer'
34
37
  require 'hobo/lib/seed/seed'
35
38
 
36
- # Built-in tasks
37
- require 'hobo/tasks/debug'
38
- require 'hobo/tasks/deps'
39
- require 'hobo/tasks/seed'
40
- require 'hobo/tasks/vm'
41
- require 'hobo/tasks/tools'
39
+ # Host checks
40
+ require 'hobo/lib/host_check/git'
41
+ require 'hobo/lib/host_check/vagrant'
42
+ require 'hobo/lib/host_check/ruby'
43
+ require 'hobo/lib/host_check/deps'
44
+ require 'hobo/lib/host_check'
42
45
 
43
46
  # App
44
47
  require 'hobo/cli'
@@ -0,0 +1,16 @@
1
+ module Hobo
2
+ class << self
3
+ attr_accessor :asset_applicators
4
+ def asset_applicators
5
+ @asset_applicators ||= AssetApplicatorRegistry.new
6
+ end
7
+ end
8
+
9
+ private
10
+
11
+ class AssetApplicatorRegistry < Hash
12
+ def register pattern, &block
13
+ self[pattern] = block
14
+ end
15
+ end
16
+ end
@@ -1,9 +1,14 @@
1
+ require 'slop'
2
+ require 'deepstruct'
3
+
1
4
  module Hobo
2
5
 
3
6
  class Halt < Error
4
7
  end
5
8
 
6
9
  class Cli
10
+ include Hobo::Logging
11
+
7
12
  attr_accessor :slop, :help_formatter
8
13
 
9
14
  def initialize opts = {}
@@ -13,11 +18,13 @@ module Hobo
13
18
  @help_opts = {}
14
19
  end
15
20
 
16
- def start argv = ARGV
17
- load_hobofile
21
+ def start args = ARGV
22
+ load_user_config
23
+ load_builtin_tasks
24
+ load_hobofiles
25
+ load_project_config
18
26
 
19
27
  tasks = structure_tasks Hobo::Metadata.metadata.keys
20
- args = fix_args_with_equals argv
21
28
  define_global_opts @slop
22
29
 
23
30
  begin
@@ -54,13 +61,38 @@ module Hobo
54
61
 
55
62
  private
56
63
 
57
- def load_hobofile
64
+ def load_builtin_tasks
65
+ require 'hobo/tasks/assets'
66
+ require 'hobo/tasks/console'
67
+ require 'hobo/tasks/debug'
68
+ require 'hobo/tasks/deps'
69
+ require 'hobo/tasks/host'
70
+ require 'hobo/tasks/seed'
71
+ require 'hobo/tasks/vm'
72
+ require 'hobo/tasks/tools'
73
+ end
74
+
75
+ def load_user_config
76
+ Hobo.user_config = Hobo::Config::File.load Hobo.user_config_file
77
+ end
78
+
79
+ def load_project_config
80
+ if Hobo.in_project?
81
+ Hobo.project_config = Hobo::Config::File.load Hobo.project_config_file
82
+ else
83
+ Hobo.project_config = DeepStruct.wrap({})
84
+ end
85
+ end
86
+
87
+ def load_hobofiles
58
88
  if Hobo.in_project? && File.exists?(Hobo.hobofile_path)
59
- load Hobo.hobofile_path
89
+ logger.debug("cli: Loading hobofile @ #{Hobo.hobofile_path}")
90
+ TOPLEVEL_BINDING.eval File.read(Hobo.hobofile_path)
60
91
  end
61
92
 
62
93
  if File.exists?(Hobo.user_hobofile_path)
63
- load Hobo.user_hobofile_path
94
+ logger.debug("cli: Loading hobofile @ #{Hobo.user_hobofile_path}")
95
+ TOPLEVEL_BINDING.eval File.read(Hobo.user_hobofile_path)
64
96
  end
65
97
  end
66
98
 
@@ -83,6 +115,7 @@ module Hobo
83
115
  structured_list.each do |k, v|
84
116
  name = (stack + [k]).join(':')
85
117
  new_stack = stack + [k]
118
+ logger.debug("cli: Defined #{name}")
86
119
  map[name] = if v.size == 0
87
120
  define_command(name, scope, new_stack)
88
121
  else
@@ -144,6 +177,7 @@ module Hobo
144
177
  end
145
178
 
146
179
  run do |opts, args|
180
+ Dir.chdir Hobo.project_path if Hobo.in_project?
147
181
  raise ::Hobo::ProjectOnlyError.new if opts.project_only && !Hobo.in_project?
148
182
  task.opts = opts.to_hash
149
183
  raise ::Hobo::MissingArgumentsError.new(name, args, hobo) if args && task.arg_names.length > args.length
@@ -170,19 +204,5 @@ module Hobo
170
204
  end
171
205
  out
172
206
  end
173
-
174
- # Slop badly handles assignment args passed as --arg=val
175
- # This hack fixes that by making them --arg val
176
- def fix_args_with_equals args
177
- items = []
178
- args.each do |item|
179
- if item.match /^-.*\=/
180
- item.split('=').each { |i| items.push i }
181
- else
182
- items.push item
183
- end
184
- end
185
- return items
186
- end
187
207
  end
188
208
  end
@@ -0,0 +1,5 @@
1
+ module Hobo
2
+ class << self
3
+ attr_accessor :project_config, :user_config
4
+ end
5
+ end
@@ -1,9 +1,11 @@
1
1
  require 'yaml'
2
+ require 'deepstruct'
2
3
 
3
4
  module Hobo
4
5
  module Config
5
6
  class File
6
7
  def self.save(file, config)
8
+ config = config.unwrap if config.respond_to? :unwrap
7
9
  dir = ::File.dirname file
8
10
  FileUtils.mkdir_p dir unless ::File.exists? dir
9
11
  ::File.open(file, 'w+') do |f|
@@ -14,7 +16,7 @@ module Hobo
14
16
  def self.load(file)
15
17
  config = ::File.exists?(file) ? YAML.load_file(file) : {}
16
18
  raise "Invalid hobo configuration (#{file})" unless config
17
- return config
19
+ return DeepStruct.wrap(config)
18
20
  end
19
21
  end
20
22
  end
@@ -54,7 +54,14 @@ module Hobo
54
54
  class NonInteractiveError < Error
55
55
  def initialize question
56
56
  @question = question
57
- super("A task requested input from user but hobo is in non-interactive mode")
57
+ super("A task requested input from the user but hobo is in non-interactive mode")
58
+ end
59
+ end
60
+
61
+ class MissingDependency < Error
62
+ def initialize dep
63
+ @dependency = dep
64
+ super("A tool that hobo depends on could not be detected (#{dep})")
58
65
  end
59
66
  end
60
67
  end
@@ -1,3 +1,8 @@
1
+ require 'slop'
2
+ require 'highline'
3
+ require 'hobo/ui'
4
+ require 'hobo/patches/slop'
5
+
1
6
  module Hobo
2
7
  class HelpFormatter
3
8
  attr_accessor :command_map
@@ -60,8 +65,10 @@ module Hobo
60
65
  (heads + tails).map do |opt|
61
66
  next if source != @global && opt.short == 'h'
62
67
  line = padded(opt.short ? "-#{opt.short}," : "", 4)
68
+ description = opt.description
63
69
 
64
70
  if opt.long
71
+ description += ". (Disable with --no-#{opt.long})" if opt.config[:invertable]
65
72
  value = opt.config[:argument] ? "#{opt.long.upcase}" : ""
66
73
  value = "[#{value}]" if opt.accepts_optional_argument?
67
74
  value = "=#{value}" unless value.empty?
@@ -69,7 +76,7 @@ module Hobo
69
76
  line += "--#{opt.long}#{value}"
70
77
  end
71
78
 
72
- [Hobo.ui.color(line, :opt), opt.description]
79
+ [Hobo.ui.color(line, :opt), description]
73
80
  end.compact
74
81
  end
75
82
 
@@ -22,16 +22,19 @@ module Hobo
22
22
  args = [ 'git', 'ls-files', pattern ]
23
23
  args.push '-o' if others
24
24
  output = Hobo::Helper.shell *args, :capture => true
25
- path = output.split("\n")[0]
26
-
27
- unless path.nil?
25
+ paths = output.split("\n")
26
+ found = false
27
+ paths.each do |path|
28
28
  path.strip!
29
29
  Dir.chdir File.dirname(path) do
30
- yield path
30
+ Hobo::Logging.logger.debug "helper.locator: Found #{path} for #{pattern}"
31
+ yield File.basename(path), path
31
32
  end
32
33
 
33
- return true
34
+ found = true
34
35
  end
36
+
37
+ return found
35
38
  end
36
39
  end
37
40
  end