tpscript 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9239fce751b676a3dc58d6ac0cc61d5d1f0c5545
4
- data.tar.gz: a211c7b9bd46f62807fd14335549a1f299ff1220
3
+ metadata.gz: 9c14985e9c67f5ae7fbb470a60ee23c742b236ad
4
+ data.tar.gz: 21438a0bd2fbb4fb75e8d17372a21f88d91c4778
5
5
  SHA512:
6
- metadata.gz: 505a7a4a2b6a8e873a4efc62d346a6e9959e64dd6471106c677cc6233e887795c176237c2b3e8358c80f2d87e82a0c98f8d85a9ca71f0bf57a7a1e4c67fd4480
7
- data.tar.gz: bd765a20e32aed54d9c26315bee9fda67eb8fd7336ae91588090074cf5beed3ff76c9dcb8d0605b6213ffe38d35109340afb6b91ae3fa0e73e5a23380ab2440b
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("-u", "--username USERNAME", "(required) username to log on TargetProcess") do |username|
22
- options[:username] = username
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("-p", "--password PASSWORD", "(required) password to log on TargetProcess") do |password|
26
- options[:password] = password
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
@@ -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(team_abbr)
15
- get_items "#{@base_uri}/api/v1/UserStories?format=json&where=Team.Abbreviation%20eq%20%27#{team_abbr}%27"
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
@@ -1,3 +1,3 @@
1
1
  module Tpscript
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-28 00:00:00.000000000 Z
11
+ date: 2014-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler