halite 1.0.0.rc.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +20 -0
  4. data/.travis.yml +14 -4
  5. data/.yardopts +7 -0
  6. data/CHANGELOG.md +5 -0
  7. data/Gemfile +30 -8
  8. data/LICENSE +202 -202
  9. data/README.md +104 -2
  10. data/Rakefile +25 -5
  11. data/gemfiles/default.gemfile +17 -0
  12. data/gemfiles/master.gemfile +21 -0
  13. data/halite.gemspec +21 -10
  14. data/lib/berkshelf/halite.rb +25 -0
  15. data/lib/berkshelf/locations/gem.rb +84 -0
  16. data/lib/halite.rb +34 -4
  17. data/lib/halite/berkshelf/helper.rb +8 -2
  18. data/lib/halite/berkshelf/source.rb +9 -1
  19. data/lib/halite/converter.rb +34 -10
  20. data/lib/halite/converter/chef.rb +43 -0
  21. data/lib/halite/converter/libraries.rb +93 -26
  22. data/lib/halite/converter/metadata.rb +48 -10
  23. data/lib/halite/converter/misc.rb +43 -0
  24. data/lib/halite/dependencies.rb +48 -8
  25. data/lib/halite/error.rb +20 -0
  26. data/lib/halite/gem.rb +106 -21
  27. data/lib/halite/helper_base.rb +129 -0
  28. data/lib/halite/rake_helper.rb +46 -60
  29. data/lib/halite/rake_tasks.rb +17 -1
  30. data/lib/halite/spec_helper.rb +403 -54
  31. data/lib/halite/spec_helper/patcher.rb +130 -0
  32. data/lib/halite/spec_helper/runner.rb +57 -9
  33. data/lib/halite/version.rb +19 -1
  34. data/spec/converter/chef_spec.rb +54 -0
  35. data/spec/converter/libraries_spec.rb +131 -123
  36. data/spec/converter/metadata_spec.rb +61 -8
  37. data/spec/converter/misc_spec.rb +61 -0
  38. data/spec/converter_spec.rb +21 -6
  39. data/spec/dependencies_spec.rb +64 -10
  40. data/spec/example_resources/poise.rb +42 -0
  41. data/spec/example_resources/simple.rb +48 -0
  42. data/spec/{data/gems/test1/lib → fixtures/cookbooks/test1/files/halite_gem}/test1.rb +0 -0
  43. data/spec/{data/gems/test1/lib → fixtures/cookbooks/test1/files/halite_gem}/test1/version.rb +0 -0
  44. data/spec/fixtures/cookbooks/test1/libraries/default.rb +4 -0
  45. data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test1/metadata.rb +0 -0
  46. data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/attributes.rb +0 -0
  47. data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2.rb +0 -0
  48. data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2/resource.rb +0 -0
  49. data/spec/{data/gems/test2/lib → fixtures/cookbooks/test2/files/halite_gem}/test2/version.rb +0 -0
  50. data/spec/fixtures/cookbooks/test2/libraries/default.rb +3 -0
  51. data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test2/metadata.rb +1 -1
  52. data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/recipes/default.rb +0 -0
  53. data/spec/{data/gems/test2/chef → fixtures/cookbooks/test2}/templates/default/conf.erb +0 -0
  54. data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3.rb +0 -0
  55. data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3/dsl.rb +0 -0
  56. data/spec/{data/gems/test3/lib → fixtures/cookbooks/test3/files/halite_gem}/test3/version.rb +0 -0
  57. data/spec/fixtures/cookbooks/test3/libraries/default.rb +4 -0
  58. data/spec/{data/integration_cookbooks → fixtures/cookbooks}/test3/metadata.rb +0 -0
  59. data/spec/{data/gems/test3/chef → fixtures/cookbooks/test3}/recipes/default.rb +0 -0
  60. data/spec/{data → fixtures}/gems/test1/Rakefile +0 -0
  61. data/spec/fixtures/gems/test1/lib/test1.rb +2 -0
  62. data/spec/fixtures/gems/test1/lib/test1/version.rb +3 -0
  63. data/spec/{data → fixtures}/gems/test1/test1.gemspec +0 -0
  64. data/spec/{data → fixtures}/gems/test2/Rakefile +0 -0
  65. data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/attributes.rb +0 -0
  66. data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/recipes/default.rb +0 -0
  67. data/spec/{data/integration_cookbooks/test2 → fixtures/gems/test2/chef}/templates/default/conf.erb +0 -0
  68. data/spec/fixtures/gems/test2/lib/test2.rb +4 -0
  69. data/spec/{data/integration_cookbooks/test2/libraries/test2__resource.rb → fixtures/gems/test2/lib/test2/resource.rb} +1 -2
  70. data/spec/fixtures/gems/test2/lib/test2/version.rb +3 -0
  71. data/spec/{data → fixtures}/gems/test2/test2.gemspec +0 -0
  72. data/spec/{data → fixtures}/gems/test3/Rakefile +0 -0
  73. data/spec/{data/integration_cookbooks/test3 → fixtures/gems/test3/chef}/recipes/default.rb +0 -0
  74. data/spec/fixtures/gems/test3/lib/test3.rb +4 -0
  75. data/spec/{data/integration_cookbooks/test3/libraries/test3__dsl.rb → fixtures/gems/test3/lib/test3/dsl.rb} +1 -2
  76. data/spec/fixtures/gems/test3/lib/test3/version.rb +3 -0
  77. data/spec/{data → fixtures}/gems/test3/test3.gemspec +1 -0
  78. data/spec/gem_spec.rb +41 -31
  79. data/spec/integration_spec.rb +58 -82
  80. data/spec/runner_spec.rb +108 -0
  81. data/spec/spec_helper.rb +19 -26
  82. data/spec/spec_helper_spec.rb +238 -0
  83. metadata +124 -151
  84. data/lib/halite/converter/other.rb +0 -19
  85. data/lib/halite/converter/readme.rb +0 -20
  86. data/spec/converter/other_spec.rb +0 -56
  87. data/spec/converter/readme_spec.rb +0 -55
  88. data/spec/data/integration_cookbooks/test1/libraries/test1.rb +0 -3
  89. data/spec/data/integration_cookbooks/test1/libraries/test1__version.rb +0 -4
  90. data/spec/data/integration_cookbooks/test2/libraries/test2.rb +0 -5
  91. data/spec/data/integration_cookbooks/test2/libraries/test2__version.rb +0 -4
  92. data/spec/data/integration_cookbooks/test3/libraries/test3.rb +0 -5
  93. data/spec/data/integration_cookbooks/test3/libraries/test3__version.rb +0 -4
