Skip to content

Commit

Permalink
Reduce deps list for packaged binary (fixes #151)
Browse files Browse the repository at this point in the history
  • Loading branch information
blahah committed Jul 7, 2015
1 parent 3b08adf commit 56ba970
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 13 additions & 3 deletions lib/transrate/cmdline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def argument_parser
"Log level. One of [error, info, warn, debug]",
:default => 'info'
opt :install_deps,
"Install any missing dependencies. One of [all, read, ref]",
"Install any missing dependencies. One of " +
"[#{cmdline.allowed_deps.join(', ')}]",
:type => String, :default => nil
opt :examples, "Show some example commands with explanations"
end
Expand Down Expand Up @@ -258,10 +259,19 @@ def check_dependencies

end # check_dependencies

def allowed_deps
binkey = 'TRANSRATE_PACKAGED_BINARY'
if ENV.has_key?(binkey) && ENV[binkey] == 'true'
return ['read']
else
return ['read', 'ref', 'all']
end
end

def check_install_command
unless %w[all read ref].include? @opts.install_deps
unless allowed_deps.include? @opts.install_deps
msg = "install-deps #{@opts.install_deps} is not valid. " +
"You must specify one of: all, read, ref."
"You must specify one of: #{allowed_deps.join(', ')}."
raise TransrateError.new(msg)
end
end
Expand Down
3 changes: 3 additions & 0 deletions packaging/transrate
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ export DYLD_FALLBACK_LIBRARY_PATH=$SELFDIR/lib:$DYLD_FALLBACK_LIBRARY_PATH
export BUNDLE_GEMFILE="$SELFDIR/lib/app/Gemfile"
unset BUNDLE_IGNORE_CONFIG

# Tell transrate this is the packaged version
export TRANSRATE_PACKAGED_BINARY=true

# Run the actual app using the bundled Ruby interpreter, with Bundler activated.
exec "$SELFDIR/lib/app/ruby/bin/ruby" -rbundler/setup "$SELFDIR/lib/app/bin/transrate" $@

0 comments on commit 56ba970

Please sign in to comment.