knife-cookbook-readme 0.1.2 → 0.1.3

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: a22fbf6290e37c8c038ef2df5c4d02f71de5d862
4
+ data.tar.gz: bc71a063b422222a8b1e54bedc82fef90dc44e4d
5
+ SHA512:
6
+ metadata.gz: 23c18204dd65d728e9c972c05b1d7dee6fd46efbd8bd063bbb7e7472126f18fafaaea6df5c799913b3a4c62232c8a5a4f27df303afb6d496c20aea5e3b27989d
7
+ data.tar.gz: 7c5ceab3877c69dc5b9d66b9a4b54c20881aa7e99a6db182800b4f942995bb76ca2df404a0e75c6994d53e62017720489c77dfb882b00d92621dd4c80552d457
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.8.7
5
+ - 1.9.3
6
+ - 2.0.0
7
+
8
+ install: bundle install
9
+
10
+ script: bundle exec rake spec
11
+
12
+ branches:
13
+ only:
14
+ - master
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ v0.1.3 (Sep 15 2013)
2
+ --------------------
3
+
4
+ * Add RSpec tests, including Rake task and Travis CI config.
5
+
6
+ README updates:
7
+
8
+ * Link to Opscode's metadata docs.
9
+ * Say that knife-cookbook-doc is based on knife-cookbook-readme.
10
+ * Add contributing guidelines.
11
+
1
12
  v0.1.2 (Jul 17 2013)
2
13
  --------------------
3
14
 
data/README.md CHANGED
@@ -2,9 +2,7 @@ knife-cookbook-readme
2
2
  =====================
3
3
 
4
4
  This is a Knife plugin to generate a skeleton `README.md` file from a cookbook's
