copyright-header 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,6 +16,7 @@ Caveats
16
16
  -------
17
17
  * Will only remove headers to files that have exactly the same header as the one we added
18
18
  * Will only add headers to files which do not contain the case-sensitive pattern `/[Cc]opyright|[Lc]icense/` in the first `N` lines
19
+ * Will not properly format arguments that contain new-line ("`\n`") characters.
19
20
 
20
21
  Requirements
21
22
  ------------
@@ -35,17 +36,17 @@ Usage
35
36
 
36
37
  Full list of supported arguments:
37
38
 
38
- Usage: bin/copyright-header options [file]
39
+ Usage: copyright-header options [file]
39
40
  -n, --dry-run Output the parsed files to STDOUT
40
41
  -o, --output-dir DIR Use DIR as output directory
41
42
  --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
+ --license [AGPL3|ASL2|BSD-2-CLAUSE|BSD-3-CLAUSE|BSD-4-CLAUSE|GPL3|MIT]
43
44
  Use LICENSE as header
44
45
  --copyright-software NAME The common name for this piece of software (e.g. "Copyright Header")
45
46
  --copyright-software-description DESC
46
- The common name for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")
47
- --copyright-holder NAME The common name for this piece of software (e.g. "Erik Osterman <e@osterman.com>"). Repeat argument for multiple names.
48
- --copyright-year YEAR The common name for this piece of software (e.g. "2012"). Repeat argument for multiple years.
47
+ The detailed description for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")
48
+ --copyright-holder NAME The legal owner of the copyright for the software. (e.g. "Erik Osterman <e@osterman.com>"). Repeat argument for multiple names.
49
+ --copyright-year YEAR The years for which the copyright exists (e.g. "2012"). Repeat argument for multiple years.
49
50
  -w, --word-wrap LEN Maximum number of characters per line for license (default: 80)
50
51
  -a, --add-path PATH Recursively insert header in all files found in path (allows multiple paths separated by platform path-separator ":")
51
52
  -r, --remove-path PATH Recursively remove header in all files found in path (allows multiple paths separated by platform path-separator ":")
@@ -54,7 +55,6 @@ Full list of supported arguments:
54
55
  -V, --version Display version information
55
56
  -h, --help Display this screen
56
57
 
57
-
58
58
  Examples
59
59
  --------
60
60
 
@@ -64,11 +64,25 @@ Discover available parameters by passing the `--help` argument
64
64
 
65
65
  Add a GPL3 License header to a file:
66
66
 
67
- copyright-header --add-path /tmp/test.rb --license GPL3 --dry-run
67
+ copyright-header --add-path /tmp/test.rb \
68
+ --license GPL3 \
69
+ --copyright-holder 'Joe Shmoe' \
70
+ --copyright-software 'Example Software' \
71
+ --copyright-software-description "This is the description of the software." \
72
+ --copyright-year 2012 \
73
+ --output-dir /tmp \
74
+ --dry-run
68
75
 
69
76
  Remove the header created in the previous step (without --dry-run argument):
70
77
 
71
- copyright-header --remove-path /tmp/test.rb --license GPL3 --dry-run
78
+ copyright-header --remove-path /tmp/test.rb \
79
+ --license GPL3 \
80
+ --copyright-holder 'Joe Shmoe' \
81
+ --copyright-software 'Example Software' \
82
+ --copyright-software-description 'This is the description of the software.' \
83
+ --copyright-year 2012 \
84
+ --output-dir /tmp \
85
+ --dry-run
72
86
 
73
87
  Command used to generate copyright headers for this script:
74
88
 
data/contrib/syntax.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ruby:
2
- ext: ['.rb']
2
+ ext: ['.rb', '.rake']
3
3
  after: ['^#!', '^#.*encoding:']
4
4
  comment:
5
5
  open: '#\n'
@@ -14,7 +14,6 @@ perl:
14
14
  close: '#\n'
15
15
  prefix: '# '
16
16
 
17
-
18
17
  # Support PEP 0263 comments:
19
18
  # coding=<encoding name>
20
19
  # -*- coding: <encoding name> -*-
@@ -42,7 +41,6 @@ php:
42
41
  close: ' */ ?>\n'
43
42
  prefix: ' * '
44
43
 
45
-
46
44
  javacript:
47
45
  ext: ['.js']
48
46
  comment:
@@ -57,7 +55,6 @@ css:
57
55
  close: ' */\n\n'
58
56
  prefix: ' * '
59
57
 
60
-
61
58
  c:
62
59
  ext: ['.c', '.h']
63
60
  comment:
@@ -80,7 +77,7 @@ java:
80
77
  prefix: ' * '
