librarian-puppet-simple.haf 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,17 +23,14 @@ module Librarian
23
23
  def install!
24
24
  each_module do |repo|
25
25
  print_verbose "\n##### processing module #{repo[:name]}..."
26
+ # module path is where ALL the modules go, not this particular one
26
27
  module_path = module_path()
27
- if repo[:subdir]
28
- module_path = File.join(module_path, repo[:subdir])
29
- FileUtils.mkdir_p(module_path) unless File.exists?(module_path)
30
- end
31
- module_dir = File.join(module_path, repo[:name])
28
+ module_dir = File.join(module_path, repo[:subdir] || repo[:name])
32
29
 
33
30
  unless File.exists?(module_dir)
34
31
  case
35
32
  when repo[:git]
36
- install_git module_path, repo[:name], repo[:git], repo[:ref]
33
+ install_git module_path, repo[:name], repo[:git], repo[:ref], repo[:subdir]
37
34
  when repo[:tarball]
38
35
  install_tarball module_path, repo[:name], repo[:tarball]
39
36
  else
@@ -48,15 +45,17 @@ module Librarian
48
45
  private
49
46
 
50
47
  # installs sources that are git repos
51
- def install_git(module_path, module_name, repo, ref = nil)
52
- module_dir = File.join(module_path, module_name)
48
+ def install_git(module_path, module_name, repo, ref = nil, subdir = nil)
49
+ folder_name = subdir || module_name
50
+ module_dir = File.join(module_path, folder_name)
53
51
 
54
52
  Dir.chdir(module_path) do
55
53
  print_verbose "cloning #{repo}"
56
- system_cmd("git clone #{repo} #{module_name}")
57
- Dir.chdir(module_dir) do
54
+ system_cmd("git clone #{repo} #{folder_name}")
55
+ Dir.chdir(folder_name) do
58
56
  system_cmd('git branch -r')
59
57
  system_cmd("git checkout #{ref}") if ref
58
+ system_cmd("git filter-branch --subdirectory-filter #{subdir}") if subdir
60
59
  end
61
60
  end
62
61
  end
@@ -10,7 +10,7 @@ module Librarian
10
10
  def forge(repo)
11
11
  # this does nothing atm
12
12
  end
13
- # figure out what directory we are working out og
13
+ # figure out what directory we are working out of
14
14
  def base_dir
15
15
  @base_dir ||= Dir.pwd
16
16
  end
@@ -1,7 +1,7 @@
1
1
  module Librarian
2
2
  module Puppet
3
3
  module Simple
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -22,30 +22,33 @@ describe "Functional - Install" do
22
22
 
23
23
  before :each do
24
24
  temp_directory = Dir.mktmpdir
25
- Dir.entries(temp_directory).should =~ ['.', '..']
25
+ Dir.entries(temp_directory).should =~ %w|. ..|
26
26
  FileUtils.touch File.join(temp_directory, 'trashfile')
27
- Dir.entries(temp_directory).should =~ ['.', '..', 'trashfile']
27
+ Dir.entries(temp_directory).should =~ %w|. .. trashfile|
28
28
  end
29
29
 
30
30
  after :each do
31
31
  FileUtils.rm_rf temp_directory
32
32
  end
33
33
 
34
- it "install the modules in a temp directory" do
34
+ it "install the modules in a temp directory", :type => 'integration' do
35
35
  output, status = execute_captured("bin/librarian-puppet install --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
36
36
 
37
37
  status.should == 0
38
38
  Dir.entries(temp_directory).should =~ %w|. .. apache ntp trashfile dnsclient testlps subdir-A|
39
+ Dir.entries(File.join(temp_directory, 'subdir-A')).should =~ %w|. .. .git Hello.txt|
39
40
  end
40
41
 
41
- it "with --clean it cleans the directory before installing the modules in a temp directory" do
42
+
43
+
44
+ it "with --clean it cleans the directory before installing the modules in a temp directory", :type => 'integration' do
42
45
  output, status = execute_captured("bin/librarian-puppet install --clean --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
43
46
 
44
47
  status.should == 0
45
48
  Dir.entries(temp_directory).should =~ %w|. .. apache ntp dnsclient testlps subdir-A|
46
49
  end
47
50
 
48
- it "with --verbose it outputs progress messages" do
51
+ it "with --verbose it outputs progress messages", :type => 'integration' do
49
52
  output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
50
53
 
51
54
  status.should == 0
@@ -57,12 +60,12 @@ describe "Functional - Install" do
57
60
 
58
61
  before :each do
59
62
  temp_directory = Dir.mktmpdir
60
- Dir.entries(temp_directory).should =~ ['.', '..']
63
+ Dir.entries(temp_directory).should =~ %w|. ..|
61
64
  FileUtils.touch File.join(temp_directory, 'apache')
62
- Dir.entries(temp_directory).should =~ ['.', '..', 'apache']
65
+ Dir.entries(temp_directory).should =~ %w|. .. apache|
63
66
  end
64
67
 
65
- it 'without clean it should only install ntp' do
68
+ it 'without clean it should only install ntp', :type => 'integration' do
66
69
  output, status = execute_captured("bin/librarian-puppet install --verbose --path=#{temp_directory} --puppetfile=spec/fixtures/Puppetfile")
67
70
  status.should == 0
68
71
  output.should include('Module apache already installed')
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,12 @@ require 'open3'
9
9
  RSpec.configure do |config|
10
10
  config.treat_symbols_as_metadata_keys_with_true_values = true
11
11
  config.run_all_when_everything_filtered = true
12
- config.filter_run :focus
12
+
13
+ # if ENV['INTEGRATION']
14
+ # config.filter_run :type => 'integration'
15
+ # else
16
+ # config.filter_run_excluding :type => 'integration'
17
+ # end
13
18
 
14
19
  # Run specs in random order to surface order dependencies. If you find an
15
20
  # order dependency and want to debug it, you can fix the order by providing
@@ -22,4 +27,4 @@ RSpec.configure do |config|
22
27
  condensed = stdout.readlines.join + stderr.readlines.join
23
28
  [condensed, $?.exitstatus]
24
29
  end
25
- end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian-puppet-simple.haf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: