hobo-inviqa 0.0.2

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 (56) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +93 -0
  3. data/Guardfile +14 -0
  4. data/Hobofile +34 -0
  5. data/Rakefile +2 -0
  6. data/bin/hobo +23 -0
  7. data/features/deps.feature +43 -0
  8. data/features/hobo/basic.feature +30 -0
  9. data/features/hobo/help.feature +12 -0
  10. data/features/hobo/subcommands.feature +16 -0
  11. data/features/seed/plant.feature +64 -0
  12. data/features/step_definitions/seed.rb +11 -0
  13. data/features/support/env.rb +6 -0
  14. data/features/vm.feature +0 -0
  15. data/hobo.gemspec +37 -0
  16. data/lib/hobo.rb +44 -0
  17. data/lib/hobo/cli.rb +185 -0
  18. data/lib/hobo/config/file.rb +21 -0
  19. data/lib/hobo/error_handlers/debug.rb +9 -0
  20. data/lib/hobo/error_handlers/friendly.rb +52 -0
  21. data/lib/hobo/errors.rb +60 -0
  22. data/lib/hobo/help_formatter.rb +111 -0
  23. data/lib/hobo/helper/file_locator.rb +39 -0
  24. data/lib/hobo/helper/shell.rb +59 -0
  25. data/lib/hobo/lib/seed/project.rb +41 -0
  26. data/lib/hobo/lib/seed/replacer.rb +57 -0
  27. data/lib/hobo/lib/seed/seed.rb +43 -0
  28. data/lib/hobo/metadata.rb +28 -0
  29. data/lib/hobo/patches/rake.rb +56 -0
  30. data/lib/hobo/patches/slop.rb +22 -0
  31. data/lib/hobo/paths.rb +49 -0
  32. data/lib/hobo/tasks/debug.rb +22 -0
  33. data/lib/hobo/tasks/deps.rb +45 -0
  34. data/lib/hobo/tasks/seed.rb +43 -0
  35. data/lib/hobo/tasks/tools.rb +13 -0
  36. data/lib/hobo/tasks/vm.rb +49 -0
  37. data/lib/hobo/ui.rb +96 -0
  38. data/lib/hobo/util.rb +7 -0
  39. data/lib/hobo/version.rb +3 -0
  40. data/spec/hobo/cli_spec.rb +135 -0
  41. data/spec/hobo/config/file_spec.rb +48 -0
  42. data/spec/hobo/error_handlers/debug_spec.rb +10 -0
  43. data/spec/hobo/error_handlers/friendly_spec.rb +81 -0
  44. data/spec/hobo/error_spec.rb +0 -0
  45. data/spec/hobo/help_formatter_spec.rb +131 -0
  46. data/spec/hobo/helpers/file_locator_spec.rb +7 -0
  47. data/spec/hobo/helpers/shell_spec.rb +7 -0
  48. data/spec/hobo/lib/seed/project_spec.rb +83 -0
  49. data/spec/hobo/lib/seed/replacer_spec.rb +47 -0
  50. data/spec/hobo/lib/seed/seed_spec.rb +95 -0
  51. data/spec/hobo/metadata_spec.rb +46 -0
  52. data/spec/hobo/patches/rake_spec.rb +0 -0
  53. data/spec/hobo/paths_spec.rb +77 -0
  54. data/spec/hobo/ui_spec.rb +64 -0
  55. data/spec/spec_helper.rb +6 -0
  56. metadata +355 -0
