project_monitor_stat 0.0.6 → 0.0.7

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: 60cafe63acb23bdd72a7faf84396a3e04e4da2b0
4
- data.tar.gz: 7763aaf8a523c96b6af81cc3dee9891437257b62
3
+ metadata.gz: a9ef3f44c9a7b97f66cbe1418ea316431af361c1
4
+ data.tar.gz: 2b4ee8859d568cc37c03e3cb047a5e07411cd668
5
5
  SHA512:
6
- metadata.gz: 5fd66e2ad6a8074952d9ff5252f8a3e3055b4c96fd0bf22016e121f7f07a20d7f26932f5cb195072abf012e1f68d542fc699f2c847dba6ca14ae0750c88c78ac
7
- data.tar.gz: a804ad1ebddfb9ac628688f3591e77a85ff1db3e12d79c10d660a2deed056ef163e1173fa8132a48a87bd3819dae1415003138c72d8a544d04758a333a391331
6
+ metadata.gz: 1403642cdb4c77c26bad5ba55830411bab9108035fb6dba32e9a75726ca9692fe7784aaeb8b0e8951e0bc13864553954d25325d94389d2deb79347e24ecae5a6
7
+ data.tar.gz: d450706ae7cc5d6086d0cc6bfcf856d1fe46c409e36149c56c6da5272dd72c35f3c6b9cc39d5d0d51e94dcc038e3d15a57d0260432d7d55499711997261cfee4
@@ -1,7 +1,8 @@
1
1
  module ProjectMonitorStat
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
 
4
4
  autoload :Config, 'project_monitor_stat/config'
5
+ autoload :GitEmailParser, 'project_monitor_stat/git_email_parser'
5
6
  autoload :Fetcher, 'project_monitor_stat/fetcher'
6
7
  autoload :Reporter, 'project_monitor_stat/reporter'
7
8
  autoload :Util, 'project_monitor_stat/util'
@@ -4,14 +4,30 @@ require 'optparse'
4
4
  module ProjectMonitorStat
5
5
  class Config
6
6
  def self.parse_options(argv: raise)
7
- tag = argv[0] || raise(ArgumentError.new('You must provide a tag'))
8
7
  instance = new
9
- instance.tag = tag
10
8
  instance.base_url = 'http://pulse.pivotallabs.com/projects.json'
11
9
  instance.idle_seconds = 600
12
10
 
13
11
  opt_parser = OptionParser.new do |opts|
14
- opts.banner = "Usage: #{File.basename(__FILE__)} tag [options]"
12
+ opts.banner = 'Usage: project_monitor_stat [options]'
13
+
14
+ opts.on('-t tag1,tag2', '--tags tag1,tag2,tag3', Array,
15
+ 'Project Monitor tags') do |t|
16
+ instance.tags = t
17
+ end
18
+
19
+ opts.on('-g', '--git-author-tags',
20
+ 'Use current git author username@ or pair+usernames@ for tags') do
21
+ git_email_parser = GitEmailParser.new
22
+
23
+ if git_email_parser.username_tags.empty?
24
+ Util.puts "Error: Invalid git email: '#{git_email_parser.git_email}'"
25
+ Util.puts opts
26
+ exit(1)
27
+ end
28
+
29
+ instance.tags = git_email_parser.username_tags
30
+ end
15
31
 
16
32
  opts.on('-sCOMMAND', '--success COMMAND',
17
33
  'Command after success') do |s|
@@ -52,12 +68,12 @@ module ProjectMonitorStat
52
68
  end
53
69
 
54
70
  opts.on_tail('-h', '--help', 'Show this message') do
55
- puts opts
71
+ Util.puts opts
56
72
  exit
57
73
  end
58
74
 
59
75
  opts.on_tail('--version', 'Show version') do
60
- puts VERSION
76
+ Util.puts VERSION
61
77
  exit
62
78
  end
63
79
  end
@@ -67,11 +83,11 @@ module ProjectMonitorStat
67
83
  instance
68
84
  end
69
85
 
70
- attr_accessor :tag, :base_url, :success_cmd, :building_cmd, :fail_cmd, :idle_cmd, :idle_seconds, :cookie
86
+ attr_accessor :tags, :base_url, :success_cmd, :building_cmd, :fail_cmd, :idle_cmd, :idle_seconds, :cookie
71
87
 
72
88
  def url
73
89
  uri = URI(base_url)
74
- uri.query = "tags=#{tag}"
90
+ uri.query = "tags=#{tags.join(',')}"
75
91
  uri
76
92
  end
77
93
  end
@@ -0,0 +1,26 @@
1
+ module ProjectMonitorStat
2
+ class GitEmailParser
3
+ SOLO_USERNAME_REGEX = /\A[^+]+(?=@)/
4
+ PAIR_USERNAME_REGEX = /(?<=[\+^])\w+(?=[\+@])/
5
+
6
+ attr_reader :git_email
7
+
8
+ def initialize
9
+ @git_email = Util.x('git config --get user.email')
10
+ end
11
+
12
+ def username_tags
13
+ solo_usernames | pair_usernames
14
+ end
15
+
16
+ private
17
+
18
+ def solo_usernames
19
+ git_email.scan(SOLO_USERNAME_REGEX)
20
+ end
21
+
22
+ def pair_usernames
23
+ git_email.scan(PAIR_USERNAME_REGEX)
24
+ end
25
+ end
26
+ end
@@ -11,6 +11,10 @@ module ProjectMonitorStat
11
11
  Kernel.system(*args)
12
12
  end
13
13
 
14
+ def self.x(command)
15
+ %x(#{command}).chomp
16
+ end
17
+
14
18
  def self.get(url: raise, cookie: nil)
15
19
  uri = URI(url)
16
20
  request = Net::HTTP::Get.new(uri)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: project_monitor_stat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Young
@@ -66,6 +66,7 @@ files:
66
66
  - lib/project_monitor_stat.rb
67
67
  - lib/project_monitor_stat/config.rb
68
68
  - lib/project_monitor_stat/fetcher.rb
69
+ - lib/project_monitor_stat/git_email_parser.rb
69
70
  - lib/project_monitor_stat/reporter.rb
70
71
  - lib/project_monitor_stat/util.rb
71
72
  homepage: http://rubygems.org/gems/project_monitor_stat