Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Commenting and improved enum

  • Loading branch information...
commit 7ac7b1a27b61ef3c260e5f339d4b45fcfad45673 1 parent 07e231d
@OmriShiv OmriShiv authored
Showing with 7 additions and 11 deletions.
  1. +7 −11 AutomaticCoder/auto_coder_no_sql.rb
View
18 AutomaticCoder/auto_coder_no_sql.rb
@@ -2,11 +2,11 @@
Name: Ruby Github Sequence Coder
Author: Omri Shiv
Description: An automatic translator of github sequence data to clustal sequences for sequence analysis
-Use: Needs an argument, either just the project name, or the author/project
+Use: Needs 2 arguments: -a author -p project which maps to author/project in Github parlance
=end
require 'optparse' #for using options in program
-require 'octokit'
+require 'octokit' #github API library
@options = {verbose:false}
OptionParser.new do |opts|
opts.banner = "Usage: auto_coder.rb [options]"
@@ -103,17 +103,13 @@ def event_to_sequence(event, number)
end
begin
- # load the data
puts "Looking for all projects from repo #{@options[:repository]}... This may take some time...\n"
- if events = Octokit::Client.new(:auto_traversal => true).repository_events("#{@options[:actor]}/#{@options[:repository]}")
- puts events.size
- n = 0 #iterator for sequence number
+ if events = Octokit::Client.new(:auto_traversal => true).repository_events("#{@options[:actor]}/#{@options[:repository]}") #Query Github API for project events
f = File.new("#{@options[:actor]}_#{@options[:repository]}_seq.txt", 'w') #creating sequence file
- events.collect{|event|
- f.puts(event_to_sequence(event, n))
- n += 1
+ events.enum_for(:each_with_index).collect{|event, i| #iterate through events array with index
+ f.puts(event_to_sequence(event, i)) #append sequence to file
}
- f.close
+ f.close #close file
end
- rescue (Octokit::NotFound) then puts "Could not find project #{@options[:actor]}/#{@options[:repository]}"
+ rescue (Octokit::NotFound) then puts "Could not find project #{@options[:actor]}/#{@options[:repository]}" #rescue project not found error
end
Please sign in to comment.
Something went wrong with that request. Please try again.