copyright-header 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -35,24 +35,24 @@ Usage
35
35
 
36
36
  Full list of supported arguments:
37
37
 
38
- Usage: copyright-header options [file]
38
+ Usage: bin/copyright-header options [file]
39
39
  -n, --dry-run Output the parsed files to STDOUT
40
40
  -o, --output-dir DIR Use DIR as output directory
41
- --license-file FILE Use FILE as header
42
- --license [GPL3|MIT] Use LICENSE as header
41
+ --license-file FILE Use FILE as header (instead of using --license argument)
42
+ --license [AGPL3|BSD-2-CLAUSE|BSD-3-CLAUSE|BSD-4-CLAUSE|GPL3|MIT]
43
+ Use LICENSE as header
43
44
  --copyright-software NAME The common name for this piece of software (e.g. "Copyright Header")
44
45
  --copyright-software-description DESC
45
46
  The common name for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")
46
47
  --copyright-holder NAME The common name for this piece of software (e.g. "Erik Osterman <e@osterman.com>"). Repeat argument for multiple names.
47
48
  --copyright-year YEAR The common name for this piece of software (e.g. "2012"). Repeat argument for multiple years.
48
49
  -w, --word-wrap LEN Maximum number of characters per line for license (default: 80)
49
- -a, --add-path PATH Recursively insert header in all files found in path
50
- -r, --remove-path PATH Recursively remove header in all files found in path
50
+ -a, --add-path PATH Recursively insert header in all files found in path (allows multiple pathes separated by platform path-separator)
51
+ -r, --remove-path PATH Recursively remove header in all files found in path (allows multiple pathes separated by platform path-separator)
51
52
  -c, --syntax FILE Syntax configuration file
52
53
  -V, --version Display version information
53
54
  -h, --help Display this screen
54
55
 
55
-
56
56
  Examples
57
57
  --------
58
58
 
@@ -84,6 +84,30 @@ Paths can be either files or directories. It will recursively traverse the direc
84
84
 
85
85
  You can specify an alternative syntax configuration file using the `--syntax` argument.
86
86
 
87
+ Rake
88
+ ----
89
+
90
+ the above example as rake task inside a Rakefile:
91
+
92
+ task :headers do
93
+ require 'rubygems'
94
+ require 'copyright_header'
95
+
96
+ args = {
97
+ :license => 'GPL3',
98
+ :copyright_software => 'Copyright Header',
99
+ :copyright_software_description => "A utility to manipulate copyright headers on source code files",
100
+ :copyright_holders => ['Erik Osterman <e@osterman.com>'],
101
+ :copyright_years => ['2012'],
102
+ :add_path => 'lib',
103
+ :output_dir => '.'
104
+ }
105
+
106
+ command_line = CopyrightHeader::CommandLine.new( args )
107
+ command_line.execute
108
+ end
109
+
110
+
87
111
  Contributors
88
112
  ------------
89
113
 
@@ -21,17 +21,18 @@ require 'optparse'
21
21
 
22
22
  module CopyrightHeader
23
23
  class MissingArgumentException < Exception; end
24
+ class AmbiguousArgumentException < Exception; end
24
25
 
25
26
  class CommandLine
26
27
  attr_accessor :options, :parser, :optparse
27
28
  def initialize(options = {})
28
29
  begin
29
30
  @options = options
30
- @options[:base_path] = File.expand_path File.dirname(__FILE__) + "/../../"
31
+ @options[:base_path] ||= File.expand_path File.dirname(__FILE__) + "/../../"
31
32
  @optparse = OptionParser.new do |opts|
32
33
  opts.banner = "Usage: #{$0} options [file]"
33
34
 
34
- @options[:dry_run] = false
35
+ @options[:dry_run] ||= false
35
36
  opts.on( '-n', '--dry-run', 'Output the parsed files to STDOUT' ) do
36
37
  @options[:dry_run] = true
37
38
  end
@@ -40,13 +41,12 @@ module CopyrightHeader
40
41
  @options[:output_dir] = dir + '/'
41
42
  end
42
43
 
43
- opts.on( '--license-file FILE', 'Use FILE as header' ) do|file|
44
+ opts.on( '--license-file FILE', 'Use FILE as header (instead of using --license argument)' ) do|file|
44
45
  @options[:license_file] = file
45
46
  end
46
47
 
47
48
  opts.on( '--license [' + Dir.glob(@options[:base_path] + '/licenses/*').map { |f| File.basename(f, '.erb') }.join('|') + ']', 'Use LICENSE as header' ) do|license|
48
49
  @options[:license] = license
49
- @options[:license_file] = @options[:base_path] + '/licenses/' + license + '.erb'
50
50
  end
51
51
 
52
52
  opts.on( '--copyright-software NAME', 'The common name for this piece of software (e.g. "Copyright Header")' ) do|name|
@@ -57,30 +57,30 @@ module CopyrightHeader
57
57
  @options[:copyright_software_description] = desc
58
58
  end
59
59
 
60
- @options[:copyright_holders] = []
60
+ @options[:copyright_holders] ||= []
61
61
  opts.on( '--copyright-holder NAME', 'The common name for this piece of software (e.g. "Erik Osterman <e@osterman.com>"). Repeat argument for multiple names.' ) do|name|
62
62
  @options[:copyright_holders] << name
63
63
  end
64
64
 
