diff --git a/.gitignore b/.gitignore index 27b2413..6356f00 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ doc/build /coverage/ *.json .byebug_history +*.gem diff --git a/Gemfile.lock b/Gemfile.lock index 3cd99cb..a1b09c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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 @@ -91,4 +97,4 @@ DEPENDENCIES webmock BUNDLED WITH - 1.16.3 + 1.17.1 diff --git a/bin/ght-geolocate b/bin/ght-geolocate index f6fdeda..e8da273 100644 --- a/bin/ght-geolocate +++ b/bin/ght-geolocate @@ -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 @@ -38,4 +38,4 @@ Geolocates the given address using GHTorrent's APIs and config. end -GHTGeolocate.run \ No newline at end of file +GHTGeolocate.run diff --git a/bin/ght-log-influx b/bin/ght-log-influx index 953420c..0eea860 100755 --- a/bin/ght-log-influx +++ b/bin/ght-log-influx @@ -2,7 +2,7 @@ # require 'rubygems' -require 'trollop' +require 'optimist' require 'influxdb' require 'pp' require 'time' @@ -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. diff --git a/fixes/fix_commit_comment.rb b/fixes/fix_commit_comment.rb index 5c34745..3948e1c 100755 --- a/fixes/fix_commit_comment.rb +++ b/fixes/fix_commit_comment.rb @@ -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 diff --git a/fixes/fix_pull_request_commits.rb b/fixes/fix_pull_request_commits.rb index d9b9bf3..86d4194 100755 --- a/fixes/fix_pull_request_commits.rb +++ b/fixes/fix_pull_request_commits.rb @@ -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 @@ -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 diff --git a/fixes/refresh_pull_request_history.rb b/fixes/refresh_pull_request_history.rb index f6513c1..65ef0da 100755 --- a/fixes/refresh_pull_request_history.rb +++ b/fixes/refresh_pull_request_history.rb @@ -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) diff --git a/ghtorrent.gemspec b/ghtorrent.gemspec index a182e9a..dcd9b01 100644 --- a/ghtorrent.gemspec +++ b/ghtorrent.gemspec @@ -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' diff --git a/lib/ghtorrent/command.rb b/lib/ghtorrent/command.rb index fdbe953..d351f9f 100644 --- a/lib/ghtorrent/command.rb +++ b/lib/ghtorrent/command.rb @@ -1,5 +1,5 @@ require 'rubygems' -require 'trollop' +require 'optimist' require 'bunny' require 'etc' @@ -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) @@ -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 @@ -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 diff --git a/lib/ghtorrent/commands/full_repo_retriever.rb b/lib/ghtorrent/commands/full_repo_retriever.rb index 4e6ba58..2474131 100644 --- a/lib/ghtorrent/commands/full_repo_retriever.rb +++ b/lib/ghtorrent/commands/full_repo_retriever.rb @@ -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 diff --git a/lib/ghtorrent/commands/ght_load.rb b/lib/ghtorrent/commands/ght_load.rb index b5a64bf..0d856b0 100644 --- a/lib/ghtorrent/commands/ght_load.rb +++ b/lib/ghtorrent/commands/ght_load.rb @@ -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 diff --git a/lib/ghtorrent/commands/ght_retrieve_repo.rb b/lib/ghtorrent/commands/ght_retrieve_repo.rb index 1a7bf5c..5fcaf87 100644 --- a/lib/ghtorrent/commands/ght_retrieve_repo.rb +++ b/lib/ghtorrent/commands/ght_retrieve_repo.rb @@ -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 diff --git a/lib/ghtorrent/commands/ght_retrieve_user.rb b/lib/ghtorrent/commands/ght_retrieve_user.rb index cfae6dd..55106d9 100644 --- a/lib/ghtorrent/commands/ght_retrieve_user.rb +++ b/lib/ghtorrent/commands/ght_retrieve_user.rb @@ -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 diff --git a/lib/ghtorrent/commands/ght_update_repo.rb b/lib/ghtorrent/commands/ght_update_repo.rb index ccbd966..7ddd46d 100755 --- a/lib/ghtorrent/commands/ght_update_repo.rb +++ b/lib/ghtorrent/commands/ght_update_repo.rb @@ -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 diff --git a/lib/ghtorrent/multiprocess_queue_client.rb b/lib/ghtorrent/multiprocess_queue_client.rb index 33a8b38..81274c1 100644 --- a/lib/ghtorrent/multiprocess_queue_client.rb +++ b/lib/ghtorrent/multiprocess_queue_client.rb @@ -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 @@ -114,4 +114,4 @@ def go end end -# vim: ft=ruby: \ No newline at end of file +# vim: ft=ruby: diff --git a/test/unit/multiprocess_queue_client_test.rb b/test/unit/multiprocess_queue_client_test.rb index 2467bd1..acc3c6e 100644 --- a/test/unit/multiprocess_queue_client_test.rb +++ b/test/unit/multiprocess_queue_client_test.rb @@ -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