githubissues-port 0.1.1 → 0.1.2

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
- ZGIwYmRhYjZjY2I4MWVmMjExMGIzYTIxZTQ2NzRhOTVmODkxMTc2Yg==
4
+ Y2RhOTg3NWJlMWUxNzc0MjhiZGFhOWZkZDBhNTExNmMxZDI4MTQ2OA==
5
5
  data.tar.gz: !binary |-
6
- MGY4MzdjZjdjNzZmN2VhMTlhNmRmZDljMWM3YmFhNThjODc5Njg0NA==
6
+ MjMwMzQxYTg4NGI0MTQxYzcwNjY5MDVjNDU1NjVmMDlhMzUyNTEyOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjNiNDc1ZGNkZWEzYThmMjc5ODc4YWQzZDlmNjZiZDI0MTA1YjBlMDhmMWVj
10
- ZTc5M2I4MzEzMjlkMDQ5ZDdjNzYyNTJjM2E3OTRjNDg1ZGY5ZGE2MGQ1ZmY0
11
- ZDI4MDZlY2NiMGQ3N2MyMTQ1YWZjOTkxZWE1YWJiZDUyZmQ1OWQ=
9
+ MDZmZGE3OWEwZTE3OTE3NDQ2MGFkNDE1NWI1MGFmOGE2Yzk2NjY5M2ZmN2U3
10
+ NjNmMjUzYzAyNTY3Y2E3NjBmNDQ5MTk1ZmViODZhNmIxMmM4MWI5MzRkMTRl
11
+ Y2I5YWViNjQ4Mjg0ZTkwNDhkOTQ4Njg5MGIyMTQxMDkwNGRjMWM=
12
12
  data.tar.gz: !binary |-
13
- Yzk1Njc5YzdlZDY1MjE0MjdhNDZjMjQ1YjliZTc4OGU1YTdjNDEwZjgyODQ2
14
- NDgyMTI4MGVkYTRiZTQ0ZjU0OWQ2MWY1MzhmYmUxZmVkMDM4MzhhNWIxZDY1
15
- ZGM0NmM2YjY3ZDA3ZWFmM2JlMDFlYzljNjYxMzNkNTQ4NGZkOGE=
13
+ ZDgxY2U1ZTJjZWNlMWU2OTg2ZDU0MTBkMDgwNmFjYWYzNmUzYjAyZGZhMmVk
14
+ NjI1NTllYzUxNDQ2NjE3ZDY4OGI5YjFlMmIwODEyZGVlZmE3N2E5MTMwMTUy
15
+ N2UzMTJlOGMwNTUyODk3OTMwZmVlMGY4MWY0YTZmZmM1Nzc0OWI=
data/export.xlsx CHANGED
Binary file
@@ -6,7 +6,7 @@ require 'githubissues-port/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "githubissues-port"
8
8
  spec.version = Githubissues::Port::VERSION
9
- spec.authors = ["pythonicrubyist", "ankit8898", "hemalijain"]
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
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.}
12
12
  spec.homepage = "https://github.com/github-issues-port/githubissues-port"
@@ -4,18 +4,18 @@ require 'axlsx'
4
4
  module Githubissues
5
5
  module Port
6
6
  class Githubissues::Port::Export
7
- attr_reader :path
8
- def initialize connection, owner, repo, path
7
+ attr_reader :path, :fields
8
+ def initialize connection, owner, repo, path, options = {}
9
9
  @path = path
10
+ fields = (options.has_key? :fields) ? options[:fields] : %w(number title body labels assignee state milestone created_at closed_at comments comments_url events_url html_url labels_url)
10
11
  issues = connection.issues.list user: owner, repo: repo, filter: 'all', auto_pagination: true
11
12
  Axlsx::Package.new do |p|
12
13
  p.workbook.add_worksheet(:name => @repo) do |s|
13
- fields = %w(number title body labels assignee state milestone created_at closed_at comments comments_url events_url html_url labels_url)
14
14
  s.add_row fields
15
15
  issues.each do |i|
16
16
  row = Array.new
17
17
  fields.each do |f|
18
- row.push case f
18
+ row.push case f.downcase
19
19
  when 'assignee'
20
20
  i.assignee.login unless i.assignee.nil?
21
21
  when 'labels'
@@ -5,18 +5,32 @@ module Githubissues
5
5
  module Port
6
6
  class Githubissues::Port::Import
7
7
  attr_reader :path, :messages
8
- def initialize connection, owner, repo, path
8
+ def initialize connection, owner, repo, path, options = {}
9
+ @path = path
10
+ fields = (options.has_key? :fields) ? options[:fields] : %w(labels)
9
11
  creek = Creek::Book.new path, :check_file_extension => false
10
12
  sheet= creek.sheets[0]
11
13
  @messages = []
12
14
  sheet.rows.each_with_index do |r, i|
13
- next if i.eql? 0
14
- number = r["A#{i+1}"]
15
- break if number.nil?
16
- label_string = r["D#{i+1}"]
17
- labels = (label_string.nil?) ? [] : label_string.split(',')
18
- issue = connection.issues.edit owner, repo, number, labels: labels
19
- @messages.push "The label for issue ##{number} updated to #{labels.join(',')}."
15
+ case i
16
+ when 0
17
+ @header = r.invert
18
+ else
19
+ number = r["A#{i+1}"]
20
+ updates = {}
21
+ break if number.nil?
22
+
23
+ fields.each do |f|
24
+ if @header.has_key? f
25
+ value = r[@header[f].gsub '1', (i+1).to_s]
26
+ value = value.split(',').map(&:strip) if f.downcase.eql?'labels' and (!value.nil?)
27
+ updates[f.downcase] = value
28
+ end
29
+ end
30
+
31
+ issue = connection.issues.edit owner, repo, number, updates
32
+ @messages.push "Issue ##{number} updated: #{updates.inspect}"
33
+ end
20
34
  end
21
35
  @messages
22
36
  end
@@ -1,5 +1,5 @@
1
1
  module Githubissues
2
2
  module Port
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
Binary file
data/spec/test_spec.rb CHANGED
@@ -2,19 +2,19 @@ require 'githubissues-port'
2
2
 
3
3
  describe 'githubissues-port exporting and importing to xlsx' do
4
4
  before(:all) do
5
- my_github_username = '***********'
6
- my_github_password = '***********'
5
+ my_github_username = '*********'
6
+ my_github_password = '*********'
7
7
  @connection = Github.new basic_auth: "#{my_github_username}:#{my_github_password}"
8
8
  end
9
9
 
10
10
  it 'export should be successfull.' do
11
- export = Githubissues::Port::Export.new @connection, 'pythonicrubyist', 'test_issues', 'export.xlsx'
11
+ export = Githubissues::Port::Export.new @connection, 'pythonicrubyist', 'test_issues', 'export.xlsx', fields: ['number', 'title', 'body', 'labels']
12
12
  puts export.path
13
13
  export.should_not be_nil
14
14
  end
15
15
 
16
16
  it 'import should be successfull.' do
17
- import = Githubissues::Port::Import.new @connection, 'pythonicrubyist', 'test_issues', 'spec/fixtures/sample.xlsx'
17
+ import = Githubissues::Port::Import.new @connection, 'pythonicrubyist', 'test_issues', 'spec/fixtures/sample.xlsx', fields: ['labels']
18
18
  puts import.messages.inspect
19
19
  import.should_not be_nil
20
20
  end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githubissues-port
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - pythonicrubyist
8
- - ankit8898
9
- - hemalijain
7
+ - Ramtin Vaziri
8
+ - Ankit gupta
9
+ - Hemali Jain
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []