chef-dk 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/chef-dk/authenticated_http.rb +40 -0
  4. data/lib/chef-dk/chef_runner.rb +5 -0
  5. data/lib/chef-dk/command/exec.rb +4 -1
  6. data/lib/chef-dk/command/generate.rb +11 -0
  7. data/lib/chef-dk/command/generator_commands.rb +20 -365
  8. data/lib/chef-dk/command/generator_commands/app.rb +99 -0
  9. data/lib/chef-dk/command/generator_commands/attribute.rb +37 -0
  10. data/lib/chef-dk/command/generator_commands/base.rb +76 -0
  11. data/lib/chef-dk/command/generator_commands/cookbook.rb +100 -0
  12. data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +99 -0
  13. data/lib/chef-dk/command/generator_commands/cookbook_file.rb +45 -0
  14. data/lib/chef-dk/command/generator_commands/lwrp.rb +36 -0
  15. data/lib/chef-dk/command/generator_commands/recipe.rb +36 -0
  16. data/lib/chef-dk/command/generator_commands/repo.rb +96 -0
  17. data/lib/chef-dk/command/generator_commands/template.rb +45 -0
  18. data/lib/chef-dk/command/verify.rb +28 -0
  19. data/lib/chef-dk/component_test.rb +16 -3
  20. data/lib/chef-dk/cookbook_omnifetch.rb +2 -0
  21. data/lib/chef-dk/cookbook_profiler/identifiers.rb +3 -15
  22. data/lib/chef-dk/exceptions.rb +15 -0
  23. data/lib/chef-dk/generator.rb +102 -25
  24. data/lib/chef-dk/policyfile/community_cookbook_source.rb +0 -7
  25. data/lib/chef-dk/policyfile/{cookbook_spec.rb → cookbook_location_specification.rb} +35 -6
  26. data/lib/chef-dk/policyfile/cookbook_locks.rb +305 -0
  27. data/lib/chef-dk/policyfile/dsl.rb +26 -12
  28. data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +70 -0
  29. data/lib/chef-dk/policyfile/solution_dependencies.rb +204 -0
  30. data/lib/chef-dk/policyfile/storage_config.rb +77 -0
  31. data/lib/chef-dk/policyfile/uploader.rb +110 -0
  32. data/lib/chef-dk/policyfile_compiler.rb +59 -29
  33. data/lib/chef-dk/policyfile_lock.rb +104 -160
  34. data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -1
  35. data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +0 -1
  36. data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +66 -0
  37. data/lib/chef-dk/skeletons/code_generator/files/default/repo/Rakefile +65 -0
  38. data/lib/chef-dk/skeletons/code_generator/files/default/repo/certificates/README.md +19 -0
  39. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README-policy.md +9 -0
  40. data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/README.md +54 -0
  41. data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +63 -0
  42. data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +5 -0
  43. data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +16 -0
  44. data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +7 -1
  45. data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +62 -0
  46. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -0
  47. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.apache2.erb +201 -0
  48. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -0
  49. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -0
  50. data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -0
  51. data/lib/chef-dk/skeletons/code_generator/templates/default/default_recipe.rb.erb +1 -4
  52. data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +3 -3
  53. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/config/rake.rb.erb +38 -0
  54. data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -0
  55. data/lib/chef-dk/version.rb +1 -1
  56. data/spec/shared/a_file_generator.rb +121 -0
  57. data/spec/shared/a_generated_file.rb +12 -0
  58. data/spec/shared/fixture_cookbook_checksums.rb +47 -0
  59. data/spec/spec_helper.rb +4 -2
  60. data/spec/unit/chef_runner_spec.rb +12 -5
  61. data/spec/unit/cli_spec.rb +4 -4
  62. data/spec/unit/command/base_spec.rb +1 -1
  63. data/spec/unit/command/exec_spec.rb +37 -27
  64. data/spec/unit/command/generate_spec.rb +3 -3
  65. data/spec/unit/command/generator_commands/app_spec.rb +131 -0
  66. data/spec/unit/command/generator_commands/attribute_spec.rb +32 -0
  67. data/spec/unit/command/generator_commands/cookbook_file_spec.rb +32 -0
  68. data/spec/unit/command/generator_commands/cookbook_spec.rb +205 -0
  69. data/spec/unit/command/generator_commands/lwrp_spec.rb +32 -0
  70. data/spec/unit/command/generator_commands/recipe_spec.rb +32 -0
  71. data/spec/unit/command/generator_commands/repo_spec.rb +287 -0
  72. data/spec/unit/command/generator_commands/template_spec.rb +32 -0
  73. data/spec/unit/command/shell_init_spec.rb +4 -4
  74. data/spec/unit/command/verify_spec.rb +9 -9
  75. data/spec/unit/commands_map_spec.rb +1 -1
  76. data/spec/unit/component_test_spec.rb +3 -3
  77. data/spec/unit/cookbook_profiler/git_spec.rb +7 -7
  78. data/spec/unit/cookbook_profiler/identifiers_spec.rb +12 -8
  79. data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +1 -1
  80. data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +1 -1
  81. data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +1 -1
  82. data/spec/unit/fixtures/example_cookbook/Berksfile +1 -1
  83. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +4 -0
  84. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +96 -0
  85. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +8 -0
  86. data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +8 -0
  87. data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +1 -1
  88. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -0
  89. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -0
  90. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -0
  91. data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -0
  92. data/spec/unit/generator_spec.rb +120 -0
  93. data/spec/unit/policyfile/{cookbook_spec_spec.rb → cookbook_location_specification_spec.rb} +83 -38
  94. data/spec/unit/policyfile/cookbook_locks_spec.rb +354 -0
  95. data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +85 -0
  96. data/spec/unit/policyfile/solution_dependencies_spec.rb +145 -0
  97. data/spec/unit/policyfile/storage_config_spec.rb +98 -0
  98. data/spec/unit/policyfile/uploader_spec.rb +292 -0
  99. data/spec/unit/policyfile_demands_spec.rb +177 -24
  100. data/spec/unit/policyfile_evaluation_spec.rb +40 -12
  101. data/spec/unit/{policyfile_builder_spec.rb → policyfile_lock_build_spec.rb} +179 -64
  102. data/spec/unit/policyfile_lock_install_spec.rb +138 -0
  103. data/spec/unit/policyfile_lock_validation_spec.rb +610 -0
  104. metadata +103 -59
  105. data/spec/unit/command/generator_commands_spec.rb +0 -504
