puppet-herald-client 1.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10a02327028f1e701de4805879b484c651236b94
4
+ data.tar.gz: 557cc22e3a983eac1b87e39a5b253964b4ebc49b
5
+ SHA512:
6
+ metadata.gz: 1aa96b7d6fcdd0b53af0b2d49259185191a814b4b127e0663dbde50eeb6fdcca1d0304f6b1cd5d2010b88a7670ff65e348dd59492ba18e0e1d2c1489b2116f6a
7
+ data.tar.gz: f423fb19d43681e6bcf41c2c25ca594a09f3d97cbf5a378ef39c8eae9ad8faad701f23b3f7de13b3b78d2d61dfd2d06386351ec7832b00a6dbf21a26a698d4e9
data/.gitignore ADDED
@@ -0,0 +1,28 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore bundle .vendor dir
11
+ /.vendor
12
+ /coverage
13
+
14
+ /Gemfile.lock
15
+
16
+ # Ignore the default SQLite database.
17
+ /db/*.sqlite3
18
+ /db/*.sqlite3-journal
19
+
20
+ # Ignore all logfiles and tempfiles.
21
+ /log/*.log
22
+ /tmp
23
+ /node_modules
24
+ /npm-*.log
25
+
26
+ /Gemfile.local
27
+ bower_components
28
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+
3
+ inherit_from: .rubocop_todo.yml
4
+
5
+ AllCops:
6
+ Include:
7
+ - 'lib/**/*.rb'
8
+ - 'Rakefile'
9
+ - 'Gemfile'
10
+ - 'puppet-herald-client.gemspec'
11
+ Exclude:
12
+ - '.**/*'
13
+ - 'spec/**/*'
14
+ - 'coverage/**/*'
15
+ - '.vendor/**/*'
16
+ - 'vendor/**/*'
17
+ - '.bundle/**/*'
18
+
19
+ Metrics/LineLength:
20
+ Max: 120
21
+
22
+ Metrics/MethodLength:
23
+ Max: 15
24
+
25
+ Metrics/AbcSize:
26
+ Max: 20
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,6 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-12-17 02:10:52 +0100 using RuboCop version 0.28.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ ---
2
+ language: ruby
3
+ bundler_args: --without development
4
+ script:
5
+ - bundle exec rake test
6
+ before_install: rm -f Gemfile.lock
7
+ rvm:
8
+ - 1.8.7
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1.0
12
+ notifications:
13
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,32 @@
1
+ source ENV['GEM_SOURCE'] || 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # rubocop:disable Style/HashSyntax
6
+ group :test do
7
+ gem 'rake', '~> 10.4.0', :require => false
8
+ gem 'rspec', '~> 3.2.0', :require => false
9
+ gem 'coveralls', '~> 0.8.0', :require => false
10
+ gem 'simplecov', '~> 0.10.0', :require => false
11
+ gem 'webmock', '~> 1.21.0', :require => false
12
+ gem 'rest-client', '~> 1.6.8', :require => false if RUBY_VERSION < '1.9.0'
13
+ gem 'rubocop', '~> 0.30.0', :require => false if RUBY_VERSION >= '1.9.0'
14
+ gem 'ox', '~> 2.1.0', :require => false
15
+ gem 'inch', '~> 0.5.0', :require => false if RUBY_VERSION >= '1.9.0'
16
+ end
17
+
18
+ group :development do
19
+ gem 'guard', '~> 2.12.0', :require => false if RUBY_VERSION >= '1.9.0'
20
+ gem 'guard-bundler', '~> 2.1.0', :require => false if RUBY_VERSION >= '1.9.0'
21
+ gem 'guard-rspec', '~> 4.5.0', :require => false if RUBY_VERSION >= '1.9.0'
22
+ gem 'guard-rake', '~> 1.0.0', :require => false if RUBY_VERSION >= '1.9.0'
23
+ gem 'guard-rubocop', '~> 1.2.0', :require => false if RUBY_VERSION >= '1.9.0'
24
+ gem 'pry-byebug', '~> 3.1.0', :require => false if RUBY_VERSION > '2.0.0'
25
+ end
26
+
27
+ # rubocop:enable Style/HashSyntax
28
+
29
+ local_gemfile = File.join(File.dirname(__FILE__), 'Gemfile.local')
30
+ eval_gemfile local_gemfile if File.exist?(local_gemfile)
31
+
32
+ # vim:ft=ruby
data/Guardfile ADDED
@@ -0,0 +1,49 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ directories %w(lib spec)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ clearing :on
9
+
10
+ ignore /coverage/
11
+
12
+ guard :rspec, cmd: "bundle exec rspec" do
13
+ require "guard/rspec/dsl"
14
+ dsl = Guard::RSpec::Dsl.new(self)
15
+
16
+ # Feel free to open issues for suggestions and improvements
17
+
18
+ # RSpec files
19
+ rspec = dsl.rspec
20
+ watch(rspec.spec_helper) { rspec.spec_dir }
21
+ watch(rspec.spec_support) { rspec.spec_dir }
22
+ watch(rspec.spec_files)
23
+
24
+ # Ruby files
25
+ ruby = dsl.ruby
26
+ dsl.watch_spec_files_for(ruby.lib_files)
27
+
28
+ # Turnip features and steps
29
+ watch(%r{^spec/acceptance/(.+)\.feature$})
30
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
31
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
32
+ end
33
+ end
34
+
35
+ guard :bundler do
36
+ watch('Gemfile')
37
+ # Uncomment next line if Gemfile contain `gemspec' command
38
+ watch(/^.+\.gemspec/)
39
+ end
40
+
41
+ guard :rake, :task => 'inch', :all_on_start => false do
42
+ watch(%r{^lib/(.+).rb$})
43
+ end
44
+
45
+ guard :rubocop do
46
+ watch(%{^Rakefile$})
47
+ watch(%r{.+\.rb$})
48
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
49
+ end
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ puppet-herald-client gem
2
+ ========
3
+
4
+ [![GitHub Issues](https://img.shields.io/github/issues/wavesoftware/gem-puppet-herald-client.svg)](https://github.com/wavesoftware/gem-puppet-herald-client/issues) [![Gem](http://img.shields.io/gem/v/puppet-herald-client.svg)](https://rubygems.org/gems/puppet-herald-client) [![GitHub Release](https://img.shields.io/github/release/wavesoftware/gem-puppet-herald-client.svg)](https://github.com/wavesoftware/gem-puppet-herald-client/releases) [![Apache 2.0 License](http://img.shields.io/badge/license-Apache%202.0-green.svg)](https://raw.githubusercontent.com/wavesoftware/gem-puppet-herald-client/develop/LICENSE) [![Build Status](https://img.shields.io/travis/wavesoftware/gem-puppet-herald-client/master.svg)](https://travis-ci.org/wavesoftware/gem-puppet-herald-client) [![Dependency Status](https://gemnasium.com/wavesoftware/gem-puppet-herald-client.svg)](https://gemnasium.com/wavesoftware/gem-puppet-herald-client) [![Coverage Status](https://img.shields.io/coveralls/wavesoftware/gem-puppet-herald-client/master.svg)](https://coveralls.io/r/wavesoftware/gem-puppet-herald-client?branch=master) [![Code Climate](https://codeclimate.com/github/wavesoftware/gem-puppet-herald-client/badges/gpa.svg?branch=master)](https://codeclimate.com/github/wavesoftware/gem-puppet-herald-client) [![Inline docs](http://inch-ci.org/github/wavesoftware/gem-puppet-herald-client.svg?branch=master)](http://inch-ci.org/github/wavesoftware/gem-puppet-herald-client)
5
+
6
+ Overview
7
+ --------
8
+
9
+ This is a client for [Herald](https://github.com/wavesoftware/gem-puppet-herald). Herald is a puppet report processor. He provides a gateway for consuming puppet reports, a REST API and a simple Web app to display reports.
10
+
11
+
12
+ ###Contributing
13
+
14
+ Contributions are welcome!
15
+
16
+ To contribute, follow the standard [git flow](http://danielkummer.github.io/git-flow-cheatsheet/) of:
17
+
18
+ 1. Fork it
19
+ 1. Create your feature branch (`git checkout -b feature/my-new-feature`)
20
+ 1. Commit your changes (`git commit -am 'Add some feature'`)
21
+ 1. Push to the branch (`git push origin feature/my-new-feature`)
22
+ 1. Create new Pull Request
23
+
24
+ Even if you can't contribute code, if you have an idea for an improvement please open an [issue](https://github.com/wavesoftware/gem-puppet-herald/issues).
data/Rakefile ADDED
@@ -0,0 +1,90 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'fileutils'
3
+ require 'coveralls'
4
+
5
+ def cobertura_attrs
6
+ require 'ox'
7
+ f = File.open 'coverage/javascript/cobertura.xml'
8
+ Ox.parse(f.read).root.attributes
9
+ end
10
+
11
+ def verify_js_coverage(line_expected = 0.9, branch_expected = 0.9)
12
+ attrs = cobertura_attrs
13
+ fail "Line coverage is #{attrs[:'line-rate'].to_f * 100}%, " \
14
+ "that don't meet minimum requirements of #{line_expected * 100}%." if attrs[:'line-rate'].to_f < line_expected
15
+
16
+ fail "Branch coverage is #{attrs[:'branch-rate'].to_f * 100}%, " \
17
+ "that don't meet minimum requirements of #{branch_expected * 100}%." if attrs[:'branch-rate'].to_f < branch_expected
18
+ end
19
+
20
+ namespace :spec do
21
+ desc 'Run all spec tests at once.'
22
+ RSpec::Core::RakeTask.new(:all)
23
+
24
+ desc 'Run unit spec tests.'
25
+ RSpec::Core::RakeTask.new(:unit) do |t|
26
+ t.pattern = [
27
+ 'spec/unit'
28
+ ]
29
+ end
30
+
31
+ desc 'Run integration spec tests.'
32
+ RSpec::Core::RakeTask.new(:integration) do |t|
33
+ t.pattern = [
34
+ 'spec/zzz_integration'
35
+ ]
36
+ end
37
+ end
38
+
39
+ tests = [:'spec:all']
40
+
41
+ begin
42
+ require 'rubocop/rake_task'
43
+ require 'rubocop'
44
+ RuboCop::RakeTask.new(:rubocop) do |task|
45
+ # don't abort rake on failure
46
+ task.fail_on_error = true
47
+ end
48
+
49
+ namespace :rubocop do
50
+ namespace :todo do
51
+ desc 'Cleans a rubocop TODO list'
52
+ task :clean do
53
+ File.write('.rubocop_todo.yml', '')
54
+ Rake::Task[:rubocop].execute
55
+ end
56
+
57
+ desc 'Saves actual rubocop state into TODO list'
58
+ task :save do
59
+ rcli = RuboCop::CLI.new
60
+ rcli.run ['--auto-gen-config']
61
+ end
62
+ end
63
+ end
64
+ tests << :rubocop
65
+ rescue Gem::LoadError, LoadError # rubocop:disable Lint/HandleExceptions
66
+ # do nothing
67
+ end
68
+
69
+ begin
70
+ require 'inch/rake'
71
+ Inch::Rake::Suggest.new :inch, '--pedantic'
72
+ tests << :inch
73
+ rescue Gem::LoadError, LoadError # rubocop:disable Lint/HandleExceptions
74
+ # do nothing here
75
+ end
76
+
77
+ Coveralls.wear! if ENV['TRAVIS']
78
+
79
+ desc 'Run lint, and all spec tests.'
80
+ task :test => tests # rubocop:disable Style/HashSyntax
81
+
82
+ desc 'Build a gem package.'
83
+ task :gem do
84
+ sh 'gem build *.gemspec'
85
+ end
86
+
87
+ desc 'Builds, and test package'
88
+ task :build => [:test, :gem] # rubocop:disable Style/HashSyntax
89
+
90
+ task :default => :test # rubocop:disable Style/HashSyntax
@@ -0,0 +1,33 @@
1
+ require 'net/http'
2
+
3
+ # A module for Herald
4
+ module PuppetHerald
5
+ # A client class for Herald
6
+ class Client
7
+ # Constructs a client
8
+ #
9
+ # @param host [String] a host to connect to, default to +'localhost'+
10
+ # @param port [Integer] a port to connect to, default to +11303+
11
+ # @return [PuppetHerald::Client] a client instance
12
+ def initialize(host = 'localhost', port = 11_303)
13
+ @host = host
14
+ @port = port
15
+ self
16
+ end
17
+
18
+ # Process a puppet report and sends it to Herald
19
+ #
20
+ # @param report [Puppet::Transaction::Report] a puppet report
21
+ # @param block [Proc] a optional block that can modify request before sending
22
+ # @return [Boolean] true if everything is ok
23
+ def process(report, &block)
24
+ path = '/api/v1/reports'
25
+ header = { 'Content-Type' => 'application/yaml' }
26
+ req = Net::HTTP::Post.new(path, initheader = header) # rubocop:disable all
27
+ req.body = report.to_yaml
28
+ block.call(req) if block
29
+ Net::HTTP.new(@host, @port).start { |http| http.request(req) }
30
+ true
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ # A module for Herald
2
+ module PuppetHerald
3
+ # Prepare version
4
+ #
5
+ # @param desired [String] a desired version
6
+ # @return [String] a prepared version
7
+ def self.version_prep(desired)
8
+ version = desired
9
+ if desired.match(/[^0-9\.]+/)
10
+ git = `git describe --tags --dirty --always`
11
+ version += '.' + git.gsub('-', '.')
12
+ end
13
+ version.strip
14
+ end
15
+
16
+ # Version for Herald Client
17
+ VERSION = version_prep '1.0.0'
18
+ # Lincense for Herald Client
19
+ LICENSE = 'Apache-2.0'
20
+ # Project name
21
+ NAME = 'Puppet Herald Client'
22
+ # Package (gem) for Herald Client
23
+ PACKAGE = 'puppet-herald-client'
24
+ # A summary info
25
+ SUMMARY = 'a client for Puppet report processor'
26
+ # A description info
27
+ DESCRIPTION = 'Provides a client for Puppet Herald'
28
+ # A homepage for Herald
29
+ HOMEPAGE = 'https://github.com/wavesoftware/gem-puppet-herald-client'
30
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ ROOT = Pathname.new(File.expand_path('../', __FILE__))
4
+ LIB = Pathname.new('lib/puppet-herald')
5
+ ph = ROOT.join(LIB)
6
+ require ph.join('version')
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = PuppetHerald::PACKAGE
10
+ gem.version = PuppetHerald::VERSION
11
+ gem.author = 'Krzysztof Suszynski'
12
+ gem.email = 'krzysztof.suszynski@wavesoftware.pl'
13
+ gem.license = PuppetHerald::LICENSE
14
+ gem.homepage = PuppetHerald::HOMEPAGE
15
+ gem.summary = PuppetHerald::SUMMARY
16
+ gem.description = PuppetHerald::DESCRIPTION
17
+
18
+ gem.files = `git ls-files`.split("\n")
19
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ gem.require_paths = ['lib']
21
+
22
+ # Dependencies
23
+ gem.required_ruby_version = '>= 1.8.7'
24
+
25
+ # Runtime
26
+ # gem.add_runtime_dependency 'package'
27
+ end
28
+
29
+ # vim:ft=ruby
@@ -0,0 +1,34 @@
1
+
2
+ begin
3
+ gem 'simplecov'
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_filter '/test/'
7
+ add_filter '/spec/'
8
+ add_filter '/.vendor/'
9
+ add_filter '/vendor/'
10
+ add_filter '/gems/'
11
+ add_filter '/node_modules/'
12
+ add_filter '/coverage/'
13
+ add_group 'Models', 'lib/puppet-herald/models'
14
+ add_group 'App', 'lib/puppet-herald/app'
15
+ minimum_coverage 95
16
+ maximum_coverage_drop 3
17
+ coverage_dir 'coverage/ruby'
18
+ end
19
+ rescue Gem::LoadError
20
+ # do nothing
21
+ end
22
+
23
+ begin
24
+ gem 'pry'
25
+ require 'pry'
26
+ rescue Gem::LoadError
27
+ # do nothing
28
+ end
29
+
30
+ RSpec.configure do |c|
31
+ c.expect_with :rspec do |mock|
32
+ mock.syntax = [:expect, :should]
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+ require 'webmock/rspec'
3
+ require 'puppet-herald/client'
4
+
5
+ describe PuppetHerald::Client, '.process' do
6
+ let(:payload) { { :zz => 65, :yh => 12 } }
7
+ let(:expected) { payload.to_yaml }
8
+ before :each do
9
+ stub_request(:post, "#{address}/api/v1/reports").with(:body => expected).
10
+ to_return(:body => "{id: 1}", :status => 201)
11
+ end
12
+ subject { client.process payload }
13
+ context 'on defaults' do
14
+ let(:address) { 'localhost:11303' }
15
+ let(:client) { PuppetHerald::Client.new }
16
+ it { expect(subject).to be_truthy }
17
+ end
18
+ context 'on other host:port' do
19
+ let(:address) { 'master.secure.vm:8082' }
20
+ let(:client) { PuppetHerald::Client.new('master.secure.vm', 8082) }
21
+ it { expect(subject).to be_truthy }
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'puppet-herald/version'
3
+
4
+ describe PuppetHerald, '.version_prep' do
5
+ context 'on stable version v1.2.3' do
6
+ subject { PuppetHerald::version_prep '1.2.3' }
7
+ it { subject.should eq '1.2.3' }
8
+ end
9
+ context 'on unstable version v1.2.3.pre' do
10
+ subject { PuppetHerald::version_prep '1.2.3.pre' }
11
+ it { subject.should match /^1\.2\.3\.pre\.v\d+\.\d+\.\d+(?:\.\d+\.g[0-9a-f]{7}(?:\.dirty)?)?$/ }
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puppet-herald-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Krzysztof Suszynski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Provides a client for Puppet Herald
14
+ email: krzysztof.suszynski@wavesoftware.pl
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - ".rspec"
21
+ - ".rubocop.yml"
22
+ - ".rubocop_todo.yml"
23
+ - ".travis.yml"
24
+ - Gemfile
25
+ - Guardfile
26
+ - LICENSE
27
+ - README.md
28
+ - Rakefile
29
+ - lib/puppet-herald/client.rb
30
+ - lib/puppet-herald/version.rb
31
+ - puppet-herald-client.gemspec
32
+ - spec/spec_helper.rb
33
+ - spec/unit/puppet-herald/client_spec.rb
34
+ - spec/unit/puppet-herald/version_spec.rb
35
+ homepage: https://github.com/wavesoftware/gem-puppet-herald-client
36
+ licenses:
37
+ - Apache-2.0
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.8.7
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.2.2
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: a client for Puppet report processor
59
+ test_files: []
60
+ has_rdoc: