qddrud 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 55ced2a77a6c4babdbd328d60236760600393f4e
4
+ data.tar.gz: 9d01f03fe09fd48632582807ec6df77b9f2eed7b
5
+ SHA512:
6
+ metadata.gz: 889b9929238f1fd36bcf4080f4e9b5212189c59eec0a1eae3288fb606ce2e05aea81914dbedecefd323201a9e90fc9bf1a68298e2a77b1ce44b6744dbad94a9d
7
+ data.tar.gz: b80a4411db211978bcc958d22b197686f4966144a96bc42da3c9bee64203a780117f44fd3c9d3f68aa7318e6e09bfa8628db654900e9a9f6d91a64ce88605fbe
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .DS_Store
19
+ *.bundle
20
+ *.so
21
+ *.o
22
+ *.a
23
+ mkmf.log
24
+ html
@@ -0,0 +1,4 @@
1
+ AllCops:
2
+ Include:
3
+ - Gemfile
4
+ - Rakefile
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 NewMedia Denver
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Drud
2
+
3
+ Evaluates an opscode chef cookbook's [metadata](https://github.com/cyberswat){http://docs.opscode.com/essentials_cookbook_metadata.html} and [github](https://github.com/) history to generate a README.md file. The README.md is placed in the root level of the cookbook. This forces cookbook developers to properly use metadata to document their cookbooks efficiently. Additionally, it provides proper attribution for all committers in the project with links back to the contributors github profile. It is written to take advantage of cookbooks that properly utilize both Rake tasks and metadata.
4
+
5
+ You can see this in use in our cookbooks. Our reference cookbook is https://github.com/newmediadenver/nmd-skeletor
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'drud'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install drud
20
+
21
+ ## Usage
22
+
23
+ Here's an example rake task that could be placed in your cookbooks Rake file.
24
+
25
+ desc 'Generate the Readme.md file.'
26
+ task :readme do
27
+ drud = Drud::Readme.new(File.dirname(__FILE__))
28
+ drud.render
29
+ end
30
+
31
+ If you set the environment variable `DRUD_OAUTH` to a
32
+ [Github Applicaiton access tokent](https://help.github.com/articles/creating-an-access-token-for-command-line-use)
33
+ that token will be used to authenticate the Octokit client and allow access to private repos.
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/[my-github-username]/drud/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rspec/core/rake_task'
4
+ require 'rdoc/task'
5
+
6
+ desc "Build the Gem"
7
+ task :build do
8
+ sh 'gem build qddrud.gemspec'
9
+ end
10
+
11
+ desc "Release the Gem"
12
+ task :release => :build do
13
+ sh "gem push qddrud-0.1.0.gem"
14
+ end
15
+
16
+ RDoc::Task.new do |rdoc|
17
+ rdoc.main = 'README.rdoc'
18
+ rdoc.rdoc_files.include('lib/*.rb', 'lib/drud/*.rb')
19
+ end
20
+
21
+ desc 'Run rspec tests'
22
+ RSpec::Core::RakeTask.new(:spec)
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require 'qddrud/version'
3
+ require 'qddrud/readme'
@@ -0,0 +1,95 @@
1
+ require 'chef/cookbook/metadata'
2
+ require 'erb'
3
+ require 'ostruct'
4
+
5
+ module Qddrud
6
+ # Constructs a new ERB object for rendering a Readme.md file.
7
+ class ReadmeTemplate < OpenStruct
8
+ # Desribe the behaviour of the method
9
+ #
10
+ # ==== Attributes
11
+ #
12
+ # * +:template+ - The template to render against.
13
+ #
14
+ # ==== Examples
15
+ # Assuming this is the content of template.erb:
16
+ # My metadata is <%= metadata %>
17
+ # You would render it with the following:
18
+ # markdown = ReadmeTemplate.new(metadata: @metadata)
19
+ # markdown.render(File.read('template.erb'))
20
+ def render(template)
21
+ ERB.new(template).result(binding)
22
+ end
23
+ end
24
+ # Evaluates an opscode chef cookbook's
25
+ # {metadata}[http://docs.opscode.com/essentials_cookbook_metadata.html] and
26
+ # {github}[https://github.com/] history to generate a README.md file. The
27
+ # README.rb is placed in the root level of the cookbook. This forces cookbook
28
+ # developers to properly use metadata to document their cookbooks
29
+ # efficiently. Additionally, it provides proper attribution for all
30
+ # committers in the project with links back to the contributors github
31
+ # profile. It is written to take advantage of cookbooks that properly utilize
32
+ # both Rake tasks and metadata.
33
+ class Readme
34
+ # Hash map of all site cookbooks including metadata
35
+ attr_accessor :cookbooks
36
+
37
+ # Path to the site-cookbooks
38
+ attr_accessor :path
39
+
40
+ # Initialize a new instance of Drud::Readme
41
+ #
42
+ # ==== Attributes
43
+ #
44
+ # * +:path+ - The local path of the site cookbooks
45
+ #
46
+ # ==== Examples
47
+ # This can be placed in a convenient location, such as a Rake task inside
48
+ # the cookbook. When the render method is called, it will overwrite the
49
+ # cookbooks README.md
50
+ # readme = Drud::Readme.new(File.dirname(__FILE__))
51
+ # readme.render
52
+ def initialize(path)
53
+ @path = File.expand_path(path)
54
+ @cookbooks = load_cookbooks
55
+ end
56
+
57
+ # Renders the README.md file and saves it in the cookbooks path.
58
+ def render
59
+ markdown = ReadmeTemplate.new(
60
+ metadata: @metadata, tasks: @tasks, credit: @credit
61
+ )
62
+ template_path = File.join(
63
+ File.dirname(File.expand_path(__FILE__)),
64
+ '../../templates/readme.md.erb'
65
+ )
66
+ readme = markdown.render(File.read(template_path))
67
+ File.open("#{@cookbook}/README.md", 'w') { |file| file.write(readme) }
68
+ end
69
+
70
+ private
71
+ # Generates a hash of all site cookbook metadata by cookbook folder name
72
+ def load_cookbooks # :doc:
73
+ _cookbooks = Hash.new
74
+
75
+ Dir.glob(File.join(@path, '*/*.rb')).each do |cb_metadata|
76
+ cb_path = File.dirname(cb_metadata)
77
+ cb_name = File.basename(cb_path)
78
+ _cookbooks[cb_name] = [
79
+ 'path' => cb_path,
80
+ 'metadata' => load_metadata(cb_metadata)
81
+ ]
82
+ end
83
+
84
+ _cookbooks
85
+ end
86
+
87
+ # Reads the cookbooks metadata and instantiates an instance of
88
+ # Chef::Cookbook::Metadata
89
+ def load_metadata(cb_metadata) # :doc:
90
+ metadata = Chef::Cookbook::Metadata.new
91
+ metadata.from_file(cb_metadata)
92
+ metadata
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,6 @@
1
+ # The Drud module contains general functionality written to help our developers
2
+ # be more efficient.
3
+ module Qddrud
4
+ # The drud version number.
5
+ VERSION = '0.1.1'
6
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'qddrud/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'qddrud'
8
+ spec.version = Qddrud::VERSION
9
+ spec.authors = ['Jon Bogaty']
10
+ spec.email = ['jon@jonbogaty.com']
11
+ spec.required_ruby_version = '>= 2.1.2'
12
+ spec.summary = 'Generates the README.md file for Chef cookbooks.'
13
+ desc = 'Quick and dirty Drud local-mode only supporting grokking of an entire site-cookbook directory worth of metadata'
14
+
15
+ spec.description = desc
16
+ spec.homepage = 'https://github.com/newmediadenver/qddrud'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = `git ls-files -z`.split("\x0")
20
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'chef', '~> 12.4', '>= 12.4.1'
25
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Drud do
4
+ it 'does stuff' do
5
+ pending # no code yet
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter 'vendor/'
5
+ end
6
+ require 'drud'
@@ -0,0 +1,37 @@
1
+ <%= metadata.maintainer %>'s <%= metadata.name %> cookbook
2
+ =============================
3
+
4
+ <%= metadata.name %> (<%= metadata.version %>) <%= metadata.description %>
5
+
6
+ Requirements
7
+ ------------
8
+
9
+ ### Platforms
10
+ <% metadata.platforms.each do |os, version| %>
11
+ `<%= os %> <%= version %>`
12
+ <% end %>
13
+ ### Dependencies
14
+ <% metadata.dependencies.each do |os, version| %>
15
+ `<%= os %> <%= version %>`
16
+ <% end %>
17
+
18
+ Attributes
19
+ ----------
20
+ <% metadata.attributes.each do |name, values| %>
21
+ <%= name %>
22
+ calculated: <%= values['calculated'] %>
23
+ choice: <%= values['choice'].inspect %>
24
+ default: <%= values['default'] %>
25
+ description: <%= values['description'] %>
26
+ display_name: <%= values['display_name'] %>
27
+ type: <%= values['type'] %>
28
+ recipes: <%= values['recipes'].inspect %>
29
+ required: <%= values['required'] %>
30
+ <% end %>
31
+
32
+ Recipes
33
+ -------
34
+ <% metadata.recipes.each do |name, desc| %>
35
+ <%= name %>
36
+ <%= desc %>
37
+ <% end %>
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qddrud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jon Bogaty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.4'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 12.4.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '12.4'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 12.4.1
33
+ description: Quick and dirty Drud local-mode only supporting grokking of an entire
34
+ site-cookbook directory worth of metadata
35
+ email:
36
+ - jon@jonbogaty.com
37
+ executables: []
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - ".gitignore"
42
+ - ".rubocop.yml"
43
+ - Gemfile
44
+ - LICENSE.txt
45
+ - README.md
46
+ - Rakefile
47
+ - lib/qddrud.rb
48
+ - lib/qddrud/readme.rb
49
+ - lib/qddrud/version.rb
50
+ - qddrud.gemspec
51
+ - spec/drud_spec.rb
52
+ - spec/spec_helper.rb
53
+ - templates/readme.md.erb
54
+ homepage: https://github.com/newmediadenver/qddrud
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.1.2
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.5
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Generates the README.md file for Chef cookbooks.
78
+ test_files:
79
+ - spec/drud_spec.rb
80
+ - spec/spec_helper.rb