File without changes
@@ -0,0 +1,131 @@
1
+ require 'hobo/help_formatter'
2
+
3
+ describe Hobo::HelpFormatter do
4
+ help = nil
5
+ slop = nil
6
+
7
+ before do
8
+ map = {}
9
+ slop = Slop.new
10
+ slop.instance_eval do
11
+ opt "-g", "--global", "Global option"
12
+
13
+ map["test"] = command "test" do
14
+ description "Testing1"
15
+ opt "-t", "--test", "Test description"
16
+ opt "-x", "--longer-option", "Longer option"
17
+
18
+ map["test:test"] = command "test" do
19
+ description "Testing2"
20
+ arg_list [:arg]
21
+ opt "-a=", "--a-test=", "Arg with value"
22
+ opt "-b=", "--b-test=", "Arg with optional value", argument: :optional
23
+ end
24
+ end
25
+ end
26
+
27
+ help = Hobo::HelpFormatter.new slop
28
+ help.command_map = map
29
+ HighLine.use_color = false
30
+ Hobo.ui = Hobo::Ui.new
31
+ end
32
+
33
+ describe "help" do
34
+
35
+ it "should return global help if no target passed" do
36
+ help.help.should match(/test\s+Testing1/)
37
+ end
38
+
39
+ it "should return command help if target passed" do
40
+ help.help(target: "test").should match /^Testing1$/
41
+ end
42
+
43
+ describe "usage format" do
44
+ it "should include generic usage for global help" do
45
+ help.help.should match /Usage:\n\s+rspec \[command\] \[options\]/
46
+ end
47
+
48
+ it "should include command usage for command help" do
49
+ help.help(target: "test:test").should match /Usage:\n\s+rspec test test <arg> \[options\]/
50
+ end
51
+ end
52
+
53
+ describe "option format" do
54
+ it "should include short, long and description" do
55
+ help.help(target: "test").should match /\s+-t, --test\s+Test description/
56
+ end
57
+
58
+ it "should append token value to options that take an argument" do
59
+ help.help(target: "test:test").should match /--a-test=A-TEST/
60
+ end
61
+
62
+ it "should surround token value qith square brackets for option with optional argument" do
63
+ help.help(target: "test:test").should match /--b-test=\[B-TEST\]/
64
+ end
65
+
66
+ it "should have description aligned to longest option or command" do
67
+ len = "--longer-option".length - "--test".length + 4 # ALIGN_PAD
68
+ help.help(target: "test").should match /\s+-t, --test\s{#{len}}Test description/
69
+ end
70
+ end
71
+
72
+ describe "command format" do
73
+ it "should have name and description" do
74
+ help.help.should match /\s+test\s+Testing1/
75
+ end
76
+ end
77
+
78
+ describe "global" do
79
+ it "should include usage" do
80
+ help.help.should match /Usage:/
81
+ end
82
+
83
+ it "should include global options" do
84
+ help.help.should match /Global options:\n\s+-g/
85
+ end
86
+
87
+ it "should include top level command list" do
88
+ help.help.should match /Commands:\n\s+test/
89
+ end
90
+ end
91
+
92
+ describe "namespace" do
93
+ it "should include usage" do
94
+ help.help(target: "test").should match /Usage:/
95
+ end
96
+
97
+ it "should include global options" do
98
+ help.help(target: "test").should match /Global options:/
99
+ end
100
+
101
+ it "should include namespace level command list" do
102
+ help.help(target: "test").should match /Commands:/
103
+ end
104
+ end
105
+
106
+ describe "command" do
107
+ it "should include long command description if set"
108
+ it "should fall back to short command description if long description not set"
109
+ it "should not display extra blank lines if no description set"
110
+ it "should include usage"
111
+ it "should include global options"
112
+ it "should include command options"
113
+ it "shoult not include -h command option"
114
+ end
115
+
116
+ describe "options" do
117
+ it "should include short option"
118
+ it "should include long option"
119
+ it "should include option description"
120
+ end
121
+
122
+ describe "alignment" do
123
+ it "should align descriptions according to longest option or command"
124
+ end
125
+
126
+ describe "filtering" do
127
+ it "should not show commands that do not have descriptions"
128
+ it "should show commands that do not have descriptions if :all is set"
129
+ end
130
+ end
131
+ end
@@ -0,0 +1,7 @@
1
+ require 'hobo/helper/file_locator'
2
+
3
+ describe Hobo::Helper do
4
+ describe "locate" do
5
+ it "should ..."
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'hobo/helper/shell'
2
+
3
+ describe Hobo::Helper do
4
+ describe "shell" do
5
+ it "should ..."
6
+ end
7
+ end
@@ -0,0 +1,83 @@
1
+ require 'spec_helper'
2
+ require 'hobo/paths'
3
+ require 'hobo/config/file'
4
+ require 'hobo/lib/seed/project'
5
+ require 'hobo/lib/seed/seed'
6
+ require 'hobo/lib/seed/replacer'
7
+ require 'hobo/helper/file_locator'
8
+ require 'hobo/helper/shell'
9
+ require 'hobo/ui'
10
+
11
+ describe Hobo::Lib::Seed::Project do
12
+ pwd = nil
13
+ tmp_dir = nil
14
+ default_config = {}
15
+
16
+ before do
17
+ tmp_dir = Dir.mktmpdir
18
+ pwd = Dir.pwd
19
+ Dir.chdir tmp_dir
20
+ FileUtils.mkdir_p "project_path"
21
+ FileUtils.touch "project_path/test"
22
+ Hobo.ui = Hobo::Ui.new
23
+ default_config = {
24
+ :config_class => double(Hobo::Config::File).as_null_object,
25
+ :replacer => double(Hobo::Lib::Seed::Replacer.new).as_null_object
26
+ }
27
+ end
28
+
29
+ after do
30
+ Dir.chdir pwd
31
+ FileUtils.remove_entry tmp_dir
32
+ end
33
+
34
+ describe "setup" do
35
+ it "should update seed before use" do
36
+ seed = double(Hobo::Lib::Seed::Seed).as_null_object
37
+ seed.should_receive :update
38
+
39
+ project = Hobo::Lib::Seed::Project.new(default_config)
40
+
41
+ project.setup(seed, { :project_path => "project_path", :seed => {}, :git_url => '.' })
42
+ end
43
+
44
+ it "should export seed to project directory" do
45
+ seed = double(Hobo::Lib::Seed::Seed).as_null_object
46
+ seed.should_recieve(:export).with("project_path")
47
+
48
+ project = Hobo::Lib::Seed::Project.new(default_config)
49
+
50
+ project.setup(seed, { :project_path => "project_path", :seed => {}, :git_url => '.' })
51
+ end
52
+
53
+ it "should save config in project" do
54
+ seed = double(Hobo::Lib::Seed::Seed).as_null_object
55
+ seed.should_recieve :export, "project_path"
56
+
57
+ config_class = double(Hobo::Config::File).as_null_object
58
+ config_class.should_recieve(:save).with("project_config_file")
59
+
60
+ project = Hobo::Lib::Seed::Project.new(default_config.merge({ :project_config_file => "project_config_file" }))
61
+
62
+ project.setup(seed, { :project_path => "project_path", :seed => {}, :git_url => '.' })
63
+ end
64
+
65
+ it "should initialize the project git repository" do
66
+ seed = double(Hobo::Lib::Seed::Seed).as_null_object
67
+
68
+ project = Hobo::Lib::Seed::Project.new(default_config)
69
+
70
+ project.setup(seed, { :project_path => "project_path", :seed => {}, :git_url => '.' })
71
+ expect { Hobo::Helper.shell("cd project_path && git status")}.not_to raise_error
72
+ end
73
+
74
+ it "should add the git url as the origin remote" do
75
+ seed = double(Hobo::Lib::Seed::Seed).as_null_object
76
+
77
+ project = Hobo::Lib::Seed::Project.new(default_config)
78
+
79
+ project.setup(seed, { :project_path => "project_path", :seed => {}, :git_url => 'remote_url' })
80
+ Hobo::Helper.shell("cd project_path && git remote show -n origin", :capture => true).should match /remote_url/
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+ require "hobo/lib/seed/replacer"
3
+
4
+ describe Hobo::Lib::Seed::Replacer do
5
+ before do
6
+ FakeFS.activate!
7
+ Dir.mkdir("bin")
8
+ Dir.mkdir("dir")
9
+ {
10
+ "./test1" => "some {{test}} is here",
11
+ "./test2" => "no test is here",
12
+ "./dir/test" => "subdir {{test}}",
13
+ "./dir/nested" => "nested {{nested.test}}",
14
+ "./dir/no-utf" => "\xc2 {{test}}", # invalid utf should be skipped
15
+ "./bin/test" => "{{test}}" # bin/ should be ignored
16
+ }.each do |name, content|
17
+ File.write(name, content)
18
+ end
19
+
20
+ @replacer = Hobo::Lib::Seed::Replacer.new
21
+ end
22
+
23
+ after do
24
+ FakeFS::FileSystem.clear
25
+ FakeFS.deactivate!
26
+ end
27
+
28
+ it "should respect exclude directories" do
29
+ files = @replacer.replace(".", { :test => 'badger' })
30
+ File.read("./bin/test").should eq "{{test}}"
31
+ end
32
+
33
+ it "should replace placeholders in files" do
34
+ files = @replacer.replace(".", { :test => 'badger' })
35
+ expect(files.sort).to eq(["./dir/test", "./test1"])
36
+
37
+ File.read("./test1").should eq "some badger is here"
38
+ File.read("./dir/test").should eq "subdir badger"
39
+ end
40
+
41
+ it "should handle nested hashes" do
42
+ files = @replacer.replace(".", { :nested => { :test => 'nested' } })
43
+ expect(files.sort).to eq(["./dir/nested"])
44
+
45
+ File.read("./dir/nested").should eq "nested nested"
46
+ end
47
+ end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+ require 'hobo/lib/seed/seed'
3
+ require 'hobo/helper/file_locator'
4
+ require 'hobo/helper/shell'
5
+ require 'hobo/ui'
6
+
7
+ describe Hobo::Lib::Seed::Seed do
8
+ pwd = nil
9
+ tmp_dir = nil
10
+
11
+ before do
12
+ tmp_dir = Dir.mktmpdir
13
+ pwd = Dir.pwd
14
+ Dir.chdir tmp_dir
15
+ Hobo.ui = Hobo::Ui.new
16
+ end
17
+
18
+ after do
19
+ Dir.chdir pwd
20
+ FileUtils.remove_entry tmp_dir
21
+ end
22
+
23
+ def create_test_repo path, content
24
+ FileUtils.mkdir_p path
25
+ Dir.chdir path do
26
+ `git init`
27
+ `echo "#{content}" > test`
28
+ `git add *`
29
+ `git commit -m "test"`
30
+ end
31
+ end
32
+
33
+ describe "update", :integration do
34
+ it "should fetch the seed if it does not exist locally" do
35
+ # Create test repo as seed remote
36
+ remote_seed_path = File.join(tmp_dir, "seed_1")
37
+ create_test_repo remote_seed_path, "does not exist locally"
38
+
39
+ seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_1', remote_seed_path
40
+ seed.update
41
+
42
+ # Repo is bare so we need to use git show to get contents
43
+ `cd seeds/seed_1 && git show HEAD:test`.strip.should eq "does not exist locally"
44
+ end
45
+
46
+ it "should update the seed if it exists locally" do
47
+ # Create test repo as seed remote
48
+ remote_seed_path = File.join(tmp_dir, "seed_2")
49
+ create_test_repo remote_seed_path, "does exist locally"
50
+
51
+ # Clone seed to seed cache directory
52
+ FileUtils.mkdir_p "seeds"
53
+ `cd seeds && git clone #{remote_seed_path} seed_2 --mirror 2> /dev/null`
54
+
55
+ # Update seed origin repo to give test something to update
56
+ `cd seed_2 && echo "updated" > test && git add test && git commit -m "test"`
57
+
58
+ seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_2', remote_seed_path
59
+ seed.update
60
+
61
+ # Repo is bare so we need to use git show to get contents
62
+ `cd seeds/seed_2 && git show HEAD:test`.strip.should eq "updated"
63
+ end
64
+ end
65
+
66
+ describe "export", :integration do
67
+ it "should export the seed contents to specified directory" do
68
+ # Create test repo as seed remote
69
+ remote_seed_path = File.join(tmp_dir, "seed_3")
70
+ create_test_repo remote_seed_path, "exported"
71
+
72
+ # Update seed and export
73
+ seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_3', remote_seed_path
74
+ seed.update
75
+ seed.export "exported"
76
+
77
+ File.read("exported/test").strip.should eq "exported"
78
+ File.exists?("exported/.git").should be false
79
+ end
80
+ end
81
+
82
+ describe "version", :integration do
83
+ it "should return the git sha of the seed" do
84
+ # Create test repo as seed remote
85
+ remote_seed_path = File.join(tmp_dir, "seed_4")
86
+ create_test_repo remote_seed_path, "version_test"
87
+
88
+ # Update seed and export
89
+ seed = Hobo::Lib::Seed::Seed.new 'seeds/seed_4', remote_seed_path
90
+ seed.update
91
+
92
+ seed.version.should eq `cd seeds/seed_4 && git rev-parse --short HEAD`.strip
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,46 @@
1
+ require 'hobo/metadata'
2
+
3
+ describe Hobo::Metadata do
4
+ before do
5
+ Hobo::Metadata.store = {}
6
+ Hobo::Metadata.metadata = {}
7
+ Hobo::Metadata.defaults = {}
8
+ end
9
+
10
+ describe "store" do
11
+ it "should expose storage" do
12
+ Hobo::Metadata.store[:opts] = {}
13
+ Hobo::Metadata.store[:opts].should be {}
14
+ end
15
+ end
16
+
17
+ describe "metadata" do
18
+ it "should expose metadata" do
19
+ Hobo::Metadata.store[:type] = "value"
20
+ Hobo::Metadata.add "key", :type
21
+ Hobo::Metadata.metadata["key"][:type].should match "value"
22
+ end
23
+ end
24
+
25
+ describe "add" do
26
+ it "should assign store value to task metadata for type" do
27
+ Hobo::Metadata.store[:type] = "value"
28
+ Hobo::Metadata.add "key", :type
29
+ Hobo::Metadata.metadata["key"][:type].should match "value"
30
+ end
31
+
32
+ it "should set store value to default after add" do
33
+ Hobo::Metadata.default :type, "value"
34
+ Hobo::Metadata.add "key", :type
35
+ Hobo::Metadata.metadata["key"][:type].should match "value"
36
+ end
37
+ end
38
+
39
+ describe "default" do
40
+ it "should store default value for type" do
41
+ Hobo::Metadata.default :type, "default"
42
+ Hobo::Metadata.add "key", :type
43
+ Hobo::Metadata.metadata["key"][:type].should match "default"
44
+ end
45
+ end
46
+ end
File without changes
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+ require 'hobo/paths'
3
+
4
+ describe Hobo do
5
+ describe 'project_path' do
6
+ before do
7
+ Hobo.project_path = nil
8
+ FakeFS.activate!
9
+ end
10
+
11
+ after do
12
+ FakeFS::FileSystem.clear
13
+ FakeFS.deactivate!
14
+ end
15
+
16
+ it 'should return current directory if not in project' do
17
+ Hobo.project_path.should eq Dir.pwd
18
+ end
19
+
20
+ it 'should return project directory if tools/hobo exists' do
21
+ FileUtils.mkdir_p 'project/test/tools/hobo'
22
+ Dir.chdir 'project/test' do
23
+ Hobo.project_path.should eq '/project/test'
24
+ end
25
+ end
26
+
27
+ it 'should traverse up directories search for tools/hobo' do
28
+ FileUtils.mkdir_p 'project/test/tools/hobo'
29
+ Dir.chdir 'project/test/tools/hobo' do
30
+ Hobo.project_path.should eq '/project/test'
31
+ end
32
+ end
33
+
34
+ it 'should memoize project path' do
35
+ FileUtils.mkdir_p 'project/test/tools/hobo'
36
+ Dir.chdir 'project/test/tools/hobo' do
37
+ Hobo.project_path.should eq '/project/test'
38
+ end
39
+
40
+ # We remove the hobo directory to see if the path was memoized or not
41
+ FileUtils.rmdir('project/test/tools/hobo')
42
+ Dir.chdir 'project/test/tools' do
43
+ Hobo.project_path.should eq '/project/test'
44
+ end
45
+ end
46
+ end
47
+
48
+ describe 'config_path' do
49
+ it 'should be ~/.hobo' do
50
+ Hobo.config_path.should eq File.join(ENV['HOME'], '.hobo')
51
+ end
52
+ end
53
+
54
+ describe 'seed_cache_path' do
55
+ it 'should be ~/.hobo/seeds' do
56
+ Hobo.seed_cache_path.should eq File.join(ENV['HOME'], '.hobo', 'seeds')
57
+ end
58
+ end
59
+
60
+ describe 'hobofile_path' do
61
+ it 'should be project_path + Hobofile' do
62
+ Hobo.hobofile_path.should eq File.join(Hobo.project_path, 'Hobofile')
63
+ end
64
+ end
65
+
66
+ describe 'project_config_file' do
67
+ it 'should be project_path + tools/hobo/storage.yaml' do
68
+ Hobo.project_config_file.should eq File.join(Hobo.project_path, 'tools', 'hobo', 'storage.yaml')
69
+ end
70
+ end
71
+
72
+ describe 'user_config_file' do
73
+ it 'should be ~/.hobo/config.rb' do
74
+ Hobo.user_config_file.should eq File.join(Hobo.config_path, 'config.rb')
75
+ end
76
+ end
77
+ end