Skip to content

Commit 94b7260

Browse files
ryanfairclothosterman
authored andcommitted
Minor updates (#48)
* Fix dependency to specific a version to clear warning * Upgrade the docker image to use the current ubuntu LTS This change increments the base image to Ubuntu 18.04 LTS and adds the required cmake and libss-dev ubuntu packages required by gem to build platform specific packages * This change adds "conf" file support conf files are commonly commented using hashtag lines this change adds support * This change adds contributor information for [email protected] * Include ext type detected and exception in console logging * This change adds language type declaration to ensure ruby does not fail with UTF-8 files * Remove copy paste vendor reference * Remove use of after condition for conf file type * Work with exception logging guidance from upstream
1 parent 7961b14 commit 94b7260

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Erik Osterman <[email protected]> - Initial version
2-
2+
Ryan Faircloth <[email protected]> - Contributions

Dockerfile

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
FROM ubuntu:16.04
1+
FROM ubuntu:18.04
22

33
RUN apt-get update && \
4-
apt-get -y install ruby ruby-dev git make build-essential libicu-dev zlib1g-dev cmake pkg-config
4+
apt-get -y install ruby ruby-dev git make build-essential libicu-dev zlib1g-dev cmake pkg-config cmake libssl-dev
5+
6+
# Set the locale
7+
# make the "en_US.UTF-8" locale so ruby will be utf-8 enabled by default
8+
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
9+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
10+
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
11+
locale-gen
12+
ENV LANG en_US.UTF-8
13+
ENV LANGUAGE en_US:en
14+
ENV LC_ALL en_US.UTF-8
515

616
ADD . /tmp/copyright-header/
717
ADD .git /tmp/copyright-header/.git

contrib/syntax.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,10 @@ rust:
228228
open: '/*\n'
229229
close: ' */\n\n'
230230
prefix: ' * '
231-
231+
# Conf files i.e. apache config, splunk.conf files
232+
conf:
233+
ext: ['.conf']
234+
comment:
235+
open: '#\n'
236+
close: '#\n'
237+
prefix: '# '

copyright-header.gemspec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
$:.push File.expand_path("../lib", __FILE__)
44
require "copyright_header/version"
55

6+
if RUBY_VERSION =~ /1.9/ # assuming you're running Ruby ~1.9
7+
Encoding.default_external = Encoding::UTF_8
8+
Encoding.default_internal = Encoding::UTF_8
9+
end
10+
611
Gem::Specification.new do |s|
712
s.name = "copyright-header"
813
s.version = CopyrightHeader::VERSION
@@ -19,5 +24,5 @@ Gem::Specification.new do |s|
1924
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
2025
s.extra_rdoc_files = ['README.md', 'LICENSE', 'AUTHORS', 'contrib/syntax.yml' ]
2126
s.require_paths = ["lib"]
22-
s.add_dependency('github-linguist')
27+
s.add_runtime_dependency('github-linguist','~>6.0')
2328
end

lib/copyright_header/parser.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def word_wrap(text, max_width = nil)
4242
def load_template
4343
if File.exists?(@options[:license_file])
4444
template = ::ERB.new File.new(@options[:license_file]).read, 0, '%'
45-
license = template.result(OpenStruct.new(@options).instance_eval { binding })
45+
license = template.result(OpenStruct.new(@options).instance_eval { binding })
4646
license = word_wrap(license)
4747
license
4848
else
@@ -219,7 +219,7 @@ def transform(method, path)
219219
next
220220
end
221221

222-
if @syntax.supported?(path)
222+
if @syntax.supported?(path)
223223
header = @syntax.header(path)
224224
contents = header.send(method, @license)
225225
if contents.nil?
@@ -228,10 +228,10 @@ def transform(method, path)
228228
write(path, contents)
229229
end
230230
else
231-
STDERR.puts "SKIP #{path}; unsupported"
231+
STDERR.puts "SKIP #{path}; unsupported #{@syntax.ext(path)}"
232232
end
233233
rescue Exception => e
234-
STDERR.puts "SKIP #{path}; #{e.message}"
234+
STDERR.puts "SKIP #{path}; exception=#{e.message}"
235235
end
236236
end
237237
end
@@ -247,7 +247,7 @@ def remove(dir)
247247
end
248248

249249
def write(file, contents)
250-
if @options[:dry_run]
250+
if @options[:dry_run]
251251
STDERR.puts "UPDATE #{file} [dry-run]"
252252
STDERR.puts contents
253253
elsif @options[:output_dir].nil?

0 commit comments

Comments
 (0)