5
- `metadata.rb` file.
6
-
7
- The plugin helps to
5
+ [metadata.rb](http://docs.opscode.com/essentials_cookbook_metadata.html) file.
8
6
 
9
7
  - create the first bits of documentation you can build upon
10
8
  - write documentation that is consistent among your or your team's cookbooks
@@ -55,7 +53,8 @@ Alternatives
55
53
  Here is a list of other documentation tools for Chef (sorted alphabetically):
56
54
 
57
55
  * [knife-cookbook-doc](https://github.com/realityforge/knife-cookbook-doc)
58
- ([blog post](http://realityforge.org/code/2013/04/01/documenting-cookbooks.html))
56
+ (based on knife-cookbook-readme,
57
+ [blog post](http://realityforge.org/code/2013/04/01/documenting-cookbooks.html))
59
58
  * [yard-chef](https://github.com/rightscale/yard-chef)
60
59
 
61
60
 
@@ -75,6 +74,16 @@ See the License for the specific language governing permissions and
75
74
  limitations under the License.
76
75
 
77
76
 
77
+ Contributing
78
+ ------------
79
+
80
+ 1. Fork it
81
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
82
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
83
+ 4. Push to the branch (`git push origin my-new-feature`)
84
+ 5. Create new Pull Request
85
+
86
+
78
87
  Contact
79
88
  -------
80
89
 
data/Rakefile CHANGED
@@ -1,6 +1,11 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/clean'
3
-
4
- task :default => :build
3
+ require 'rspec/core/rake_task'
5
4
 
6
5
  CLEAN.include 'pkg'
6
+
7
+ RSpec::Core::RakeTask.new(:spec) do |t|
8
+ t.rspec_opts = '--color --format documentation'
9
+ end
10
+
11
+ task :default => :spec
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'erubis'
21
21
 
22
22
  s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'rspec', '~> 2.14'
23
24
  end
@@ -1,3 +1,3 @@
1
1
  module KnifeCookbookReadme
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -0,0 +1,142 @@
1
+ require File.expand_path("../../lib/knife_cookbook_readme/readme_model", __FILE__)
2
+ require "erubis"
3
+
4
+ module KnifeCookbookReadme
5
+ describe ReadmeModel do
6
+ it "generates title from cookbook name" do
7
+ cookbook_name = "cats"
8
+ metadata = double(:metadata, :name => cookbook_name)
9
+ model = ReadmeModel.new(metadata)
10
+ model.title.should == "Cats Cookbook"
11
+ end
12
+
13
+ it "generates description" do
14
+ description = double
15
+ metadata = double(:metadata, :description => description)
16
+ model = ReadmeModel.new(metadata)
17
+ model.description.should == description
18
+ end
19
+
20
+ it "generates recipes" do
21
+ recipes = double
22
+ metadata = double(:metadata, :recipes => recipes)
23
+ model = ReadmeModel.new(metadata)
24
+ model.recipes.should == recipes
25
+ end
26
+
27
+ it "generates cookbook attributes" do
28
+ attributes = {
29
+ "pets/cat/name" => {
30
+ "description" => "The name of your cat",
31
+ "default" => "Kitty",
32
+ },
33
+ "pets/dog/name" => {
34
+ "description" => "The name of your dog",
35
+ "default" => "Barf",
36
+ }
37
+ }
38
+ metadata = double(:metadata, :attributes => attributes)
39
+ model = ReadmeModel.new(metadata)
40
+ model.attributes.sort.should == [
41
+ ["node['pets']['cat']['name']", "The name of your cat", "Kitty"],
42
+ ["node['pets']['dog']['name']", "The name of your dog", "Barf"],
43
+ ]
44
+ end
45
+
46
+ context "supported platforms" do
47
+ let(:metadata) do
48
+ platforms = { "debian" => "= 7", "ubuntu" => ">= 10.04" }
49
+ double(:metadata, :platforms => platforms)
50
+ end
51
+
52
+ it "generates platforms with version constraints" do
53
+ constraints = true
54
+ model = ReadmeModel.new(metadata, constraints)
55
+ model.platforms.sort.should == ["Debian (= 7)", "Ubuntu (>= 10.04)"]
56
+ end
57
+
58
+ it "generates platforms without version constraints" do
59
+ constraints = false
60
+ model = ReadmeModel.new(metadata, constraints)
61
+ model.platforms.sort.should == ["Debian", "Ubuntu"]
62
+ end
63
+ end
64
+
65
+ context "cookbook dependencies" do
66
+ let(:metadata) do
67
+ dependencies = {
68
+ "cats" => "< 1.0",
69
+ "dogs" => ReadmeModel::DEFAULT_CONSTRAINT,
70
+ }
71
+ double(:metadata, :dependencies => dependencies)
72
+ end
73
+
74
+ it "generates dependencies with version constraints" do
75
+ constraints = true
76
+ model = ReadmeModel.new(metadata, constraints)
77
+ model.dependencies.sort.should == ["cats (< 1.0)", "dogs"]
78
+ end
79
+
80
+ it "generates dependencies without version constraints" do
81
+ constraints = false
82
+ model = ReadmeModel.new(metadata, constraints)
83
+ model.dependencies.sort.should == ["cats", "dogs"]
84
+ end
85
+ end
86
+
87
+ context "license and author" do
88
+ it "generates author from maintainer name" do
89
+ maintainer = double
90
+ metadata = double(:metadata, :maintainer => maintainer)
91
+ model = ReadmeModel.new(metadata)
92
+ model.author.should == maintainer
93
+ end
94
+
95
+ it "generates author email from maintainer email" do
96
+ maintainer_email = double
97
+ metadata = double(:metadata, :maintainer_email => maintainer_email)
98
+ model = ReadmeModel.new(metadata)
99
+ model.author_email.should == maintainer_email
100
+ end
101
+
102
+ it "generates copyright year from current year" do
103
+ time_now = Time.mktime(2013, 1, 1)
104
+ Time.stub(:now).and_return(time_now)
105
+ metadata = double
106
+ model = ReadmeModel.new(metadata)
107
+ model.copyright_year.should == time_now.year
108
+ end
109
+
110
+ it "generates license name" do
111
+ license = double
112
+ metadata = double(:metadata, :license => license)
113
+ model = ReadmeModel.new(metadata)
114
+ model.license.should == license
115
+ end
116
+ end
117
+
118
+ # TODO: implement ReadmeModel#render
119
+ context "template rendering" do
120
+ it "can be rendered with erubis" do
121
+ metadata = double(:metadata,
122
+ :name => "cats",
123
+ :description => "Manages a herd of cats!")
124
+ model = ReadmeModel.new(metadata)
125
+ template = <<EOS
126
+ <%= title %>
127
+ <%= '=' * title.length %>
128
+
129
+ <%= description %>
130
+ EOS
131
+ eruby = Erubis::Eruby.new(template)
132
+ result = eruby.result(model.get_binding)
133
+ result.should == <<EOS
134
+ Cats Cookbook
135
+ =============
136
+
137
+ Manages a herd of cats!
138
+ EOS
139
+ end
140
+ end
141
+ end
142
+ end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cookbook-readme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mathias Lafeldt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-17 00:00:00.000000000 Z
11
+ date: 2013-09-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: chef
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: erubis
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,11 +48,24 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
62
69
  description: Knife plugin to generate README.md from metadata.rb
63
70
  email:
64
71
  - mathias.lafeldt@gmail.com
@@ -67,6 +74,7 @@ extensions: []
67
74
  extra_rdoc_files: []
68
75
  files:
69
76
  - .gitignore
77
+ - .travis.yml
70
78
  - CHANGELOG.md
71
79
  - Gemfile
72
80
  - LICENSE
@@ -76,36 +84,31 @@ files:
76
84
  - lib/chef/knife/cookbook_readme_from.rb
77
85
  - lib/knife_cookbook_readme/readme_model.rb
78
86
  - lib/knife_cookbook_readme/version.rb
87
+ - spec/readme_model_spec.rb
79
88
  - template/README.md.erb
80
89
  homepage: http://mlafeldt.github.com/knife-cookbook-readme
81
90
  licenses:
82
91
  - Apache 2.0
92
+ metadata: {}
83
93
  post_install_message:
84
94
  rdoc_options: []
85
95
  require_paths:
86
96
  - lib
87
97
  required_ruby_version: !ruby/object:Gem::Requirement
88
- none: false
89
98
  requirements:
90
99
  - - '>='
91
100
  - !ruby/object:Gem::Version
92
101
  version: '0'
93
- segments:
94
- - 0
95
- hash: -921780819663544875
96
102
  required_rubygems_version: !ruby/object:Gem::Requirement
97
- none: false
98
103
  requirements:
99
104
  - - '>='
100
105
  - !ruby/object:Gem::Version
101
106
  version: '0'
102
- segments:
103
- - 0
104
- hash: -921780819663544875
105
107
  requirements: []
106
108
  rubyforge_project:
107
- rubygems_version: 1.8.25
109
+ rubygems_version: 2.0.7
108
110
  signing_key:
109
- specification_version: 3
111
+ specification_version: 4
110
112
  summary: Knife plugin to generate README.md from metadata.rb
111
- test_files: []
113
+ test_files:
114
+ - spec/readme_model_spec.rb