@@ -0,0 +1,36 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef-dk/command/generator_commands/cookbook_code_file'
19
+
20
+ module ChefDK
21
+ module Command
22
+ module GeneratorCommands
23
+ # chef generate lwrp [path/to/cookbook_root] NAME
24
+ class LWRP < CookbookCodeFile
25
+
26
+ banner "Usage: chef generate lwrp [path/to/cookbook] NAME [options]"
27
+
28
+ options.merge!(SharedGeneratorOptions.options)
29
+
30
+ def recipe
31
+ 'lwrp'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef-dk/command/generator_commands/cookbook_code_file'
19
+
20
+ module ChefDK
21
+ module Command
22
+ module GeneratorCommands
23
+ # chef generate recipe [path/to/cookbook/root] name
24
+ class Recipe < CookbookCodeFile
25
+
26
+ banner "Usage: chef generate recipe [path/to/cookbook] NAME [options]"
27
+
28
+ options.merge!(SharedGeneratorOptions.options)
29
+
30
+ def recipe
31
+ 'recipe'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,96 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef-dk/command/generator_commands/base'
19
+
20
+ module ChefDK
21
+ module Command
22
+ module GeneratorCommands
23
+
24
+ # ## Repo
25
+ # chef generate repo path/to/basename --generator-cookbook=path/to/generator --policy-only
26
+ #
27
+ # Generates a full "chef-repo" directory structure.
28
+ class Repo < Base
29
+
30
+ banner "Usage: chef generate repo NAME [options]"
31
+
32
+ attr_reader :errors
33
+ attr_reader :repo_name_or_path
34
+
35
+ option :policy_only,
36
+ :short => "-p",
37
+ :long => "--policy-only",
38
+ :description => "Create a repository for policy only, not cookbooks",
39
+ :default => false
40
+
41
+ options.merge!(SharedGeneratorOptions.options)
42
+
43
+ def initialize(params)
44
+ @params_valid = true
45
+ @repo_name = nil
46
+ super
47
+ end
48
+
49
+ def run
50
+ read_and_validate_params
51
+ if params_valid?
52
+ setup_context
53
+ chef_runner.converge
54
+ else
55
+ msg(banner)
56
+ 1
57
+ end
58
+ end
59
+
60
+ def setup_context
61
+ super
62
+ Generator.add_attr_to_context(:repo_root, repo_root)
63
+ Generator.add_attr_to_context(:repo_name, repo_name)
64
+ end
65
+
66
+ def recipe
67
+ "repo"
68
+ end
69
+
70
+ def repo_name
71
+ File.basename(repo_full_path)
72
+ end
73
+
74
+ def repo_root
75
+ File.dirname(repo_full_path)
76
+ end
77
+
78
+ def repo_full_path
79
+ File.expand_path(repo_name_or_path, Dir.pwd)
80
+ end
81
+
82
+ def read_and_validate_params
83
+ arguments = parse_options(params)
84
+ @repo_name_or_path = arguments[0]
85
+ @params_valid = false unless @repo_name_or_path
86
+ end
87
+
88
+ def params_valid?
89
+ @params_valid
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+
@@ -0,0 +1,45 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require 'chef-dk/command/generator_commands/cookbook_code_file'
19
+
20
+ module ChefDK
21
+ module Command
22
+ module GeneratorCommands
23
+ # chef generate template [path/to/cookbook_root] name --source=source_file
24
+ class Template < CookbookCodeFile
25
+
26
+ option :content_source,
27
+ :short => "-s SOURCE_FILE",
28
+ :long => "--source SOURCE_FILE",
29
+ :description => "Copy content from SOURCE_FILE"
30
+
31
+ banner "Usage: chef generate template [path/to/cookbook] NAME [options]"
32
+
33
+ options.merge!(SharedGeneratorOptions.options)
34
+
35
+ def recipe
36
+ 'template'
37
+ end
38
+
39
+ def setup_context
40
+ super
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -114,6 +114,34 @@ module ChefDK
114
114
  c.smoke_test { run_in_tmpdir("chef generate cookbook example") }
