get_issues 0.1.2 → 0.1.6

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: c647790e195bc2bf3094c7ee73839692f4f2bf67f538c3e20b35dd495a2f1360
4
- data.tar.gz: ee006ee93851277ecf3f6c92126a6d6bfb2f4afec3c4a15775d875b312fa40e2
3
+ metadata.gz: 587b8c56362302e2938510d98cbf0178313181060445999b13f7f0bbae799537
4
+ data.tar.gz: 6a9d1aaf452391f6a16f3bfc51e51f88f2570fada575f6a0b60eec1fa3c1319e
5
5
  SHA512:
6
- metadata.gz: 72fef0227a84cb21832358b28bac2c0837b1c25828da2be79f7fd4f5fd7f09f527260250bd4e2d276138516c46a590daf752c619c743bfe381fcd136e2719bd4
7
- data.tar.gz: 7837421247d2ee2070ee605c32e459160e82f7835d5a24e13045edcc4b0a5ce98e889e98cff51ea8da59b39b16804ff7bbe11efd911916693f9028164a62fb60
6
+ metadata.gz: 579c044bf1549efab620115a82b49c527612f79a9072e896d61cc509ed882987f312061969a46db9eea56056ba50e0dc6393ce8256571b19e7da4ba33c8b051d
7
+ data.tar.gz: 689184fd5eddc34082cdf13c371cf2ea8b669e651a5928a5a3279e97c04bfe4d1a068d0191f86a46e9f746f6b7a668ecd1f8b3a352d54335a5035b7493d879d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
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/
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.2"
2
+ VERSION = "0.1.6"
3
3
  end
data/lib/get_issues.rb CHANGED
@@ -3,25 +3,51 @@ require "spreadsheet_architect"
3
3
 
4
4
  module GetIssues
5
5
  class Error < StandardError; end
6
+ https://repo.scm.atyun.com.cn/api/v4/projects?sort=asc&&order_by=name&&simple=true&&per_page=1000
6
7
 
7
- def self.start(prefix_url, private_token, project_name, mile_stone_title)
8
- projects_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}"`
9
- projects_json = JSON.parse(projects_string)
10
- project_json = projects_json.filter { |t| t["name"] == project_name }&.first
11
- project_id = project_json["id"]
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?per_page=1000"`
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
12
16
 
13
- milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/#{project_id}/milestones"`
17
+ milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups/#{group_id}/milestones?per_page=1000"`
14
18
  milestones_json = JSON.parse(milestones_string)
15
19
  mile_stone_json = milestones_json.filter { |t| t["title"] == mile_stone_title }&.first
16
20
  mile_stone_id = mile_stone_json["id"]
21
+ if mile_stone_id.nil?
22
+ p "找不到mile_stone"
23
+ end
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?sort=asc&&order_by=name&&simple=true&&per_page=1000"`
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&&per_page=1000"`
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
22
49
 
23
- def self.to_xlsx(prefix_url, private_token, project_name, mile_stone_title)
24
- issues_json = start(prefix_url, private_token, project_name, mile_stone_title)
50
+ def self.to_xlsx(issues_json,mile_stone_title)
25
51
  data = []
26
52
  issues_json.each do |issue|
27
53
  assignes_names = issue["assignees"]&.map { |t| t["name"]&.split(" ")&.reverse&.join("") }&.join(",")
@@ -35,6 +61,14 @@ module GetIssues
35
61
  f.write file_data
36
62
  end
37
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
38
72
  # 定义xlsx文件格式的头样式
39
73
  def self.init_header_style
40
74
  { height: 75, background_color: "458B00", color: "FFFFFF", align: :center, font_name: "Arial", font_size: 14, bold: false, italic: false, underline: false }
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.2
4
+ version: 0.1.6
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-23 00:00:00.000000000 Z
11
+ date: 2021-11-26 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