puppet-examples-helpers 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fdc0ddd753686ec142f4b7815cfb19ed13aaa766
4
+ data.tar.gz: 0c868a7ccee1d60e304f52f5e973b7b71d23a55e
5
+ SHA512:
6
+ metadata.gz: 6b3b3baaff70abf622ecfd0bcd08270255a405fb89ac313579547a18971afeb386bb5a2ce1260a8e3bf1f937542acf9c76e788bb47eeb064f61cf56d9007a23f
7
+ data.tar.gz: 1955e599ef3f35d7d47066318e5f2e66d9063789e2dc59e90fb1fa4695728a250c6aa860ce2d9dd6d5b098cd244a6c2e17ebc7ee98012eec16ae09062ab4b698
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /vendor/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,20 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ AllCops:
3
+ TargetRubyVersion: 1.9
4
+ Include:
5
+ - ./**/*.rb
6
+ Exclude:
7
+ - vendor/**/*
8
+ - .vendor/**/*
9
+ Metrics/LineLength:
10
+ Max: 140
11
+ Style/FileName:
12
+ Exclude:
13
+ - 'Gemfile'
14
+ - 'Rakefile'
15
+ - '*.gemspec'
16
+ - lib/puppet-examples-helpers.rb
17
+ - spec/puppet-examples-helpers_spec.rb
18
+ Metrics/BlockLength:
19
+ Exclude:
20
+ - 'spec/**/*_spec.rb'
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-06-14 18:06:57 +0200 using RuboCop version 0.49.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
@@ -0,0 +1,11 @@
1
+ sudo: false
2
+ language: ruby
3
+ matrix:
4
+ fast_finish: true
5
+ include:
6
+ - rvm: '1.9'
7
+ bundler_args: '--no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}'
8
+ - rvm: '2.1'
9
+ - rvm: '2.3'
10
+ - rvm: '2.4'
11
+ before_install: gem install bundler -v 1.15.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at krzysztof.suszynski@coi.gov.pl. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
+
3
+ RVERSION = Gem::Version.new(RUBY_VERSION.dup)
4
+
5
+ def req(req_s)
6
+ Gem::Requirement.new(req_s)
7
+ end
8
+
9
+ group :test do
10
+ gem 'rspec', '~> 3', require: false
11
+ gem 'rubocop', '~> 0.49', require: false if req('>= 2.0') =~ RVERSION
12
+ gem 'simplecov', '~> 0.14.1', require: false
13
+ end
14
+
15
+ group :development do
16
+ gem 'pry-byebug', '~> 3.4', '>= 3.4.2', require: false if req('>= 2.0') =~ RVERSION
17
+ gem 'rake', '~> 10', require: false
18
+ end
19
+
20
+ # Specify your gem's dependencies in puppet-examples-helpers.gemspec
21
+ gemspec
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ puppet-examples-helpers (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.3.0)
10
+ byebug (9.0.6)
11
+ coderay (1.1.1)
12
+ diff-lcs (1.3)
13
+ docile (1.1.5)
14
+ json (1.8.6)
15
+ method_source (0.8.2)
16
+ parallel (1.11.2)
17
+ parser (2.4.0.0)
18
+ ast (~> 2.2)
19
+ powerpack (0.1.1)
20
+ pry (0.10.4)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ pry-byebug (3.4.2)
25
+ byebug (~> 9.0)
26
+ pry (~> 0.10)
27
+ rainbow (2.2.2)
28
+ rake
29
+ rake (10.5.0)
30
+ rspec (3.6.0)
31
+ rspec-core (~> 3.6.0)
32
+ rspec-expectations (~> 3.6.0)
33
+ rspec-mocks (~> 3.6.0)
34
+ rspec-core (3.6.0)
35
+ rspec-support (~> 3.6.0)
36
+ rspec-expectations (3.6.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.6.0)
39
+ rspec-mocks (3.6.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.6.0)
42
+ rspec-support (3.6.0)
43
+ rubocop (0.49.1)
44
+ parallel (~> 1.10)
45
+ parser (>= 2.3.3.1, < 3.0)
46
+ powerpack (~> 0.1)
47
+ rainbow (>= 1.99.1, < 3.0)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (~> 1.0, >= 1.0.1)
50
+ ruby-progressbar (1.8.1)
51
+ simplecov (0.14.1)
52
+ docile (~> 1.1.0)
53
+ json (>= 1.8, < 3)
54
+ simplecov-html (~> 0.10.0)
55
+ simplecov-html (0.10.1)
56
+ slop (3.6.0)
57
+ unicode-display_width (1.3.0)
58
+
59
+ PLATFORMS
60
+ ruby
61
+
62
+ DEPENDENCIES
63
+ bundler (~> 1.15)
64
+ pry-byebug (~> 3.4, >= 3.4.2)
65
+ puppet-examples-helpers!
66
+ rake (~> 10)
67
+ rspec (~> 3)
68
+ rubocop (~> 0.49)
69
+ simplecov (~> 0.14.1)
70
+
71
+ BUNDLED WITH
72
+ 1.15.1
@@ -0,0 +1,13 @@
1
+ Copyright 2017 Center for Information Technology, Poland
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,97 @@
1
+ # PuppetExamplesHelpers
2
+
3
+ [![Build Status](https://travis-ci.org/coi-gov-pl/puppet-examples-helpers.svg?branch=develop)](https://travis-ci.org/coi-gov-pl/puppet-examples-helpers)
4
+
5
+ Helpers to utilize puppet example files.
6
+
7
+ Using new `example` method you can read and execute example file provided in puppet modules in accetance tests.
8
+
9
+ ```ruby
10
+ # Sets code to contents of examples/init.pp file
11
+ let(:code) { example '::modulename' }
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ Add this to your puppet module's Gemfile:
17
+
18
+ ```ruby
19
+ group :system_tests do
20
+ # [..]
21
+ gem 'puppet-examples-helpers'
22
+ end
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install puppet-examples-helpers
32
+
33
+ ## Usage
34
+
35
+ ### RSpec Acceptance Helper
36
+
37
+ ```ruby
38
+ # file: spec/spec_helper_acceptance.rb
39
+ require 'puppet'
40
+ require 'beaker-rspec'
41
+ require 'beaker/puppet_install_helper'
42
+ require 'beaker/module_install_helper'
43
+ require 'puppet-examples-helpers'
44
+
45
+ UNSUPPORTED_PLATFORMS = %w[Suse windows AIX Solaris].freeze
46
+
47
+ run_puppet_install_helper
48
+ install_module
49
+ install_module_dependencies
50
+
51
+ RSpec.configure do |c|
52
+ c.include PuppetExamplesHelpers
53
+
54
+ c.formatter = :documentation
55
+ end
56
+ ```
57
+
58
+ ### Acceptance Test Example
59
+
60
+ ```ruby
61
+ # file: spec/acceptance/jboss/internal/service_spec.rb
62
+ require 'spec_helper_acceptance'
63
+
64
+ describe '::jboss::internal::service', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
65
+ # Reads examples/internal/service.pp file
66
+ let(:code) { example '::jboss::internal::service' }
67
+
68
+ it 'should work with no errors' do
69
+ result = apply_manifest(code, catch_failures: true)
70
+ expect(result.exit_code).to be(2)
71
+ end
72
+ it 'should work idempotently' do
73
+ apply_manifest(code, catch_changes: true)
74
+ end
75
+ describe service('wildfly') do
76
+ it { is_expected.to be_running }
77
+ end
78
+ end
79
+ ```
80
+
81
+ ## Development
82
+
83
+ After checking out the repo, run `bundle` to install dependencies. Then, run `bundle exec rake spec` to run the tests. You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.
84
+
85
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
86
+
87
+ ## Contributing
88
+
89
+ Bug reports and pull requests are welcome on GitHub at https://github.com/coi-gov-pl/puppet-examples-helpers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
90
+
91
+ ## License
92
+
93
+ The gem is available as open source under the terms of the [Apache 2.0](https://opensource.org/licenses/Apache-2.0).
94
+
95
+ ## Code of Conduct
96
+
97
+ Everyone interacting in the Puppet::Examples::Helper project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coi-gov-pl/puppet-examples-helpers/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,20 @@
1
+ def gem_present(name)
2
+ !Bundler.rubygems.find_name(name).empty?
3
+ end
4
+
5
+ require 'bundler/gem_tasks'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ test_tasks = [:spec]
11
+
12
+ if gem_present 'rubocop'
13
+ require 'rubocop/rake_task'
14
+ RuboCop::RakeTask.new
15
+ test_tasks.unshift(:rubocop)
16
+ end
17
+
18
+ task test: test_tasks
19
+
20
+ task default: :test
@@ -0,0 +1 @@
1
+ debug('an main init.pp')
@@ -0,0 +1 @@
1
+ info('sample file')
@@ -0,0 +1 @@
1
+ debug('just to show off')
@@ -0,0 +1,35 @@
1
+ require 'puppet-examples-helpers/version'
2
+
3
+ # A main module of puppet-examples-helpers
4
+ module PuppetExamplesHelpers
5
+ DEFAULT_MODULENAME = 'modulename'.freeze
6
+ BASE_EXAMPLES_PATH = Pathname.new('examples')
7
+ DEFAULT_INIT_FILENAME = 'init'.freeze
8
+
9
+ # Reads an example mainifests from examples/ directory
10
+ # This can be useful in puppet's acceptance tests
11
+ # @return [String] The example file contents
12
+ # @param [String] classname The file path to be read, in puppet loader convention
13
+ def example(classname = nil)
14
+ paths = normalize(classname).split('::')[1..-1]
15
+ paths = [DEFAULT_INIT_FILENAME] if paths.empty?
16
+ paths[-1] = "#{paths[-1]}.pp"
17
+
18
+ path = BASE_EXAMPLES_PATH
19
+ paths.each do |subpath|
20
+ path = path.join(subpath)
21
+ end
22
+ raise "Can't read example manifest '#{path}'" unless path.readable?
23
+ $stderr.puts "Reading example manifest '#{path}'"
24
+ path.read
25
+ end
26
+
27
+ private
28
+
29
+ def normalize(classname)
30
+ classname ||= DEFAULT_MODULENAME
31
+ classname.gsub!(/^::/, '') if classname =~ /^::/
32
+ classname = DEFAULT_MODULENAME if classname.empty?
33
+ classname
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module PuppetExamplesHelpers
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'puppet-examples-helpers/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'puppet-examples-helpers'
9
+ spec.version = PuppetExamplesHelpers::VERSION
10
+ spec.authors = ['Suszyński Krzysztof']
11
+ spec.email = ['krzysztof.suszynski@coi.gov.pl']
12
+
13
+ spec.summary = 'Helpers to utilize puppet example files'
14
+ spec.description = 'Using new `example` method you can read and execute example file provided in' \
15
+ ' puppet modules in accetance tests.'
16
+ spec.homepage = 'https://github.com/coi-gov-pl/puppet-examples-helpers'
17
+ spec.license = 'Apache-2.0'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
20
+ f.match(%r{^(test|spec|features)/})
21
+ end
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+ spec.required_ruby_version = '>= 1.9.0'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.15'
28
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-examples-helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Suszyński Krzysztof
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ description: Using new `example` method you can read and execute example file provided
28
+ in puppet modules in accetance tests.
29
+ email:
30
+ - krzysztof.suszynski@coi.gov.pl
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - ".rubocop_todo.yml"
39
+ - ".travis.yml"
40
+ - CODE_OF_CONDUCT.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE.txt
44
+ - README.md
45
+ - Rakefile
46
+ - examples/init.pp
47
+ - examples/sample.pp
48
+ - examples/sub/showoff.pp
49
+ - lib/puppet-examples-helpers.rb
50
+ - lib/puppet-examples-helpers/version.rb
51
+ - puppet-examples-helpers.gemspec
52
+ homepage: https://github.com/coi-gov-pl/puppet-examples-helpers
53
+ licenses:
54
+ - Apache-2.0
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 1.9.0
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.6.12
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Helpers to utilize puppet example files
76
+ test_files: []