Skip to content

Commit

Permalink
Minor updates (#48)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ryanfaircloth authored and osterman committed Aug 20, 2018
1 parent 7961b14 commit 94b7260
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Erik Osterman <[email protected]> - Initial version

Ryan Faircloth <[email protected]> - Contributions
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

RUN apt-get update && \
apt-get -y install ruby ruby-dev git make build-essential libicu-dev zlib1g-dev cmake pkg-config
apt-get -y install ruby ruby-dev git make build-essential libicu-dev zlib1g-dev cmake pkg-config cmake libssl-dev

# Set the locale
# make the "en_US.UTF-8" locale so ruby will be utf-8 enabled by default
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

ADD . /tmp/copyright-header/
ADD .git /tmp/copyright-header/.git
Expand Down
8 changes: 7 additions & 1 deletion contrib/syntax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,10 @@ rust:
open: '/*\n'
close: ' */\n\n'
prefix: ' * '

# Conf files i.e. apache config, splunk.conf files
conf:
ext: ['.conf']
comment:
open: '#\n'
close: '#\n'
prefix: '# '
7 changes: 6 additions & 1 deletion copyright-header.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
$:.push File.expand_path("../lib", __FILE__)
require "copyright_header/version"

if RUBY_VERSION =~ /1.9/ # assuming you're running Ruby ~1.9
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end

Gem::Specification.new do |s|
s.name = "copyright-header"
s.version = CopyrightHeader::VERSION
Expand All @@ -19,5 +24,5 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.extra_rdoc_files = ['README.md', 'LICENSE', 'AUTHORS', 'contrib/syntax.yml' ]
s.require_paths = ["lib"]
s.add_dependency('github-linguist')
s.add_runtime_dependency('github-linguist','~>6.0')
end
10 changes: 5 additions & 5 deletions lib/copyright_header/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def word_wrap(text, max_width = nil)
def load_template
if File.exists?(@options[:license_file])
template = ::ERB.new File.new(@options[:license_file]).read, 0, '%'
license = template.result(OpenStruct.new(@options).instance_eval { binding })
license = template.result(OpenStruct.new(@options).instance_eval { binding })
license = word_wrap(license)
license
else
Expand Down Expand Up @@ -219,7 +219,7 @@ def transform(method, path)
next
end

if @syntax.supported?(path)
if @syntax.supported?(path)
header = @syntax.header(path)
contents = header.send(method, @license)
if contents.nil?
Expand All @@ -228,10 +228,10 @@ def transform(method, path)
write(path, contents)
end
else
STDERR.puts "SKIP #{path}; unsupported"
STDERR.puts "SKIP #{path}; unsupported #{@syntax.ext(path)}"
end
rescue Exception => e
STDERR.puts "SKIP #{path}; #{e.message}"
STDERR.puts "SKIP #{path}; exception=#{e.message}"
end
end
end
Expand All @@ -247,7 +247,7 @@ def remove(dir)
end

def write(file, contents)
if @options[:dry_run]
if @options[:dry_run]
STDERR.puts "UPDATE #{file} [dry-run]"
STDERR.puts contents
elsif @options[:output_dir].nil?
Expand Down

0 comments on commit 94b7260

Please sign in to comment.