tpscript 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cumulative_flow +4 -2
- data/lib/cli.rb +29 -4
- data/lib/target_process.rb +9 -4
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c14985e9c67f5ae7fbb470a60ee23c742b236ad
|
4
|
+
data.tar.gz: 21438a0bd2fbb4fb75e8d17372a21f88d91c4778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1da436e5d1e9b660cec11aad99aa73c26e5121091677a05524d2bc41db50969a129ccee6286caedb383afcddfb6110221d13316fffa2d538b5ced3fa755d8ce8
|
7
|
+
data.tar.gz: 5972fe9c05d9a9341c6fa001b08350bec4242b6b34dbf4e98401097ce684015ab9440326bbde80d016fccf57d75e3b239b25994ba1f7a83b5bc5bd69eb20d5f0
|
data/bin/cumulative_flow
CHANGED
@@ -7,9 +7,11 @@ require_relative '../lib/cumulative_flow'
|
|
7
7
|
|
8
8
|
options = Cli.options!
|
9
9
|
|
10
|
-
tp = TargetProcess.new(username: options[:username], password: options[:password], base_uri: options[:base_uri])
|
10
|
+
tp = TargetProcess.new(username: options[:username], password: options[:password], base_uri: options[:base_uri], verify_ssl_certs: options[:verify])
|
11
|
+
|
12
|
+
stories = tp.user_stories("Team.Abbreviation" => options[:team],
|
13
|
+
"Project.Abbreviation" => options[:project])
|
11
14
|
|
12
|
-
stories = tp.user_stories(options[:team])
|
13
15
|
history = stories.flat_map {|s| tp.story_history(s["Id"]) }
|
14
16
|
|
15
17
|
puts CumulativeFlow.new(history, iteration_start: options[:day], states: options[:states]).to_csv
|
data/lib/cli.rb
CHANGED
@@ -18,12 +18,12 @@ module Cli
|
|
18
18
|
options[:team] = team
|
19
19
|
end
|
20
20
|
|
21
|
-
opts.on("-
|
22
|
-
options[:
|
21
|
+
opts.on("-p", "--project PROJ_ABBREVIATION", "(required) select a project to filter the data") do |project|
|
22
|
+
options[:project] = project
|
23
23
|
end
|
24
24
|
|
25
|
-
opts.on("-
|
26
|
-
options[:
|
25
|
+
opts.on("-u", "--username USERNAME", "(required) username to log on TargetProcess") do |username|
|
26
|
+
options[:username] = username
|
27
27
|
end
|
28
28
|
|
29
29
|
opts.on("-b", "--base-uri URI", "(required) URI of TargetProcess") do |uri|
|
@@ -39,8 +39,33 @@ module Cli
|
|
39
39
|
"day of week used as iteration start (defaults to tuesday)") do |day|
|
40
40
|
options[:day] = day
|
41
41
|
end
|
42
|
+
|
43
|
+
options[:verify] = true
|
44
|
+
opts.on("--[no-]verify", "verify ssl certificates") do |verify|
|
45
|
+
options[:verify] = verify
|
46
|
+
end
|
47
|
+
|
42
48
|
end.parse!(args)
|
43
49
|
|
50
|
+
unless options[:username] then
|
51
|
+
options[:username] = get_input("Username: ")
|
52
|
+
end
|
53
|
+
|
54
|
+
options[:password] = get_input("Password: ", echo: false)
|
55
|
+
|
44
56
|
options
|
45
57
|
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def self.get_input(prompt, echo: true)
|
62
|
+
$stderr.print prompt
|
63
|
+
if echo then
|
64
|
+
$stdin.gets.chomp
|
65
|
+
else
|
66
|
+
input = $stdin.noecho(&:gets).chomp
|
67
|
+
puts
|
68
|
+
input
|
69
|
+
end
|
70
|
+
end
|
46
71
|
end
|
data/lib/target_process.rb
CHANGED
@@ -5,14 +5,15 @@ require 'uri'
|
|
5
5
|
|
6
6
|
class TargetProcess
|
7
7
|
|
8
|
-
def initialize(username: nil, password: nil, base_uri: nil)
|
8
|
+
def initialize(username: nil, password: nil, base_uri: nil, verify_ssl_certs: true)
|
9
9
|
@username = username
|
10
10
|
@password = password
|
11
11
|
@base_uri = base_uri
|
12
|
+
@verify_ssl_certs = verify_ssl_certs
|
12
13
|
end
|
13
14
|
|
14
|
-
def user_stories(
|
15
|
-
get_items "#{@base_uri}/api/v1/UserStories?format=json&where
|
15
|
+
def user_stories(options)
|
16
|
+
get_items "#{@base_uri}/api/v1/UserStories?format=json&where=#{filter(options)}"
|
16
17
|
end
|
17
18
|
|
18
19
|
def story_history(id)
|
@@ -21,6 +22,10 @@ class TargetProcess
|
|
21
22
|
|
22
23
|
private
|
23
24
|
|
25
|
+
def filter(options)
|
26
|
+
URI.encode_www_form_component(options.map {|k,v| "(#{k} eq '#{v}')"}.join(" and "))
|
27
|
+
end
|
28
|
+
|
24
29
|
def parse_date(date)
|
25
30
|
match = /\/Date\(([0-9]+)([+-][0-9]+)\)\//.match date
|
26
31
|
DateTime.strptime(match[1], "%Q")
|
@@ -38,7 +43,7 @@ class TargetProcess
|
|
38
43
|
|
39
44
|
def get(url)
|
40
45
|
$stderr.puts "Getting #{url}..."
|
41
|
-
response = HTTParty.get(url, basic_auth: {username: @username, password: @password})
|
46
|
+
response = HTTParty.get(url, basic_auth: {username: @username, password: @password}, verify: @verify_ssl_certs)
|
42
47
|
JSON.parse(response.body)
|
43
48
|
end
|
44
49
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tpscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Fliri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|