81
78
 
82
79
  haml:
83
- ext: ['.haml']
80
+ ext: ['.haml', '.hamlc']
84
81
  comment:
85
82
  open: '-#\n'
86
83
  close: '-#\n'
@@ -122,9 +119,24 @@ sql:
122
119
  # preprocessing directive, if present.
123
120
  # FIXME: only supports single line directives
124
121
  xml:
125
- ext: ['.xml', '.xsd']
122
+ ext: ['.xml', '.xsd', '.mxml']
126
123
  after: ['^<\?']
127
124
  comment:
128
125
  open: '<!--\n'
129
126
  close: '-->\n'
130
127
  prefix: ' '
128
+
129
+ yaml:
130
+ ext: ['.yml', '.yaml']
131
+ comment:
132
+ open: '#\n'
133
+ close: '#\n'
134
+ prefix: '# '
135
+
136
+ action_script:
137
+ ext: ['.as']
138
+ comment:
139
+ open: '//\n'
140
+ close: '//\n\n'
141
+ prefix: '// '
142
+
@@ -38,7 +38,7 @@ module CopyrightHeader
38
38
  end
39
39
 
40
40
  opts.on( '-o', '--output-dir DIR', 'Use DIR as output directory') do |dir|
41
- @options[:output_dir] = dir + '/'
41
+ @options[:output_dir] = dir.gsub(/\/+$/, '')
42
42
  end
43
43
 
44
44
  opts.on( '--license-file FILE', 'Use FILE as header (instead of using --license argument)' ) do|file|
@@ -53,17 +53,17 @@ module CopyrightHeader
53
53
  @options[:copyright_software] = name
54
54
  end
55
55
 
56
- opts.on( '--copyright-software-description DESC', 'The common name for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")' ) do|desc|
56
+ opts.on( '--copyright-software-description DESC', 'The detailed description for this piece of software (e.g. "A utility to manipulate copyright headers on source code files")' ) do|desc|
57
57
  @options[:copyright_software_description] = desc
58
58
  end
59
59
 