@@ -1,19 +0,0 @@
1
- module Halite
2
- module Converter
3
- module Other
4
-
5
- def self.write(spec, base_path)
6
- spec.each_file('chef') do |path, rel_path|
7
- dir_path = File.dirname(rel_path)
8
- FileUtils.mkdir_p(File.join(base_path, dir_path)) unless dir_path == '.'
9
- File.open(path, 'rb') do |in_f|
10
- File.open(File.join(base_path, rel_path), 'wb') do |out_f|
11
- IO.copy_stream(in_f, out_f)
12
- end
13
- end
14
- end
15
- end
16
-
17
- end
18
- end
19
- end
@@ -1,20 +0,0 @@
1
- module Halite
2
- module Converter
3
- module Readme
4
-
5
- def self.write(spec, base_path)
6
- readme_path = %w{README.md README README.txt readme.md readme readme.txt}.map do |name|
7
- File.join(spec.full_gem_path, name)
8
- end.find {|path| File.exists?(path) }
9
- if readme_path
10
- File.open(readme_path, 'rb') do |in_f|
11
- File.open(File.join(base_path, File.basename(readme_path)), 'wb') do |out_f|
12
- IO.copy_stream(in_f, out_f)
13
- end
14
- end
15
- end
16
- end
17
-
18
- end
19
- end
20
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
- require 'halite/converter/other'
3
-
4
- describe Halite::Converter::Other do
5
-
6
- describe '#write' do
7
- let(:files) { [] }
8
- let(:input) { [] }
9
- let(:output) { [] }
10
- let(:spec) do
11
- spec = double(name: 'mygem')
12
- allow(spec).to receive(:each_file) do |&block|
13
- files.each {|path| block.call(File.join('/source', path), path) }
14
- end
15
- spec
16
- end
17
- before do
18
- files.each do |path|
19
- input_sentinel = double("content of #{path}")
20
- output_sentinel = double("generated output for #{path}")
21
- allow(File).to receive(:open).with(File.join('/source', path), 'rb').and_yield(input_sentinel)
22
- input << input_sentinel
23
- output << output_sentinel
24
- end
25
- end
26
-
27
- context 'with a single file' do
28
- let(:files) { ['recipes/default.rb'] }
29
-
30
- it 'writes a single file' do
31
- expect(FileUtils).to receive(:mkdir_p).with('/test/recipes')
32
- expect(File).to receive(:open).with('/test/recipes/default.rb', 'wb').and_yield(output[0])
33
- expect(IO).to receive(:copy_stream).with(input[0], output[0])
34
- described_class.write(spec, '/test')
35
- end
36
- end # /context with a single file
37
-
38
- context 'with multiple files' do
39
- let(:files) { ['attributes.rb', 'recipes/default.rb', 'templates/default/conf.erb'] }
40
-
41
- it 'writes multiple files' do
42
- expect(FileUtils).to receive(:mkdir_p).with('/test/recipes')
43
- expect(FileUtils).to receive(:mkdir_p).with('/test/templates/default')
44
- expect(File).to receive(:open).with('/test/attributes.rb', 'wb').and_yield(output[0])
45
- expect(IO).to receive(:copy_stream).with(input[0], output[0])
46
- expect(File).to receive(:open).with('/test/recipes/default.rb', 'wb').and_yield(output[1])
47
- expect(IO).to receive(:copy_stream).with(input[1], output[1])
48
- expect(File).to receive(:open).with('/test/templates/default/conf.erb', 'wb').and_yield(output[2])
49
- expect(IO).to receive(:copy_stream).with(input[2], output[2])
50
- described_class.write(spec, '/test')
51
- end
52
- end # /context with a single file
53
-
54
- end # /describe #write
55
-
56
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
- require 'halite/converter/readme'
3
-
4
- describe Halite::Converter::Readme do
5
-
6
- describe '#write' do
7
- let(:spec) { double(full_gem_path: '/source') }
8
- let(:readme_file) { }
9
- let(:input) { [] }
10
- let(:output) { [] }
11
- before do
12
- allow(File).to receive(:exists?).and_return(false)
13
- Array(readme_file).each do |path|
14
- input_sentinel = double("content of #{path}")
15
- output_sentinel = double("generated output for #{path}")
16
- allow(File).to receive(:exists?).with(File.join('/source', path)).and_return(true)
17
- allow(File).to receive(:open).with(File.join('/source', path), 'rb').and_yield(input_sentinel)
18
- input << input_sentinel
19
- output << output_sentinel
20
- end
21
- end
22
-
23
- context 'with a README.md' do
24
- let(:readme_file) { 'README.md' }
25
-
26
- it 'writes out a README.md' do
27
- expect(File).to receive(:open).with('/test/README.md', 'wb').and_yield(output[0])
28
- expect(IO).to receive(:copy_stream).with(input[0], output[0])
29
- described_class.write(spec, '/test')
30
- end
31
- end # /context with a README.md
32
-
33
- context 'with a README' do
34
- let(:readme_file) { 'README' }
35
-
36
- it 'writes out a README' do
37
- expect(File).to receive(:open).with('/test/README', 'wb').and_yield(output[0])
38
- expect(IO).to receive(:copy_stream).with(input[0], output[0])
39
- described_class.write(spec, '/test')
40
- end
41
- end # /context with a README
42
-
43
- context 'with multiple files' do
44
- let(:readme_file) { %w{README.txt readme.md} }
45
-
46
- it 'writes out a README' do
47
- expect(File).to receive(:open).with('/test/README.txt', 'wb').and_yield(output[0])
48
- expect(IO).to receive(:copy_stream).with(input[0], output[0])
49
- described_class.write(spec, '/test')
50
- end
51
- end # /context with multiple files
52
-
53
- end # /describe #write
54
-
55
- end
@@ -1,3 +0,0 @@
1
- ENV['HALITE_LOAD'] = '1'; begin; module Test1
2
- end
3
- ensure; ENV.delete('HALITE_LOAD'); end
@@ -1,4 +0,0 @@
1
- if ENV['HALITE_LOAD']; module Test1
2
- VERSION = '1.2.3'
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- ENV['HALITE_LOAD'] = '1'; begin; require_relative 'test2__resource'
2
-
3
- module Test2
4
- end
5
- ensure; ENV.delete('HALITE_LOAD'); end
@@ -1,4 +0,0 @@
1
- if ENV['HALITE_LOAD']; module Test2
2
- VERSION = '4.5.6'
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- ENV['HALITE_LOAD'] = '1'; begin; require_relative 'test3__dsl'
2
-
3
- module Test3
4
- end
5
- ensure; ENV.delete('HALITE_LOAD'); end
@@ -1,4 +0,0 @@
1
- if ENV['HALITE_LOAD']; module Test3
2
- VERSION = '7.8.9'
3
- end
4
- end