githubissues-port 0.5 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjIxNzZjZjJmODFmNTBjODgxNTMxZWQ2Y2NhMDNjMWFjMDZlNjY2ZQ==
4
+ ZDk1M2Q3NTE5ODYyZTg0ZWE4NjE5Zjk3MmVmNmYwYzgwMjg0MDA5NQ==
5
5
  data.tar.gz: !binary |-
6
- NTRjM2ViOTQ5OGI0MmM5ZWIyOWMyZWJiYTJhMDc3NDhlYjU0ZTc0OA==
6
+ MTUzNDVmNGY3YWE1MmQ1OTRlY2ZiMzY3NmYxNjJkZWVlNmEyOGExNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTVjNzJmNzEyMDJjOTZjNTRjZDNmZTc1YmFhMWI2OTkyN2FlZDhhZTlkYTFl
10
- MWVmZjgxZDYzNGRiMjlmYTc2ZGVmM2FlYWE5Y2IyMWEyMTdmODgxOTFjNDhl
11
- N2Y0NDI4MmFhZGRjYjFhODExNjhmMjVlNmMxNWQ3MWNjYjZmODM=
9
+ ZmViYjYxZDllYjY5OWNkM2RmYmJhYTdmYWY4OTY5YzgwZThhZTRlODAxZTM2
10
+ OTM4NGEyYjkzZDM2MGVmNWM3OTdjMjg3MGZkNjY1ZDcyZjBkZmM3Y2U3ZDYx
11
+ ZWNlYjhhNDk1ODZlNjcxZmIzNzBjZjk5NjRjY2I2ZWRiOWM1YTM=
12
12
  data.tar.gz: !binary |-
13
- MTM5ZDhkMDcxYzQzOWQ4YWYyMzVmOTNhMTU5NWU3OTkyMWVkMThlMGU3OGJh
14
- MTExNmZiMDZiMzJhMzNhMmNiMGVlNjI5N2EzMjQzYjIxYmRlNWNmOGIzZmEy
15
- M2ZkMjM4MzFmY2Y1OGU1ZmQyNjhlOWJlMDBlY2I1ZjA4MTU1YmM=
13
+ MTBhZDcyY2VjNGI3NjY0NTcwZjRkNzBlNTBkNDNkYmU3NjYxMDA0ODY2NWQ2
14
+ NmVhYWIzZWI0NzAyODAwYTJlNjFkYWZhMDliYTUyNGJmMmFmMTdjODgyYTY0
15
+ NDFjZWM5NTY0N2FjYjhmMGMwOTdiNGMxYTUwODcwNDU5NTRiNTU=
data/Readme.md CHANGED
@@ -29,9 +29,8 @@ githubissues-port can simply import or export issues from an Excel file.:
29
29
 
30
30
  your_github_username = '***********'
31
31
  your_github_password = '***********'
32
-
33
- owner = '***********'
34
- repo = '***********'
32
+ owner = '***********'
33
+ repo = '***********'
35
34
 
36
35
  connection = Github.new(basic_auth: "#{your_github_username}:#{your_github_password}")
37
36
 
data/export.xlsx CHANGED
Binary file
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Githubissues::Port::VERSION
9
9
  spec.authors = ["Ramtin Vaziri", "Ankit gupta", "Hemali Jain"]
10
10
  spec.description = %q{An Excel import/export extension for github issues in Ruby.}
11
- spec.summary = %q{github-issues-port is a Ruby gem that facilittes easy import and export of Github Issues in Ruby and Ruyb on Rails.}
11
+ spec.summary = %q{github-issues-port is a Ruby gem that facilittes easy import and export of Github Issues in Ruby and Ruby on Rails.}
12
12
  spec.homepage = "https://github.com/github-issues-port/githubissues-port"
13
13
  spec.license = "MIT"
14
14
 
@@ -4,14 +4,13 @@ require 'axlsx'
4
4
  module Githubissues
5
5
  module Port
6
6
  class Githubissues::Port::Export
7
- attr_reader :connection, :owner, :repo, :path
7
+ attr_reader :connection, :owner, :repo, :path
8
+
9
+ DEFAULT_FIELDS = %w(number title body labels assignee state milestone created_at closed_at comments labels comments_url events_url html_url labels_url type priority module status)
10
+
8
11
  def initialize connection, owner, repo, path, options = {}
9
- @path = path
10
- @connection = connection
11
- @owner = owner
12
- @repo = repo
13
- @default_fields = %w(number title body labels assignee state milestone created_at closed_at comments comments_url events_url html_url labels_url)
14
- @fields = (options.has_key? :fields) ? options[:fields] : @default_fields
12
+ @path, @connection, @owner, @repo = path, connection, owner, repo
13
+ @fields = (options.has_key? :fields) ? options[:fields] : DEFAULT_FIELDS
15
14
  generate_excel
16
15
  end
17
16
 
@@ -26,28 +25,38 @@ module Githubissues
26
25
  def generate_sheet excel, state
27
26
  excel.workbook.add_worksheet(:name => state) do |sheet|
28
27
  sheet.add_row @fields
29
- issues = @connection.issues.list user: @owner,
30
- repo: @repo,
31
- filter: 'all',
28
+ issues = @connection.issues.list user: @owner,
29
+ repo: @repo,
30
+ filter: 'all',
32
31
  auto_pagination: true,
33
- state: state
32
+ state: state
34
33
  issues.each{|issue| sheet.add_row generate_row(issue)}
35
34
  end
36
35
  end
37
36
 
38
37
  def generate_row issue
