banery_stats 0.0.1
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 +7 -0
- data/bin/banery_stats +3 -0
- data/lib/banery_stats.rb +66 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 380f564eb7ec4c5e3aa4cab68bb72f615994a43d
|
4
|
+
data.tar.gz: a3c548d0524d3691f56c65c5aa67252b7b5e40f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f0f962f9a7f736723418a2e6d994d68ea2f8c8835dea159f512c62e8e4caaae2aa30c1d02444c89a8a24963e668ce52a4386daaf6a63cf2e43ad263363e7764
|
7
|
+
data.tar.gz: 3c5e187b8435f0b03d2c9c41180d4671c631322e011b410acb4ab81ce7524e9fc2c250f87bf29d1f675653bd0f57c74410cf943808ddec21eb99f5a8d99dc6a2
|
data/bin/banery_stats
ADDED
data/lib/banery_stats.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
2
|
+
require 'active_support/json'
|
3
|
+
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
module BaneryStats
|
7
|
+
mattr_accessor :api_token
|
8
|
+
|
9
|
+
class OutputSummary
|
10
|
+
def self.run
|
11
|
+
new.run
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
workspaces.each do |workspace|
|
16
|
+
puts "WORKSPACE #{workspace.name} #projects: #{workspace.projects.size}"
|
17
|
+
workspace.projects.each do |workspace_project|
|
18
|
+
project_tasks = project_tasks(workspace.name, workspace_project.id)
|
19
|
+
puts "#{project_tasks.size.to_s.rjust(5)} #{workspace_project.name}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def workspaces
|
25
|
+
data = http_get("https://kanbanery.com/api/v1/user/workspaces.json/")
|
26
|
+
data.collect do |workspace_data|
|
27
|
+
projects = workspace_data["projects"].collect { |workspace_project| OpenStruct.new(id: workspace_project["id"], name: workspace_project["name"]) }
|
28
|
+
OpenStruct.new(id: workspace_data["id"], name: workspace_data["name"], projects: projects)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def project_tasks(workspace_name, project_id)
|
33
|
+
data = http_get("https://#{workspace_name}.kanbanery.com/api/v1/projects/#{project_id}/tasks.json")
|
34
|
+
data.keep_if { |d| d.has_key?("owner_id") && d["owner_id"] == own_user_id }
|
35
|
+
data
|
36
|
+
end
|
37
|
+
|
38
|
+
def own_user_id
|
39
|
+
@own_user_id ||=
|
40
|
+
begin
|
41
|
+
data = http_get("https://avarteq.kanbanery.com/api/v1/user.json")
|
42
|
+
data["id"]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def http_get(url)
|
49
|
+
uri = URI.parse(url)
|
50
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
51
|
+
http.use_ssl = true
|
52
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
53
|
+
|
54
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
55
|
+
request['X-Kanbanery-ApiToken'] = BaneryStats.api_token or raise "You must set BaneryStats.api_token to your API token"
|
56
|
+
|
57
|
+
response = http.request(request)
|
58
|
+
|
59
|
+
data = ActiveSupport::JSON.decode(response.body)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
BaneryStats.api_token = ENV['KANBANERY_API_TOKEN']
|
65
|
+
|
66
|
+
BaneryStats::OutputSummary.run
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: banery_stats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Gogolok
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.1.0
|
27
|
+
description: Simple kanbanery overview tool
|
28
|
+
email: gogolok@gmail.com
|
29
|
+
executables:
|
30
|
+
- banery_stats
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/banery_stats.rb
|
35
|
+
- bin/banery_stats
|
36
|
+
homepage: https://github.com/gogolok/banery_stats
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.0.6
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Banery stats
|
60
|
+
test_files: []
|