get_issues 0.1.1 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34661abc538a1adc4907e7eb2e312f8f2e5b6f1b7971ed424dee266ff80c3737
4
- data.tar.gz: 63171b876881280829529ac9efe650ead817b0658f8588561c1b3c38d01c857a
3
+ metadata.gz: cb7c65b432b3e28c576fa2224130a2d338590214abdfbbdad8968a7e73a0abc0
4
+ data.tar.gz: 2482bed8567a15ff1e4d8ba275dee4660cb5003275b071c5df07c70b5d1c515b
5
5
  SHA512:
6
- metadata.gz: e3a17ffd858660f8f32b3dc6dbee700df48cec0637e1431a75d90d2346f274754b53f7455037767f38ab5d77277cedb86f97ada52a72a291af4f23fe056c5989
7
- data.tar.gz: 108950b36ddff39ecb35c830141419803991ebaa9e38b5ad953f68118b88a5d528a20083ff2bcc65b5240fa69a608f4f5059c32f0cf33644c1e41a0c93fd8594
6
+ metadata.gz: f61a2b4cfd7aa6f23680e1a87faf67d16c4ffb2f05a22bb73a61400a442531dee8c0f1c266c4f2fbcc51f9253227489948d262501d466e27653979d17ecd2e25
7
+ data.tar.gz: 1f349dcccb24b1938ebb291643c0bd7e63df2c114b6ac930362507626adf158e54162d83e3a3d76e118da2de4b404460e25a852d0473654cbda2c64aea5f7a67
data/.idea/.gitignore CHANGED
@@ -1,8 +1,8 @@
1
- # Default ignored files
2
- /shelf/
3
- /workspace.xml
4
- # Datasource local storage ignored files
5
- /dataSources/
6
- /dataSources.local.xml
7
- # Editor-based HTTP Client requests
8
- /httpRequests/
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
data/.idea/.rakeTasks CHANGED
@@ -1,7 +1,7 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
2
  <Settings><!--This file was automatically generated by Ruby plugin.
3
3
  You are allowed to:
4
4
  1. Remove rake task
5
5
  2. Add existing rake tasks
6
6
  To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.idea/get_issues.iml CHANGED
@@ -1,18 +1,18 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="ModuleRunConfigurationManager">
4
- <shared />
5
- </component>
6
- <component name="NewModuleRootManager">
7
- <content url="file://$MODULE_DIR$">
8
- <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
- <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
- <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
- </content>
12
- <orderEntry type="inheritedJdk" />
13
- <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.2, ruby-2.6.1-p33) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, ruby-2.6.1-p33) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.6.1-p33) [gem]" level="application" />
17
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="inheritedJdk" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.2, ruby-2.6.1-p33) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, ruby-2.6.1-p33) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.6.1-p33) [gem]" level="application" />
17
+ </component>
18
18
  </module>
data/.idea/misc.xml CHANGED
@@ -1,7 +1,7 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptSettings">
4
- <option name="languageLevel" value="ES6" />
5
- </component>
6
- <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.6.1-p33" project-jdk-type="RUBY_SDK" />
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-2.6.1-p33" project-jdk-type="RUBY_SDK" />
7
7
  </project>
data/.idea/modules.xml CHANGED
@@ -1,8 +1,8 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/get_issues.iml" filepath="$PROJECT_DIR$/.idea/get_issues.iml" />
6
- </modules>
7
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/get_issues.iml" filepath="$PROJECT_DIR$/.idea/get_issues.iml" />
6
+ </modules>
7
+ </component>
8
8
  </project>
data/.idea/vcs.xml CHANGED
@@ -1,6 +1,6 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
6
  </project>
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in get_issues.gemspec
6
6
  gemspec
7
+ gem 'spreadsheet_architect'
8
+
data/Gemfile.lock CHANGED
@@ -1,15 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- get_issues (0.1.1)
4
+ get_issues (0.1.2)
5
+ spreadsheet_architect (~> 4.2.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ activesupport (6.1.4.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ zeitwerk (~> 2.3)
16
+ axlsx_styler (1.1.0)
17
+ activesupport (>= 3.1)
18
+ caxlsx (>= 2.0.2)
19
+ builder (3.2.4)
20
+ caxlsx (3.1.0)
21
+ htmlentities (~> 4.3, >= 4.3.4)
22
+ marcel (~> 1.0)
23
+ nokogiri (~> 1.10, >= 1.10.4)
24
+ rubyzip (>= 1.3.0, < 3)
25
+ concurrent-ruby (1.1.9)
26
+ dry-inflector (0.2.1)
27
+ htmlentities (4.3.4)
28
+ i18n (1.8.10)
29
+ concurrent-ruby (~> 1.0)
30
+ marcel (1.0.1)
31
+ mini_portile2 (2.6.1)
9
32
  minitest (5.14.4)
33
+ nokogiri (1.12.3)
34
+ mini_portile2 (~> 2.6.1)
35
+ racc (~> 1.4)
36
+ nokogiri (1.12.3-x64-mingw32)
37
+ racc (~> 1.4)
38
+ racc (1.5.2)
10
39
  rake (10.5.0)
40
+ rodf (1.1.1)
41
+ builder (>= 3.0)
42
+ dry-inflector (~> 0.1)
43
+ rubyzip (>= 1.0)
44
+ rubyzip (2.3.2)
45
+ spreadsheet_architect (4.2.0)
46
+ axlsx_styler (>= 1.0.0, < 2)
47
+ caxlsx (>= 2.0.2, < 4)
48
+ rodf (>= 1.0.0, < 2)
49
+ tzinfo (2.0.4)
50
+ concurrent-ruby (~> 1.0)
51
+ zeitwerk (2.4.2)
11
52
 
12
53
  PLATFORMS
54
+ ruby
13
55
  x64-mingw32
14
56
 
15
57
  DEPENDENCIES
@@ -17,6 +59,7 @@ DEPENDENCIES
17
59
  get_issues!
18
60
  minitest (~> 5.0)
19
61
  rake (~> 10.0)
62
+ spreadsheet_architect
20
63
 
21
64
  BUNDLED WITH
22
65
  1.17.2
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
  ```ruby
25
- prefix_url = 'https://repo2.scm.atyun.com.cn/api/v4/projects'
25
+ prefix_url = 'https://xxxxxx/api/v4/projects'
26
26
  private_token = 'xxx'
27
27
  group_name = 'xxx'
28
28
  project_name = 'xxx'
data/get_issues.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |spec|
35
35
  spec.add_development_dependency "bundler", "~> 1.17"
36
36
  spec.add_development_dependency "rake", "~> 10.0"
37
37
  spec.add_development_dependency "minitest", "~> 5.0"
38
+ spec.add_runtime_dependency "spreadsheet_architect", "~> 4.2.0"
38
39
  end
@@ -1,3 +1,3 @@
1
1
  module GetIssues
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/get_issues.rb CHANGED
@@ -1,22 +1,81 @@
1
- require 'json'
1
+ require "json"
2
+ require "spreadsheet_architect"
2
3
 
3
4
  module GetIssues
4
5
  class Error < StandardError; end
5
- def self.start(prefix_url,private_token,project_name,mile_stone_title)
6
- projects_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}"`
7
- projects_json = JSON.parse(projects_string)
8
- project_json = projects_json.filter{|t| t["name"]==project_name}&.first
9
- project_id = project_json["id"]
10
-
11
6
 
12
- milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/#{project_id}/milestones"`
7
+
8
+ def self.start_group(prefix_url,private_token,group_name,mile_stone_title)
9
+ groups_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups"`
10
+ groups_json = JSON.parse(groups_string)
11
+ group_json = groups_json.filter { |t| t["name"] == group_name }&.first || {}
12
+ group_id = group_json["id"]
13
+ if group_id.nil?
14
+ p "找不到group"
15
+ end
16
+
17
+ milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups/#{group_id}/milestones"`
13
18
  milestones_json = JSON.parse(milestones_string)
14
- mile_stone_json = milestones_json.filter{|t| t["title"]==mile_stone_title}&.first
19
+ mile_stone_json = milestones_json.filter { |t| t["title"] == mile_stone_title }&.first
15
20
  mile_stone_id = mile_stone_json["id"]
21
+ if mile_stone_id.nil?
22
+ p "找不到mile_stone"
23
+ end
16
24
 
25
+ issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups/#{group_id}/milestones/#{mile_stone_id}/issues?per_page=10000"`
26
+ issues_json = JSON.parse(issues_string)
27
+ issues_json
28
+ end
17
29
 
18
- issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/#{project_id}/milestones/#{mile_stone_id}/issues"`
30
+ def self.start_project(prefix_url, private_token, project_name, mile_stone_title)
31
+ projects_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects"`
32
+ projects_json = JSON.parse(projects_string)
33
+ project_json = projects_json.filter { |t| t["name"] == project_name }&.first || {}
34
+ project_id = project_json["id"]
35
+ if project_id.nil?
36
+ p "找不到project"
37
+ end
38
+ milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects/#{project_id}/milestones"`
39
+ milestones_json = JSON.parse(milestones_string)
40
+ mile_stone_json = milestones_json.filter { |t| t["title"] == mile_stone_title }&.first || {}
41
+ mile_stone_id = mile_stone_json["id"]
42
+ if mile_stone_id.nil?
43
+ p "找不到mile_stone"
44
+ end
45
+ issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects/#{project_id}/milestones/#{mile_stone_id}/issues?per_page=10000"`
19
46
  issues_json = JSON.parse(issues_string)
20
47
  issues_json
21
48
  end
49
+
50
+ def self.to_xlsx(issues_json,mile_stone_title)
51
+ data = []
52
+ issues_json.each do |issue|
53
+ assignes_names = issue["assignees"]&.map { |t| t["name"]&.split(" ")&.reverse&.join("") }&.join(",")
54
+ milestone = issue["milestone"]["title"] rescue ""
55
+ data << ["##{issue["iid"]}",issue["title"], assignes_names, issue["labels"]&.join(","), milestone]
56
+ end
57
+ headers = %w(编号 标题 负责人 标签 归属端)
58
+ options = { headers: headers, data: data, header_style: init_header_style, row_style: init_row_style }
59
+ file_data = SpreadsheetArchitect.to_xlsx(options)
60
+ file = File.open("#{mile_stone_title}.xlsx".to_s, "wb+") do |f|
61
+ f.write file_data
62
+ end
63
+ end
64
+ def self.to_xlsx_group(prefix_url,private_token,group_name,mile_stone_title)
65
+ issues_json = start_group(prefix_url,private_token,group_name,mile_stone_title)
66
+ to_xlsx(issues_json,mile_stone_title)
67
+ end
68
+ def self.to_xlsx_project(prefix_url, private_token, project_name, mile_stone_title)
69
+ issues_json = start_project(prefix_url, private_token, project_name, mile_stone_title)
70
+ to_xlsx(issues_json,mile_stone_title)
71
+ end
72
+ # 定义xlsx文件格式的头样式
73
+ def self.init_header_style
74
+ { height: 75, background_color: "458B00", color: "FFFFFF", align: :center, font_name: "Arial", font_size: 14, bold: false, italic: false, underline: false }
75
+ end
76
+
77
+ # 定义xlsx文件的row样式
78
+ def self.init_row_style
79
+ { font_size: 12, align: :left }
80
+ end
22
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_issues
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - '807715333'
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-22 00:00:00.000000000 Z
11
+ date: 2021-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: spreadsheet_architect
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.2.0
55
69
  description: 根据里程碑获取issues
56
70
  email:
57
71
  - 807715333@qq.com