puppet_pal 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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in magic_config.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Owings
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ ## Puppet Pal!
2
+
3
+ ## Usage
4
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/puppet-pal ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ load 'puppet_pal/cli.rb'
3
+ PuppetPal::Cli.new.run
@@ -0,0 +1,29 @@
1
+ require 'getoptlong'
2
+ require 'puppet_pal/pal'
3
+
4
+ module PuppetPal
5
+ class Cli
6
+ def initialize
7
+
8
+ end
9
+
10
+ def run
11
+ opts = GetoptLong.new(
12
+ [ '--puppet_file', '-f', GetoptLong::REQUIRED_ARGUMENT ],
13
+ )
14
+ # Shove our options into a hash
15
+ @options = {puppet_file: "Puppetfile"}
16
+ opts.each do |opt, arg|
17
+ key=opt.split("--").last
18
+ if arg && !arg.empty?
19
+ @options[key.to_sym]=arg
20
+ else
21
+ @options[key.to_sym]=true
22
+ end
23
+ end
24
+ raise "Cannot find Puppetfile: #{@options[:puppet_file]}." unless File.exists?(@options[:puppet_file])
25
+ pal = PuppetPal::Pal.new(@options[:puppet_file])
26
+ pal.run
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,70 @@
1
+ require 'fileutils'
2
+
3
+ module PuppetPal
4
+ class Pal
5
+ PAL_WORKING_DIR = ".puppet_pal"
6
+ DEFAULT_GIT_MODE = :reclone
7
+ MODULE_DIR = "modules"
8
+
9
+ def initialize(puppet_file_name)
10
+ @repositories={git: {}}
11
+ @puppet_file_name = File.expand_path(puppet_file_name)
12
+ @base_dir = File.dirname(@puppet_file_name)
13
+ @work_dir = File.join(@base_dir, PAL_WORKING_DIR)
14
+ @module_dir = File.join(@base_dir, MODULE_DIR)
15
+ @git_mode = DEFAULT_GIT_MODE
16
+ end
17
+
18
+ def run
19
+ FileUtils.mkdir_p(@work_dir)
20
+ FileUtils.mkdir_p(@module_dir)
21
+ self.instance_eval(File.read(@puppet_file_name))
22
+ end
23
+
24
+ def repo_dirname(name, type)
25
+ File.join(@work_dir, type.to_s, name.gsub("/","-"))
26
+ end
27
+
28
+ def pull_repo(name, type = :git)
29
+ # git is only supprted type right now
30
+ working_dir = repo_dirname(name, type)
31
+ unless @repositories[type][name]
32
+ @repositories[type][name] = working_dir
33
+ if @git_mode == :reclone
34
+ FileUtils.rm_rf(working_dir) # Clear it out
35
+ success = system("git clone #{name} #{working_dir}")
36
+ raise "git clone failed" unless success
37
+ end
38
+ end
39
+ working_dir
40
+ end
41
+
42
+ def copy_module(name, source_path)
43
+ target = File.join(@module_dir,name)
44
+ FileUtils.rm_rf(target)
45
+ FileUtils.cp_r(source_path, target, preserve: true)
46
+ end
47
+
48
+ def pull_from_puppetforge(name)
49
+ target = File.join(@module_dir,name.split("/").last)
50
+ FileUtils.rm_rf(target)
51
+ success = system("puppet module install --target-dir #{@module_dir} #{name}")
52
+ raise "Unable to pull from puppet forge. Verify that puppet is installed and that module name is correct" unless success
53
+ end
54
+
55
+ def forge(name)
56
+ @forge = name # This is unused right now, until I figure out what it does in librarian-puppet
57
+ end
58
+
59
+ def mod(name, options={})
60
+ puts "Processing module: #{name}"
61
+ if options[:git]
62
+ working_dir = pull_repo(options[:git])
63
+ path = options[:path] || ""
64
+ copy_module(name, File.join(working_dir, path))
65
+ else # Assume we are pulling from puppet forge
66
+ pull_from_puppetforge(name)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module PuppetPal
2
+ VERSION = "0.0.2"
3
+ end
data/lib/puppet_pal.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "puppet_pal/version"
2
+ require "puppet_pal/pal"
3
+ require "puppet_pal/cli"
4
+
5
+ module PuppetPal
6
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'puppet_pal/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "puppet_pal"
8
+ spec.version = PuppetPal::VERSION
9
+ spec.authors = ["Michael Owings"]
10
+ spec.email = ["mowings@turbosquid.com"]
11
+ spec.description = %q{A simpler, faster version of librarian-puppet -- pulls specified modules from soure control}
12
+ spec.summary = %q{Puppet Pal!}
13
+ spec.homepage = "https://github.com/turbosquid/puppet_pal"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ # spec.add_dependency('activesupport', '~> 3.2')
25
+ end
data/spec/spec.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe "PuppetPal::Pal" do
4
+
5
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet_pal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Owings
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-01-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A simpler, faster version of librarian-puppet -- pulls specified modules
63
+ from soure control
64
+ email:
65
+ - mowings@turbosquid.com
66
+ executables:
67
+ - puppet-pal
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - bin/puppet-pal
77
+ - lib/puppet_pal.rb
78
+ - lib/puppet_pal/cli.rb
79
+ - lib/puppet_pal/pal.rb
80
+ - lib/puppet_pal/version.rb
81
+ - puppet_pal.gemspec
82
+ - spec/spec.rb
83
+ - spec/spec_helper.rb
84
+ homepage: https://github.com/turbosquid/puppet_pal
85
+ licenses:
86
+ - MIT
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 1.8.23
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: Puppet Pal!
109
+ test_files:
110
+ - spec/spec.rb
111
+ - spec/spec_helper.rb
112
+ has_rdoc: