project_monitor_stat 0.0.3 → 0.0.4
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 +4 -4
- data/bin/project_monitor_stat +3 -3
- data/lib/project_monitor_stat/config.rb +14 -26
- data/lib/project_monitor_stat/fetcher.rb +4 -4
- data/lib/project_monitor_stat/util.rb +3 -2
- data/lib/project_monitor_stat.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0a9a51e769f21160a57b01e91f80539e314b80
|
4
|
+
data.tar.gz: 042c169698f2eff51239004cce48d3d8b7585fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e34b3d10f5af30ae5ea275a69630e946a2a4bfd0df572a13d621a8bd6aaa091ae0c79e7481b2211c56b9fa949de7dd5d9e2b686d9ca4b317c8e98e7d53add4
|
7
|
+
data.tar.gz: 406b0243a737fb93dd22615a4ba4fb78d1d1df96f4c337175739cabe82a939cd1755e6e510578b19a68f2e0ba4879deb3a450474893737f4ab57cf8fd6d267db
|
data/bin/project_monitor_stat
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
require 'project_monitor_stat'
|
3
3
|
|
4
4
|
config = ProjectMonitorStat::Config.parse_options(argv: ARGV)
|
5
|
-
result = ProjectMonitorStat::Fetcher.new(
|
6
|
-
ProjectMonitorStat::Reporter.new(config: config, result: result)
|
7
|
-
|
5
|
+
result = ProjectMonitorStat::Fetcher.new(config: config).fetch
|
6
|
+
reporter = ProjectMonitorStat::Reporter.new(config: config, result: result)
|
7
|
+
reporter.report
|
@@ -5,40 +5,37 @@ module ProjectMonitorStat
|
|
5
5
|
class Config
|
6
6
|
def self.parse_options(argv: raise)
|
7
7
|
tag = argv[0] || raise(ArgumentError.new('You must provide a tag'))
|
8
|
-
|
9
|
-
|
10
|
-
success_cmd = nil
|
11
|
-
building_cmd = nil
|
12
|
-
fail_cmd = nil
|
8
|
+
instance = new
|
9
|
+
instance.base_url = 'http://pulse.pivotallabs.com/projects.json'
|
13
10
|
|
14
11
|
opt_parser = OptionParser.new do |opts|
|
15
12
|
opts.banner = "Usage: #{File.basename(__FILE__)} tag [options]"
|
16
13
|
|
17
14
|
opts.on('-sCOMMAND', '--success COMMAND',
|
18
15
|
'Success command') do |s|
|
19
|
-
success_cmd = s
|
16
|
+
instance.success_cmd = s
|
20
17
|
end
|
21
18
|
|
22
19
|
opts.on('-bCOMMAND', '--building COMMAND',
|
23
20
|
'Building command') do |b|
|
24
|
-
building_cmd = b
|
21
|
+
instance.building_cmd = b
|
25
22
|
end
|
26
23
|
|
27
24
|
opts.on('-fCOMMAND', '--fail COMMAND',
|
28
25
|
'Fail command') do |s|
|
29
|
-
fail_cmd = s
|
26
|
+
instance.fail_cmd = s
|
30
27
|
end
|
31
28
|
|
32
29
|
opts.on('-u', '--url',
|
33
30
|
'Your projectMonitor url ',
|
34
|
-
" Default: #{
|
35
|
-
|
31
|
+
" Default: #{instance.base_url}") do |u|
|
32
|
+
instance.base_url = u
|
36
33
|
end
|
37
34
|
|
38
|
-
opts.on('-
|
39
|
-
'Your
|
40
|
-
' Get this from your browser cookie inspector') do |
|
41
|
-
|
35
|
+
opts.on('-c', '--cookies []',
|
36
|
+
'Your cookie string',
|
37
|
+
' Get this from your browser cookie inspector') do |c|
|
38
|
+
instance.cookie = c
|
42
39
|
end
|
43
40
|
|
44
41
|
opts.on_tail('-h', '--help', 'Show this message') do
|
@@ -54,19 +51,10 @@ module ProjectMonitorStat
|
|
54
51
|
|
55
52
|
opt_parser.parse!(argv)
|
56
53
|
|
57
|
-
|
54
|
+
instance
|
58
55
|
end
|
59
56
|
|
60
|
-
|
61
|
-
|
62
|
-
def initialize(url: raise, tag: raise, success_cmd: raise, building_cmd: raise, fail_cmd: raise, session_id: nil)
|
63
|
-
@base_url = url
|
64
|
-
@tag = tag
|
65
|
-
@success_cmd = success_cmd
|
66
|
-
@building_cmd = building_cmd
|
67
|
-
@fail_cmd = fail_cmd
|
68
|
-
@session_id = session_id
|
69
|
-
end
|
57
|
+
attr_accessor :base_url, :success_cmd, :building_cmd, :fail_cmd, :cookie
|
70
58
|
|
71
59
|
def url
|
72
60
|
uri = URI(base_url)
|
@@ -76,6 +64,6 @@ module ProjectMonitorStat
|
|
76
64
|
|
77
65
|
private
|
78
66
|
|
79
|
-
attr_reader :
|
67
|
+
attr_reader :tag
|
80
68
|
end
|
81
69
|
end
|
@@ -3,12 +3,12 @@ require 'json'
|
|
3
3
|
|
4
4
|
module ProjectMonitorStat
|
5
5
|
class Fetcher
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(config: raise)
|
7
|
+
@config = config
|
8
8
|
end
|
9
9
|
|
10
10
|
def fetch
|
11
|
-
json = Util.get(url)
|
11
|
+
json = Util.get(url: config.url, cookie: config.cookie)
|
12
12
|
|
13
13
|
begin
|
14
14
|
projects = JSON.parse(json)
|
@@ -40,6 +40,6 @@ module ProjectMonitorStat
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
-
attr_reader :
|
43
|
+
attr_reader :config
|
44
44
|
end
|
45
45
|
end
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module ProjectMonitorStat
|
2
2
|
class Util
|
3
3
|
def self.puts(*args)
|
4
|
-
|
4
|
+
Kernel.puts(*args)
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.system(*args)
|
8
8
|
Kernel.system(*args)
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.get(url)
|
11
|
+
def self.get(url: raise, cookie: nil)
|
12
12
|
uri = URI(url)
|
13
13
|
request = Net::HTTP::Get.new(uri)
|
14
|
+
request.add_field('Cookie', cookie) if cookie
|
14
15
|
|
15
16
|
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
|
16
17
|
http.request(request)
|
data/lib/project_monitor_stat.rb
CHANGED