115
115
  end
116
116
 
117
+ add_component "chefspec" do |c|
118
+ c.gem_base_dir = "chefspec"
119
+ c.unit_test { sh("rake unit") }
120
+ c.smoke_test do
121
+ tmpdir do |cwd|
122
+ FileUtils.mkdir(File.join(cwd, "spec"))
123
+ File.open(File.join(cwd, "spec", "spec_helper.rb"), "w+") do |f|
124
+ f.write <<-EOF
125
+ require 'chefspec'
126
+ require 'chefspec/berkshelf'
127
+ require 'chefspec/cacher'
128
+
129
+ RSpec.configure do |config|
130
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
131
+ end
132
+ EOF
133
+ end
134
+ FileUtils.touch(File.join(cwd, "Berksfile"))
135
+ File.open(File.join(cwd, "spec", "foo_spec.rb"), "w+") do |f|
136
+ f.write <<-EOF
137
+ require 'spec_helper'
138
+ EOF
139
+ end
140
+ sh("rspec", cwd: cwd)
141
+ end
142
+ end
143
+ end
144
+
117
145
  attr_reader :verification_threads
118
146
  attr_reader :verification_results
119
147
  attr_reader :verification_status
@@ -50,6 +50,8 @@ module ChefDK
50
50
  @unit_test = DEFAULT_TEST
51
51
  @integration_test = DEFAULT_TEST
52
52
  @smoke_test = DEFAULT_TEST
53
+ @base_dir = nil
54
+ @gem_name_for_base_dir = nil
53
55
  end
54
56
 
55
57
  def unit_test(&test_block)
@@ -118,11 +120,22 @@ module ChefDK
118
120
  end
119
121
 
120
122
  def component_path