38
+ labels = (issue.labels.nil?) ? [] : issue.labels.map{|l| l.name.downcase}
39
+
39
40
  @fields.collect do |field|
40
41
  case field.downcase
41
42
  when 'assignee'
42
43
  issue.assignee.login unless issue.assignee.nil?
43
44
  when 'labels'
44
- issue.labels.map(&:name).join(', ') unless issue.labels.nil?
45
+ labels.join ', '
45
46
  when 'milestone'
46
47
  issue.milestone.title unless issue.milestone.nil?
47
48
  when 'created_at'
48
49
  DateTime.parse issue.created_at unless issue.created_at.nil?
49
50
  when 'closed_at'
50
51
  DateTime.parse issue.closed_at unless issue.closed_at.nil?
52
+ when 'type'
53
+ labels.select{|l| (l =~ /type*/) or (%w(bug duplicate enhancement invalid question wontfix patch).include? l)}.join ', '
54
+ when 'priority'
55
+ labels.select{|l| (l =~ /priority*/) or (%w(high medium low critical).include? l)}.join ', '
56
+ when 'module'
57
+ labels.select{|l| l =~ /module*/}.join ', '
58
+ when 'status'
59
+ labels.select{|l| l =~ /status*/}.join ', '
51
60
  else
52
61
  issue.send field
53
62
  end
@@ -6,13 +6,11 @@ module Githubissues
6
6
  class Githubissues::Port::Import
7
7
  attr_reader :connection, :owner, :repo, :path, :messages, :header
8
8
  def initialize connection, owner, repo, path, options = {}
9
- @path = path
10
- @connection = connection
11
- @owner = owner
12
- @repo = repo
9
+ @path, @connection, @owner, @repo = path, connection, owner, repo
13
10
  @fields = (options.has_key? :fields) ? options[:fields] : %w(labels)
14
11
  @messages = []
15
12
  parse_excel
13
+ @messages
16
14
  end
17
15
 
18
16
  def parse_excel
@@ -0,0 +1,23 @@
1
+ require 'githubissues-port'
2
+
3
+ describe 'githubissues-port exporting and importing to xlsx' do
4
+ before(:all) do
5
+ # Replace your test git repo credentials here:
6
+ @github_username = '**********'
7
+ @github_password = '**********'
8
+ @owner = '**********'
9
+ @repo = '**********'
10
+ @connection = Github.new basic_auth: "#{@github_username}:#{@github_password}"
11
+ end
12
+
13
+ it 'export should be successfull.' do
14
+ export = Githubissues::Port::Export.new @connection, @owner, @repo, 'export.xlsx', fields: ['number', 'title', 'body', 'labels']
15
+ #puts export.inspect
16
+ export.should_not be_nil
17
+ end
18
+
19
+ it 'import should be successfull.' do
20
+ #puts import.messages.inspect
21
+ import.should_not be_nil
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module Githubissues
2
2
  module Port
3
- VERSION = "0.5"
3
+ VERSION = "1.0"
4
4
  end
5
5
  end
data/spec/test_spec.rb CHANGED
@@ -1,21 +1,24 @@
1
+ require 'github_api'
1
2
  require 'githubissues-port'
2
3
 
3
4
  describe 'githubissues-port exporting and importing to xlsx' do
4
5
  before(:all) do
5
- my_github_username = 'githubissues-port'
6
- my_github_password = 'Github123'
7
- @connection = Github.new basic_auth: "#{my_github_username}:#{my_github_password}"
6
+ # Replace your test git repo credentials here:
7
+ @github_username = '**********'
8
+ @github_password = '**********'
9
+ @owner = '**********'
10
+ @repo = '**********'
11
+ @connection = Github.new basic_auth: "#{@github_username}:#{@github_password}"
8
12
  end
9
13
 
10
14
  it 'export should be successfull.' do
11
- export = Githubissues::Port::Export.new @connection, 'githubissues-port', 'foo', 'export.xlsx', fields: ['number', 'title', 'body', 'labels']
12
- puts export.path
15
+ export = Githubissues::Port::Export.new @connection, @owner, @repo, 'export.xlsx', fields: ['number', 'title', 'body', 'labels']
16
+ #puts export.inspect
13
17
  export.should_not be_nil
14
18
  end
15
19
 
16
20
  it 'import should be successfull.' do
17
- import = Githubissues::Port::Import.new @connection, 'githubissues-port', 'foo', 'spec/fixtures/sample.xlsx', fields: ['title', 'labels']
18
- puts import.messages.inspect
21
+ #puts import.messages.inspect
19
22
  import.should_not be_nil
20
23
  end
21
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubissues-port
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ramtin Vaziri
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-27 00:00:00.000000000 Z
13
+ date: 2014-02-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: github_api
@@ -99,6 +99,7 @@ files:
99
99
  - lib/githubissues-port.rb
100
100
  - lib/githubissues-port/export.rb
101
101
  - lib/githubissues-port/import.rb
102
+ - lib/githubissues-port/test_spec.rb
102
103
  - lib/githubissues-port/version.rb
103
104
  - spec/fixtures/sample.xlsx
104
105
  - spec/test_spec.rb
@@ -126,7 +127,7 @@ rubygems_version: 2.2.0
126
127
  signing_key:
127
128
  specification_version: 4
128
129
  summary: github-issues-port is a Ruby gem that facilittes easy import and export of
129
- Github Issues in Ruby and Ruyb on Rails.
130
+ Github Issues in Ruby and Ruby on Rails.
130
131
  test_files:
131
132
  - spec/fixtures/sample.xlsx
132
133
  - spec/test_spec.rb