Skip to content

Commit a94acdc

Browse files
committed
First commit
0 parents  commit a94acdc

File tree

7 files changed

+192
-0
lines changed

7 files changed

+192
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
.bundle
3+
hello-1.0.0-*
4+
*.tar.gz
5+
vendor

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'csvlint'
4+
gem 'thor'
5+
gem 'ffi', '1.9.6'
6+
7+
group :development do
8+
gem 'rake'
9+
end

Gemfile.lock

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
activesupport (4.2.4)
5+
i18n (~> 0.7)
6+
json (~> 1.7, >= 1.7.7)
7+
minitest (~> 5.1)
8+
thread_safe (~> 0.3, >= 0.3.4)
9+
tzinfo (~> 1.1)
10+
addressable (2.3.8)
11+
colorize (0.7.7)
12+
csvlint (0.2.4)
13+
activesupport
14+
addressable
15+
colorize
16+
escape_utils
17+
mime-types
18+
open_uri_redirections
19+
thor
20+
typhoeus
21+
uri_template
22+
escape_utils (1.1.0)
23+
ethon (0.8.0)
24+
ffi (>= 1.3.0)
25+
ffi (1.9.6)
26+
i18n (0.7.0)
27+
json (1.8.3)
28+
mime-types (2.6.2)
29+
minitest (5.8.1)
30+
open_uri_redirections (0.2.1)
31+
rake (10.4.2)
32+
thor (0.19.1)
33+
thread_safe (0.3.5)
34+
typhoeus (0.8.0)
35+
ethon (>= 0.8.0)
36+
tzinfo (1.2.2)
37+
thread_safe (~> 0.1)
38+
uri_template (0.7.0)
39+
40+
PLATFORMS
41+
ruby
42+
43+
DEPENDENCIES
44+
csvlint
45+
ffi (= 1.9.6)
46+
rake
47+
thor

Rakefile

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# For Bundler.with_clean_env
2+
require 'bundler/setup'
3+
4+
PACKAGE_NAME = "csvlint"
5+
VERSION = "1.0.0"
6+
TRAVELING_RUBY_VERSION = "20150210-2.1.5"
7+
FFI_VERSION = "1.9.6"
8+
9+
desc "Package your app"
10+
task :package => ['package:linux:x86', 'package:linux:x86_64', 'package:osx']
11+
12+
namespace :package do
13+
namespace :linux do
14+
desc "Package your app for Linux x86"
15+
task :x86 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz",
16+
"packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86-ffi-#{FFI_VERSION}.tar.gz"] do
17+
create_package("linux-x86")
18+
end
19+
20+
desc "Package your app for Linux x86_64"
21+
task :x86_64 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz",
22+
"packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64-ffi-#{FFI_VERSION}.tar.gz"] do
23+
create_package("linux-x86_64")
24+
end
25+
end
26+
27+
desc "Package your app for OS X"
28+
task :osx => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz",
29+
"packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx-ffi-#{FFI_VERSION}.tar.gz"] do
30+
create_package("osx")
31+
end
32+
33+
desc "Install gems to local directory"
34+
task :bundle_install do
35+
if RUBY_VERSION !~ /^2\.1\./
36+
abort "You can only 'bundle install' using Ruby 2.1, because that's what Traveling Ruby uses."
37+
end
38+
sh "rm -rf packaging/tmp"
39+
sh "mkdir -p packaging/tmp"
40+
sh "cp Gemfile Gemfile.lock packaging/tmp/"
41+
Bundler.with_clean_env do
42+
sh "cd packaging/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle install --path ../vendor --without development"
43+
end
44+
sh "rm -rf packaging/tmp"
45+
sh "rm -f packaging/vendor/*/*/cache/*"
46+
sh "rm -rf packaging/vendor/ruby/*/extensions"
47+
sh "find packaging/vendor/ruby/*/gems -name '*.so' | xargs rm -f"
48+
sh "find packaging/vendor/ruby/*/gems -name '*.bundle' | xargs rm -f"
49+
sh "find packaging/vendor/ruby/*/gems -name '*.o' | xargs rm -f"
50+
end
51+
end
52+
53+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz" do
54+
download_runtime("linux-x86")
55+
end
56+
57+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz" do
58+
download_runtime("linux-x86_64")
59+
end
60+
61+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz" do
62+
download_runtime("osx")
63+
end
64+
65+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86-ffi-#{FFI_VERSION}.tar.gz" do
66+
download_native_extension("linux-x86", "ffi-#{FFI_VERSION}")
67+
end
68+
69+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64-ffi-#{FFI_VERSION}.tar.gz" do
70+
download_native_extension("linux-x86_64", "ffi-#{FFI_VERSION}")
71+
end
72+
73+
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx-ffi-#{FFI_VERSION}.tar.gz" do
74+
download_native_extension("osx", "ffi-#{FFI_VERSION}")
75+
end
76+
77+
def create_package(target)
78+
package_dir = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
79+
sh "rm -rf #{package_dir}"
80+
sh "mkdir #{package_dir}"
81+
sh "mkdir -p #{package_dir}/lib/app"
82+
sh "cp #{PACKAGE_NAME}.rb #{package_dir}/lib/app/"
83+
sh "mkdir #{package_dir}/lib/ruby"
84+
sh "tar -xzf packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
85+
sh "cp packaging/wrapper.sh #{package_dir}/#{PACKAGE_NAME}"
86+
sh "cp -pR packaging/vendor #{package_dir}/lib/"
87+
sh "cp Gemfile Gemfile.lock #{package_dir}/lib/vendor/"
88+
sh "mkdir #{package_dir}/lib/vendor/.bundle"
89+
sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config"
90+
sh "tar -xzf packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}-ffi-#{FFI_VERSION}.tar.gz " +
91+
"-C #{package_dir}/lib/vendor/ruby"
92+
if !ENV['DIR_ONLY']
93+
sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
94+
sh "rm -rf #{package_dir}"
95+
end
96+
end
97+
98+
def download_runtime(target)
99+
sh "cd packaging && curl -L -O --fail " +
100+
"http://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz"
101+
end
102+
103+
def download_native_extension(target, gem_name_and_version)
104+
sh "curl -L --fail -o packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}-#{gem_name_and_version}.tar.gz " +
105+
"http://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-gems-#{TRAVELING_RUBY_VERSION}-#{target}/#{gem_name_and_version}.tar.gz"
106+
end

csvlint.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
$:.unshift File.join( File.dirname(__FILE__), "..", "lib")
2+
3+
require 'csvlint/cli'
4+
5+
if ARGV == ["help"]
6+
Csvlint::Cli.start(["help"])
7+
else
8+
Csvlint::Cli.start(ARGV.unshift("validate"))
9+
end

packaging/bundler-config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BUNDLE_PATH: .
2+
BUNDLE_WITHOUT: development
3+
BUNDLE_DISABLE_SHARED_GEMS: '1'

packaging/wrapper.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Figure out where this script is located.
5+
SELFDIR="`dirname \"$0\"`"
6+
SELFDIR="`cd \"$SELFDIR\" && pwd`"
7+
8+
# Tell Bundler where the Gemfile and gems are.
9+
export BUNDLE_GEMFILE="$SELFDIR/lib/vendor/Gemfile"
10+
unset BUNDLE_IGNORE_CONFIG
11+
12+
# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
13+
exec "$SELFDIR/lib/ruby/bin/ruby" -rbundler/setup "$SELFDIR/lib/app/csvlint.rb" $*

0 commit comments

Comments
 (0)