Skip to content

Commit

Permalink
Fixes import of Github Issues [#2] [#11]
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmckinney committed Dec 16, 2012
1 parent d977a7c commit 38f7a58
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
11 changes: 6 additions & 5 deletions bin/pomo
Expand Up @@ -73,13 +73,11 @@ command :import do |c|
c.summary = 'Import Github project issues'
c.description = 'Import Github project issues which have not yet been closed'
c.action do |args, options|
gem 'octopi', '>=0.2.1'
require 'octopi'
user = args.shift or raise('Github <user> is required')
project = args.shift or raise('Github <project> is required')
if repo = Octopi::Repository.find(:user => user, :name => project)
say "Importing items from http://github.com/#{user}/#{project}"
repo.issues.select { |i| not i.closed_at }.each do |issue|
begin
Octokit.list_issues({:username => user, :repo => project}, :state => 'open', :sort => 'created').each_with_index do |issue, index|
say "Importing issues from https://github.com/#{user}/#{project}" if index == 0
task = Pomo::GithubTask.new issue.title,
:username => user,
:project => project,
Expand All @@ -90,6 +88,9 @@ command :import do |c|
say " - Added #{task}"
end
list.save
rescue Octokit::NotFound => e
say '404: This is not the repo you are looking for.'
say e.message
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/pomo.rb
@@ -1,4 +1,5 @@
require 'yaml'
require 'octokit'
require 'terminal-notifier' if /darwin/ =~ RUBY_PLATFORM
require 'growl' if /darwin/ =~ RUBY_PLATFORM
require 'libnotify' if /linux/ =~ RUBY_PLATFORM
Expand Down
38 changes: 19 additions & 19 deletions lib/pomo/github_task.rb
Expand Up @@ -3,52 +3,52 @@ module Pomo
class Task
def github?
false
end
end
end

class GithubTask < Task

##
# Username.

attr_accessor :username

##
# Project name.

attr_accessor :project

##
# Labels array.

attr_accessor :labels

##
# Issue number.

attr_accessor :number

##
# Initialize with _name_ and _options_.

def initialize name = nil, options = {}
super
options.each { |k,v| send :"#{k}=", v }
end

##
# Check if the task is a github issue.

def github?
true
end

##
# Absolute URI to github issue.

def uri
"http://github.com/#{username}/#{project}/issues#issue/#{number}"
"https://github.com/#{username}/#{project}/issues#issue/#{number}"
end

end
end
end
1 change: 1 addition & 0 deletions pomo.gemspec
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
gem.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Pomo", "--main", "Readme.md"]

gem.add_dependency("commander", [">= 4.1.2"])
gem.add_dependency("octokit", "~> 1.19")
gem.add_dependency("terminal-notifier", [">= 1.4.2"]) if /darwin/ =~ RUBY_PLATFORM
gem.add_dependency("growl", [">= 1.0.3"]) if /darwin/ =~ RUBY_PLATFORM
gem.add_dependency("libnotify", [">= 0.8.0"]) if /linux/ =~ RUBY_PLATFORM
Expand Down

0 comments on commit 38f7a58

Please sign in to comment.