60
60
  @options[:copyright_holders] ||= []
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|
61
+ opts.on( '--copyright-holder NAME', 'The legal owner of the copyright for the 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
65
  @options[:copyright_years] ||= []
66
- opts.on( '--copyright-year YEAR', 'The common name for this piece of software (e.g. "2012"). Repeat argument for multiple years.' ) do|year|
66
+ opts.on( '--copyright-year YEAR', 'The years for which the copyright exists (e.g. "2012"). Repeat argument for multiple years.' ) do|year|
67
67
  @options[:copyright_years] << year
68
68
  end
69
69
 
@@ -91,11 +91,11 @@ module CopyrightHeader
91
91
  end
92
92
 
93
93
  opts.on( '-V', '--version', 'Display version information' ) do
94
- puts "CopyrightHeader #{CopyrightHeader::VERSION}"
95
- puts "Copyright (C) 2012 Erik Osterman <e@osterman.com>"
96
- puts "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"
97
- puts "This is free software: you are free to change and redistribute it."
98
- puts "There is NO WARRANTY, to the extent permitted by law."
94
+ STDERR.puts "CopyrightHeader #{CopyrightHeader::VERSION}",
95
+ "Copyright (C) 2012 Erik Osterman <e@osterman.com>",
96
+ "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>",
97
+ "This is free software: you are free to change and redistribute it.",
98
+ "There is NO WARRANTY, to the extent permitted by law."
99
99
  exit
100
100
  end
101
101
 
@@ -130,13 +130,13 @@ module CopyrightHeader
130
130
  raise MissingArgumentException.new("Missing --copyright-year argument") unless @options[:copyright_years].length > 0
131
131
  end
132
132
  rescue MissingArgumentException => e
133
- puts e.message
134
- puts @optparse
133
+ STDERR.puts e.message, @optparse
135
134
  exit (1)
136
135
  end
137
136
  end
138
137
 
139
138
  def execute
139
+ STDERR.puts "-- DRY RUN --" if @options[:dry_run]
140
140
  @parser = CopyrightHeader::Parser.new(@options)
141
141
  @parser.execute
142
142
  end
@@ -82,7 +82,7 @@ module CopyrightHeader
82
82
 
83
83
  copyright = self.format(license)
84
84
  if copyright.nil?
85
- puts "Copyright is nil"
85
+ STDERR.puts "Copyright is nil"
86
86
  return nil
87
87
  end
88
88
 
@@ -121,7 +121,7 @@ module CopyrightHeader
121
121
  @contents.gsub!(/#{Regexp.escape(text)}/, '')
122
122
  @contents
123
123
  else
124
- puts "SKIP #{@file}; copyright not detected"
124
+ STDERR.puts "SKIP #{@file}; copyright not detected"
125
125
  return nil
126
126
  end
127
127
  end
@@ -206,11 +206,11 @@ module CopyrightHeader
206
206
  begin
207
207
  if File.file?(path)
208
208
  if @exclude.include? File.basename(path)
209
- puts "SKIP #{path}; excluded"
209
+ STDERR.puts "SKIP #{path}; excluded"
210
210
  next
211
211
  end
212
212
  else
213
- puts "SKIP #{path}; not file"
213
+ STDERR.puts "SKIP #{path}; not file"
214
214
  next
215
215
  end
216
216
 
@@ -218,15 +218,15 @@ module CopyrightHeader
218
218
  header = @syntax.header(path)
219
219
  contents = header.send(method, @license)
220
220
  if contents.nil?
221
- puts "SKIP #{path}; failed to generate license"
221
+ STDERR.puts "SKIP #{path}; failed to generate license"
222
222
  else
223
223
  write(path, contents)
224
224
  end
225
225
  else
226
- puts "SKIP #{path}; unsupported"
226
+ STDERR.puts "SKIP #{path}; unsupported"
227
227
  end
228
228
  rescue Exception => e
229
- puts "SKIP #{path}; #{e.message}"
229
+ STDERR.puts "SKIP #{path}; #{e.message}"
230
230
  end
231
231
  end
232
232
  end
@@ -242,11 +242,15 @@ module CopyrightHeader
242
242
  end
243
243
 
244
244
  def write(file, contents)
245
- puts "UPDATE #{file}"
246
- if @options[:dry_run] || @options[:output_dir].nil?
247
- puts contents
245
+ if @options[:dry_run]
246
+ STDERR.puts "UPDATE #{file} [dry-run]"
247
+ STDERR.puts contents
248
+ elsif @options[:output_dir].nil?
249
+ STDERR.puts "UPDATE #{file} [no output-dir]"
250
+ STDERR.puts contents
248
251
  else
249
- dir = "#{@options[:output_dir]}/#{File.dirname(file)}"
252
+ dir = "#{@options[:output_dir]}/#{File.dirname(file).gsub(/^\/+/, '')}"
253
+ STDERR.puts "UPDATE #{file} [output-dir #{dir}]"
250
254
  FileUtils.mkpath dir unless File.directory?(dir)
251
255
  output_path = @options[:output_dir] + file
252
256
  f =File.new(output_path, 'w')
@@ -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.11"
21
+ VERSION = "1.0.12"
22
22
  end
metadata CHANGED
@@ -1,45 +1,49 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: copyright-header
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.11
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 12
9
+ version: 1.0.12
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Erik Osterman
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2013-09-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-11-12 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: github-linguist
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 2.6.7
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
27
25
  - - ~>
28
- - !ruby/object:Gem::Version
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 6
30
+ - 7
29
31
  version: 2.6.7
30
- description: A utility which is able to recursively insert and remove copyright headers
31
- from source code files based on file extensions.
32
- email:
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: A utility which is able to recursively insert and remove copyright headers from source code files based on file extensions.
35
+ email:
33
36
  - e@osterman.com
34
- executables:
37
+ executables:
35
38
  - copyright-header
36
39
  extensions: []
37
- extra_rdoc_files:
40
+
41
+ extra_rdoc_files:
38
42
  - README.md
39
43
  - LICENSE
40
44
  - AUTHORS
41
45
  - contrib/syntax.yml
42
- files:
46
+ files:
43
47
  - .gitignore
44
48
  - AUTHORS
45
49
  - Gemfile
@@ -60,29 +64,35 @@ files:
60
64
  - licenses/BSD-4-CLAUSE.erb
61
65
  - licenses/GPL3.erb
62
66
  - licenses/MIT.erb
67
+ has_rdoc: true
63
68
  homepage: https://github.com/osterman/copyright-header
64
- licenses:
69
+ licenses:
65
70
  - GPL-3
66
71
  post_install_message:
67
72
  rdoc_options: []
68
- require_paths:
73
+
74
+ require_paths:
69
75
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
73
- - - ! '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
- requirements:
79
- - - ! '>='
80
- - !ruby/object:Gem::Version
81
- version: '0'
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
82
90
  requirements: []
91
+
83
92
  rubyforge_project: copyright-header
84
- rubygems_version: 1.8.23
93
+ rubygems_version: 1.3.6
85
94
  signing_key:
86
95
  specification_version: 3
87
96
  summary: A utility to insert copyright headers into various types of source code files
88
97
  test_files: []
98
+