murmurs 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/murmurs +10 -3
  3. data/lib/murmurs.rb +14 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f318e8f7a6753605c905258d8693312f7241a5ad
4
- data.tar.gz: 2c1d6a0ca1dc3f11b705f0131f220ee78487762b
3
+ metadata.gz: 5ceb67cfc3d4fb198e351f552d210920b5a4782c
4
+ data.tar.gz: 13873e634d77ec001d70ce537e8420da3ac25618
5
5
  SHA512:
6
- metadata.gz: 3da1f95bdc0c56c0ce2a8884bece1bcc4e3b9bf79bf0f624d6e23090f6e9d8ec28be865991f6cc856a68d870ce225be0563ca1cebf73264023510117b5e7163d
7
- data.tar.gz: 103e6c1a8715c6a2e67ab90953bd769c0b802bbc9cb3069863e025e82c4b35071d9422b06675277d1af739c45fd1fc87cb4b977fa16e678303699407538353ec
6
+ metadata.gz: ea6cabec5e53fc13b741d9a2c7b8864e98196d8c39f46d78b7e560d03cb718f2178d30e5ae269f64ee11fb5b69dfa5dc8ff934ed8fa32eb4b5507e735acb2be4
7
+ data.tar.gz: ddf79b99bc3ee18f5e9987c771bf5fe05e8bf6f5da8c585c59686860559dd0898a7cc1857c739a8081646a9aaff436fb70356a906bee8199fe5e1a99707831ca
data/bin/murmurs CHANGED
@@ -10,7 +10,8 @@ options = {
10
10
  :access_secret_key => ENV['MINGLE_ACCESS_SECRET_KEY'],
11
11
  :skip_ssl_verify => false,
12
12
  :git => false,
13
- :git_branch => 'master'
13
+ :git_branch => 'master',
14
+ :log_level => :info
14
15
  }
15
16
 
16
17
  NOTES = %Q{
@@ -40,7 +41,6 @@ opts = OptionParser.new do |opts|
40
41
 
41
42
  opts.on_tail('-g', '--git', 'Process standard input of Git hook post-receive, and murmur each commits; default is false') do
42
43
  options[:git] = true
43
- options[:log_level] = :info
44
44
  end
45
45
 
46
46
  opts.on("-b", "--git_branch GIT_BRANCH", "Murmur Git commits in branch, default is master") do |v|
@@ -51,6 +51,11 @@ opts = OptionParser.new do |opts|
51
51
  options[:skip_ssl_verify] = true
52
52
  end
53
53
 
54
+ opts.on_tail('-v', '--version') do
55
+ puts Gem.loaded_specs['murmurs'].version
56
+ exit(0)
57
+ end
58
+
54
59
  opts.on_tail('-h', '--help') do
55
60
  puts opts
56
61
  puts NOTES
@@ -60,4 +65,6 @@ opts = OptionParser.new do |opts|
60
65
  end.parse!
61
66
 
62
67
  include Murmurs
63
- murmur(options.delete(:murmurs_url), ARGV[0] || ARGF.read, options)
68
+
69
+ msg = ARGV[0] || (STDIN.tty? ? nil : STDIN.read)
70
+ murmur(options.delete(:murmurs_url), msg, options)
data/lib/murmurs.rb CHANGED
@@ -17,26 +17,33 @@ module Murmurs
17
17
  if msg.nil? || msg.empty?
18
18
  log(options[:log_level], "Nothing to murmur.")
19
19
  else
20
- log(options[:log_level], msg)
20
+ log(options[:log_level], "murmur #{truncate(msg)} => #{extract_project_info(url)}")
21
21
  http_post(url, {:murmur => {:body => msg}}, options)
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
+ def extract_project_info(url)
27
+ if url =~ /\/projects\/([^\/]+)\//
28
+ "#{$1}@#{URI(url).host}"
29
+ else
30
+ url
31
+ end
32
+ end
33
+
26
34
  def validate_murmurs_url!(url)
27
35
  if url.to_s !~ /\Ahttps?\:\/\/.+\/murmurs/
28
36
  raise InvalidMurmursURLError, "Invalid murmurs URL: #{url.inspect}"
29
37
  end
30
38
  end
31
39
 
40
+ def truncate(m, t=15)
41
+ m.size > t ? "#{m[0..t]}..." : m
42
+ end
43
+
32
44
  def log(level, m)
33
45
  if level == :info
34
- t = 20
35
- if m.size > t
36
- puts "murmur #{m[0..t]}..."
37
- else
38
- puts "murmur #{m}"
39
- end
46
+ puts m
40
47
  end
41
48
  end
42
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: murmurs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ThoughtWorks Mingle Team