121
- File.join(omnibus_apps_dir, base_dir)
123
+ if base_dir
124
+ File.join(omnibus_apps_dir, base_dir)
125
+ elsif gem_base_dir
126
+ gem_base_dir
127
+ else
128
+ raise "`base_dir` or `gem_base_dir` must be defined for component `#{name}`"
129
+ end
130
+ end
131
+
132
+ def gem_base_dir
133
+ return nil if @gem_name_for_base_dir.nil?
134
+ Gem::Specification::find_by_name(@gem_name_for_base_dir).gem_dir
122
135
  end
123
136
 
124
- def base_dir
125
- @base_dir or raise "`base_dir` must be defined for component `#{name}`"
137
+ def gem_base_dir=(gem_name)
138
+ @gem_name_for_base_dir = gem_name
126
139
  end
127
140
 
128
141
  def omnibus_root
@@ -19,6 +19,8 @@ require 'cookbook-omnifetch'
19
19
  require 'chef-dk/shell_out'
20
20
  require 'chef-dk/cookbook_metadata'
21
21
 
22
+ require 'chef/http/simple'
23
+
22
24
  # Configure CookbookOmnifetch's dependency injection settings to use our classes and config.
23
25
  CookbookOmnifetch.configure do |c|
24
26
  c.cache_path = File.expand_path('~/.chefdk/cache')
@@ -23,10 +23,10 @@ module ChefDK
23
23
  module CookbookProfiler
24
24
  class Identifiers
25
25
 
26
- attr_reader :cookbook_path
26
+ attr_reader :cookbook_version
27
27
 
28
- def initialize(cookbook_path)
29
- @cookbook_path = cookbook_path
28
+ def initialize(cookbook_version)
29
+ @cookbook_version = cookbook_version
30
30
  end
31
31
 
32
32
  def semver_version
@@ -62,18 +62,6 @@ module ChefDK
62
62
  @files ||= cookbook_version.manifest_records_by_path
63
63
  end
64
64
 
65
- def cookbook_version
66
- @cookbook_version ||= cookbook_loader.cookbook_version
67
- end
68
-
69
- def cookbook_loader
70
- @cookbook_loader ||=
71
- begin
72
- loader = Chef::Cookbook::CookbookVersionLoader.new(cookbook_path)
73
- loader.load_cookbooks
74
- loader
75
- end
76
- end
77
65
  end
78
66
  end
79
67
  end
@@ -26,6 +26,18 @@ module ChefDK
26
26
  class MalformedCookbook < StandardError
27
27
  end
28
28
 
29
+ class DependencyConflict < StandardError
30
+ end
31
+
32
+ class CookbookNotInWorkingSet < DependencyConflict
33
+ end
34
+
35
+ class InvalidCookbookLockData < StandardError
36
+ end
37
+
38
+ class CachedCookbookModified < StandardError
39
+ end
40
+
29
41
  class MissingComponentError < RuntimeError
30
42
  def initialize(component_name)
31
43
  super("Component #{component_name} is missing.")
@@ -43,4 +55,7 @@ module ChefDK
43
55
 
44
56
  class PolicyfileError < StandardError
45
57
  end
58
+
59
+ class MissingCookbookLockData < StandardError
60
+ end
46
61
  end
@@ -19,22 +19,11 @@ module ChefDK
19
19
 
20
20
  module Generator
21
21
 
22
+ # This is here to hold attr_accessor data for Generator context variables
22
23
  class Context
23
-
24
- attr_accessor :have_git
25
-
26
- attr_accessor :app_root
27
- attr_accessor :cookbook_root
28
- attr_accessor :app_name
29
- attr_accessor :cookbook_name
30
- attr_accessor :new_file_basename
31
- attr_accessor :content_source
32
- attr_accessor :author_name
33
- attr_accessor :author_email
34
- attr_accessor :license_description
35
- attr_accessor :license_text
36
-
37
- attr_accessor :skip_git_init
24
+ def self.add_attr(name)
25
+ attr_accessor(name)
26
+ end
38
27
  end
39
28
 
40
29
  def self.reset
@@ -45,6 +34,13 @@ module ChefDK
45
34
  @context ||= Context.new
46
35
  end
47
36
 
