Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ doc/build
/coverage/
*.json
.byebug_history
*.gem
58 changes: 32 additions & 26 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,59 @@ PATH
ghtorrent (0.12.1)
bunny (~> 2.3, >= 2.3.0)
mongo (~> 2.4, >= 2.4.3)
optimist (~> 3.0, >= 3.0.0)
sequel (~> 4.5, >= 4.5.0)
trollop (~> 2.0, >= 2.0.0)

GEM
remote: https://rubygems.org/
specs:
activesupport (3.1.12)
multi_json (~> 1.0)
addressable (2.5.2)
activesupport (4.0.13)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
amq-protocol (2.3.0)
bson (4.3.0)
bunny (2.9.2)
amq-protocol (~> 2.3.0)
byebug (10.0.2)
bson (4.5.0)
bunny (2.14.2)
amq-protocol (~> 2.3, >= 2.3.0)
byebug (11.0.1)
cause (0.1)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.5)
crack (0.4.3)
safe_yaml (~> 1.0.0)
docile (1.3.0)
docile (1.3.1)
factory_girl (4.9.0)
activesupport (>= 3.0.0)
faker (1.8.7)
faker (1.9.3)
i18n (>= 0.7)
hashdiff (0.3.7)
i18n (1.0.1)
hashdiff (0.3.9)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
influxdb (0.3.5)
cause
json
json (2.1.0)
json (2.2.0)
m (1.5.1)
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
metaclass (0.0.4)
method_source (0.9.0)
method_source (0.9.2)
minitest (4.7.5)
minitest-around (0.0.5)
minitest (~> 4.7.5)
mocha (1.5.0)
mocha (1.8.0)
metaclass (~> 0.0.1)
mongo (2.5.1)
bson (>= 4.3.0, < 5.0.0)
mongo (2.8.0)
bson (>= 4.4.2, < 5.0.0)
multi_json (1.13.1)
mysql2 (0.5.1)
public_suffix (3.0.2)
rake (12.3.1)
safe_yaml (1.0.4)
mysql2 (0.5.2)
optimist (3.0.0)
public_suffix (3.1.0)
rake (12.3.2)
safe_yaml (1.0.5)
sequel (4.49.0)
simplecov (0.16.1)
docile (~> 1.1)
Expand All @@ -61,9 +66,10 @@ GEM
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
sqlite3 (1.3.13)
trollop (2.1.2)
vcr (4.0.0)
webmock (3.3.0)
thread_safe (0.3.6)
tzinfo (0.3.55)
vcr (5.0.0)
webmock (3.5.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
Expand Down Expand Up @@ -91,4 +97,4 @@ DEPENDENCIES
webmock

BUNDLED WITH
1.16.3
1.17.1
4 changes: 2 additions & 2 deletions bin/ght-geolocate
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Geolocates the given address using GHTorrent's APIs and config.

def validate
super
Trollop::die("Missing search string") if ARGV[0].nil?
Optimist::die("Missing search string") if ARGV[0].nil?
end

def go
Expand All @@ -38,4 +38,4 @@ Geolocates the given address using GHTorrent's APIs and config.

end

GHTGeolocate.run
GHTGeolocate.run
4 changes: 2 additions & 2 deletions bin/ght-log-influx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#

require 'rubygems'
require 'trollop'
require 'optimist'
require 'influxdb'
require 'pp'
require 'time'
Expand Down Expand Up @@ -176,7 +176,7 @@ def parse_log_line(line)
end
end

opts = Trollop::options do
opts = Optimist::options do
banner <<-END
Store GHTorrent log output to InfluxDB. Reads from STDIN.
Writes to a UDP port only.
Expand Down
4 changes: 2 additions & 2 deletions fixes/fix_commit_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def prepare_options(options)

def validate
super
Trollop::die 'Missing required argument URL' if ARGV.size == 0
Optimist::die 'Missing required argument URL' if ARGV.size == 0
uri = URI(ARGV[0])
Trollop::die "Argument #{ARGV[0]} not a HTTPS URL" if uri.scheme != 'https'
Optimist::die "Argument #{ARGV[0]} not a HTTPS URL" if uri.scheme != 'https'
end


Expand Down
6 changes: 3 additions & 3 deletions fixes/fix_pull_request_commits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def prepare_options(options)

def validate
super
Trollop::die "Either takes no arguments or two" if ARGV.size == 1
Optimist::die "Either takes no arguments or two" if ARGV.size == 1
end


Expand Down Expand Up @@ -50,13 +50,13 @@ def go
user_entry = ght.transaction { ght.ensure_user(ARGV[0], false, false) }

if user_entry.nil?
Trollop::die "Cannot find user #{ARGV[0]}"
Optimist::die "Cannot find user #{ARGV[0]}"
end

repo_entry = ght.transaction{ ght.ensure_repo(ARGV[0], ARGV[1]) }

if repo_entry.nil?
Trollop::die "Cannot find repository #{ARGV[0]}/#{ARGV[1]}"
Optimist::die "Cannot find repository #{ARGV[0]}/#{ARGV[1]}"
end
{"owner" => ARGV[0], "repo" => ARGV[1]}
else
Expand Down
2 changes: 1 addition & 1 deletion fixes/refresh_pull_request_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def settings

def validate
super
Trollop::die 'Three arguments required' unless args[2] && !args[2].empty?
Optimist::die 'Three arguments required' unless args[2] && !args[2].empty?
end

def run(command)
Expand Down
2 changes: 1 addition & 1 deletion ghtorrent.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '~> 2.0'

s.add_runtime_dependency 'mongo', '~> 2.4', '>= 2.4.3'
s.add_runtime_dependency 'trollop', '~> 2.0', '>= 2.0.0'
s.add_runtime_dependency 'optimist', '~> 3.0', '>= 3.0.0'
s.add_runtime_dependency 'sequel', '~> 4.5', '>= 4.5.0'
s.add_runtime_dependency 'bunny', '~> 2.3', '>= 2.3.0'

Expand Down
14 changes: 7 additions & 7 deletions lib/ghtorrent/command.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rubygems'
require 'trollop'
require 'optimist'
require 'bunny'
require 'etc'

Expand Down Expand Up @@ -79,7 +79,7 @@ def run(args = ARGV)
# Specify and parse top-level command line options.
def process_options
command = self
@options = Trollop::options(command.args) do
@options = Optimist::options(command.args) do

command.prepare_options(self)

Expand Down Expand Up @@ -107,7 +107,7 @@ def version
end

# This method should be overriden by subclasses in order to specify,
# using trollop, the supported command line options
# using optimist, the supported command line options
def prepare_options(options)
end

Expand All @@ -117,23 +117,23 @@ def prepare_options(options)
def validate
if options[:config].nil?
unless (File.exist?("config.yaml"))
Trollop::die "No config file in default location (#{Dir.pwd}). You
Optimist::die "No config file in default location (#{Dir.pwd}). You
need to specify the #{:config} parameter. Read the
documentation on how to create a config.yaml file."
end
else
Trollop::die "Cannot find file #{options[:config]}" \
Optimist::die "Cannot find file #{options[:config]}" \
unless File.exist?(options[:config])
end

unless @options[:user].nil?
if not Process.uid == 0
Trollop::die "Option --user (-u) can only be specified by root"
Optimist::die "Option --user (-u) can only be specified by root"
end
begin
Etc.getpwnam(@options[:user])
rescue ArgumentError
Trollop::die "No such user: #{@options[:user]}"
Optimist::die "No such user: #{@options[:user]}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ghtorrent/commands/full_repo_retriever.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def validate_options
end

unless options[:only_stage].nil?
Trollop::die("Not a valid function: #{options[:only_stage]}") unless stages.include? options[:only_stage]
Optimist::die("Not a valid function: #{options[:only_stage]}") unless stages.include? options[:only_stage]
end

end
Expand Down
6 changes: 3 additions & 3 deletions lib/ghtorrent/commands/ght_load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def validate
case
when filter.is_a?(Array)
options[:filter].each { |x|
Trollop::die "not a valid filter #{x}" unless is_filter_valid?(x)
Optimist::die "not a valid filter #{x}" unless is_filter_valid?(x)
}
when filter == []
# Noop
else
Trollop::die 'A filter can only be a string'
Optimist::die 'A filter can only be a string'
end

if options[:file_given]
Trollop::die "File does not exist: #{options[:file]}" unless File.exists?(options[:file])
Optimist::die "File does not exist: #{options[:file]}" unless File.exists?(options[:file])
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/ghtorrent/commands/ght_retrieve_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def prepare_options(options)
def validate
super
validate_options
Trollop::die("Missing owner") if ARGV[0].nil?
Trollop::die("Missing repo") if ARGV[1].nil?
Optimist::die("Missing owner") if ARGV[0].nil?
Optimist::die("Missing repo") if ARGV[1].nil?
end

def go
Expand Down
2 changes: 1 addition & 1 deletion lib/ghtorrent/commands/ght_retrieve_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def prepare_options(options)

def validate
super
Trollop::die "One argument is required" unless args[0] && !args[0].empty?
Optimist::die "One argument is required" unless args[0] && !args[0].empty?
end

def ght
Expand Down
2 changes: 1 addition & 1 deletion lib/ghtorrent/commands/ght_update_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def prepare_options(options)

def validate
super
Trollop::die "Takes two arguments" if ARGV.size == 1
Optimist::die "Takes two arguments" if ARGV.size == 1
end

def settings
Expand Down
4 changes: 2 additions & 2 deletions lib/ghtorrent/multiprocess_queue_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def prepare_options(options)

def validate
super
Trollop::die 'Argument mapping-file is required' unless not args[0].nil?
Optimist::die 'Argument mapping-file is required' unless not args[0].nil?
end

def go
Expand Down Expand Up @@ -114,4 +114,4 @@ def go
end
end

# vim: ft=ruby:
# vim: ft=ruby:
2 changes: 1 addition & 1 deletion test/unit/multiprocess_queue_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def clazz
describe 'validate' do
it 'must call trolltop.die' do
GHTorrent::Command.any_instance.expects(:validate)
Trollop.expects(:die)
Optimist.expects(:die)

client.stubs(:args).returns([])
client.validate
Expand Down