65
- @options[:copyright_years] = []
65
+ @options[:copyright_years] ||= []
66
66
  opts.on( '--copyright-year YEAR', 'The common name for this piece of software (e.g. "2012"). Repeat argument for multiple years.' ) do|year|
67
67
  @options[:copyright_years] << year
68
68
  end
69
69
 
70
- @options[:word_wrap] = 80
70
+ @options[:word_wrap] ||= 80
71
71
  opts.on( '-w', '--word-wrap LEN', 'Maximum number of characters per line for license (default: 80)' ) do |len|
72
72
  @options[:word_wrap] = len.to_i
73
73
  end
74
74
 
75
- opts.on( '-a', '--add-path PATH', 'Recursively insert header in all files found in path' ) do |path|
75
+ opts.on( '-a', '--add-path PATH', 'Recursively insert header in all files found in path (allows multiple pathes separated by platform path-separator)' ) do |path|
76
76
  @options[:add_path] = path
77
77
  end
78
78
 
79
- opts.on( '-r', '--remove-path PATH', 'Recursively remove header in all files found in path' ) do |path|
79
+ opts.on( '-r', '--remove-path PATH', 'Recursively remove header in all files found in path (allows multiple pathes separated by platform path-separator)' ) do |path|
80
80
  @options[:remove_path] = path
81
81
  end
82
82
 
83
- @options[:syntax] = @options[:base_path] + '/contrib/syntax.yml'
83
+ @options[:syntax] ||= @options[:base_path] + '/contrib/syntax.yml'
84
84
  opts.on( '-c', '--syntax FILE', 'Syntax configuration file' ) do |path|
85
85
  @options[:syntax] = path
86
86
  end
@@ -101,6 +101,15 @@ module CopyrightHeader
101
101
  end
102
102
 
103
103
  @optparse.parse!
104
+
105
+ unless @options[:license].nil?
106
+ unless @options[:license_file].nil?
107
+ raise AmbiguousArgumentException.new("Cannot pass both --license and --license-file arguments")
108
+ end
109
+ # get the license_file from the shiped files
110
+ @options[:license_file] ||= @options[:base_path] + '/licenses/' + @options[:license] + '.erb'
111
+ end
112
+
104
113
  unless @options.has_key?(:license_file)
105
114
  raise MissingArgumentException.new("Missing --license or --license-file argument")
106
115
  end
@@ -176,11 +176,11 @@ module CopyrightHeader
176
176
 
177
177
  def execute
178
178
  if @options.has_key?(:add_path)
179
- add(@options[:add_path])
179
+ @options[:add_path].split(File::PATH_SEPARATOR).each { |path| add(path) }
180
180
  end
181
181
 
182
182
  if @options.has_key?(:remove_path)
183
- remove(@options[:remove_path])
183
+ @options[:add_path].split(File::PATH_SEPARATOR).each { |path| remove(path) }
184
184
  end
185
185
  end
186
186
 
@@ -18,5 +18,5 @@
18
18
  # along with Copyright Header. If not, see <http://www.gnu.org/licenses/>.
19
19
  #
20
20
  module CopyrightHeader
21
- VERSION = "1.0.5"
21
+ VERSION = "1.0.7"
22
22
  end
@@ -0,0 +1,17 @@
1
+ <%=copyright_software%> - <%=copyright_software_description%>
2
+ Copyright (C) <%=copyright_years.join(', ')%> <%=copyright_holders.join(', ')%>
3
+
4
+ This file is part of <%=copyright_software%>.
5
+
6
+ <%=copyright_software%> is free software: you can redistribute it and/or modify
7
+ it under the terms of the GNU Affero General Public License as
8
+ published by the Free Software Foundation, either version 3 of the
9
+ License, or (at your option) any later version.
10
+
11
+ <%=copyright_software%> is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU Affero General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Affero General Public License
17
+ along with <%=copyright_software%>. If not, see <http://www.gnu.org/licenses/>.
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copyright-header
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
7
6
  - 1
8
7
  - 0
9
- - 5
10
- version: 1.0.5
8
+ - 7
9
+ version: 1.0.7
11
10
  platform: ruby
12
11
  authors:
13
12
  - Erik Osterman
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-10-16 00:00:00 -07:00
17
+ date: 2012-12-04 00:00:00 -08:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
@@ -45,6 +44,7 @@ files:
45
44
  - lib/copyright_header/command_line.rb
46
45
  - lib/copyright_header/parser.rb
47
46
  - lib/copyright_header/version.rb
47
+ - licenses/AGPL3.erb
48
48
  - licenses/BSD-2-CLAUSE.erb
49
49
  - licenses/BSD-3-CLAUSE.erb
50
50
  - licenses/BSD-4-CLAUSE.erb
@@ -60,27 +60,23 @@ rdoc_options: []
60
60
  require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
63
  requirements:
65
64
  - - ">="
66
65
  - !ruby/object:Gem::Version
67
- hash: 3
68
66
  segments:
69
67
  - 0
70
68
  version: "0"
71
69
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
70
  requirements:
74
71
  - - ">="
75
72
  - !ruby/object:Gem::Version
76
- hash: 3
77
73
  segments:
78
74
  - 0
79
75
  version: "0"
80
76
  requirements: []
81
77
 
82
78
  rubyforge_project: copyright-header
83
- rubygems_version: 1.3.7
79
+ rubygems_version: 1.3.6
84
80
  signing_key:
85
81
  specification_version: 3
86
82
  summary: A utility to insert copyright headers into various types of source code files