37
+ def self.add_attr_to_context(name, value=nil)
38
+ sym_name = name.to_sym
39
+ ChefDK::Generator::Context.add_attr(sym_name)
40
+ ChefDK::Generator::TemplateHelper.delegate_to_app_context(sym_name)
41
+ context.public_send("#{sym_name}=", value)
42
+ end
43
+
48
44
  module TemplateHelper
49
45
 
50
46
  def self.delegate_to_app_context(name)
@@ -53,17 +49,98 @@ module ChefDK
53
49
  end
54
50
  end
55
51
 
56
- # delegate all the attributes of app_config
57
- delegate_to_app_context :app_root
58
- delegate_to_app_context :cookbook_root
59
- delegate_to_app_context :cookbook_name
60
- delegate_to_app_context :new_file_basename
61
- delegate_to_app_context :content_source
62
- delegate_to_app_context :author_name
63
- delegate_to_app_context :author_email
64
- delegate_to_app_context :license_description
65
- delegate_to_app_context :license_text
52
+ def year
53
+ Time.now.year
54
+ end
55
+
56
+ # Prints the short description of the license, suitable for use in a
57
+ # preamble to a file. Optionally specify a comment to prepend to each line.
58
+ def license_description(comment=nil)
59
+ case license
60
+ when 'all_rights'
61
+ result = "Copyright (c) #{year} #{copyright_holder}, All Rights Reserved."
62
+ when 'apache2'
63
+ result = <<-EOH
64
+ Copyright #{year} #{copyright_holder}
65
+
66
+ Licensed under the Apache License, Version 2.0 (the "License");
67
+ you may not use this file except in compliance with the License.
68
+ You may obtain a copy of the License at
69
+
70
+ http://www.apache.org/licenses/LICENSE-2.0
71
+
72
+ Unless required by applicable law or agreed to in writing, software
73
+ distributed under the License is distributed on an "AS IS" BASIS,
74
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
75
+ See the License for the specific language governing permissions and
76
+ limitations under the License.
77
+ EOH
78
+ when 'mit'
79
+ result = <<-EOH
80
+ The MIT License (MIT)
81
+
82
+ Copyright (c) #{year} #{copyright_holder}
66
83
 
84
+ Permission is hereby granted, free of charge, to any person obtaining a copy
85
+ of this software and associated documentation files (the "Software"), to deal
86
+ in the Software without restriction, including without limitation the rights
87
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
88
+ copies of the Software, and to permit persons to whom the Software is
89
+ furnished to do so, subject to the following conditions:
90
+
91
+ The above copyright notice and this permission notice shall be included in
92
+ all copies or substantial portions of the Software.
93
+
94
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
95
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
96
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
97
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
98
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
99
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
100
+ THE SOFTWARE.
101
+ EOH
102
+ when 'gplv2'
103
+ result = <<-EOH
104
+ Copyright (C) #{year} #{copyright_holder}
105
+
106
+ This program is free software; you can redistribute it and/or modify
107
+ it under the terms of the GNU General Public License as published by
108
+ the Free Software Foundation; either version 2 of the License, or
109
+ (at your option) any later version.
110
+
111
+ This program is distributed in the hope that it will be useful,
112
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
113
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
114
+ GNU General Public License for more details.
115
+
116
+ You should have received a copy of the GNU General Public License along
117
+ with this program; if not, write to the Free Software Foundation, Inc.,
118
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
119
+ EOH
120
+ when 'gplv3'
121
+ result = <<-EOH
122
+ Copyright (C) #{year} #{copyright_holder}
123
+
124
+ This program is free software: you can redistribute it and/or modify
125
+ it under the terms of the GNU General Public License as published by
126
+ the Free Software Foundation, either version 3 of the License, or
127
+ (at your option) any later version.
128
+
129
+ This program is distributed in the hope that it will be useful,
130
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
131
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132
+ GNU General Public License for more details.
133
+
134
+ You should have received a copy of the GNU General Public License
135
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
136
+ EOH
137
+ end
138
+ if comment
139
+ result.gsub(/^/m, "#{comment} ")
140
+ else
141
+ result
142
+ end
143
+ end
67
144
  end
68
145
 
69
146
  end