git_manager 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/config/email.yml +7 -0
  2. data/lib/git_manager.rb +54 -14
  3. metadata +8 -4
data/config/email.yml ADDED
@@ -0,0 +1,7 @@
1
+ # example:
2
+ # email_config:
3
+ # from: you@yourdomain.com
4
+ # password: your_password_here
5
+ # users:
6
+ # "User 1 Full Name as found in git blame":"associated_email1@domain.com@"
7
+ # "User 2 Full Name as found in git blame":"associated_email2@domain.com@"
data/lib/git_manager.rb CHANGED
@@ -1,27 +1,67 @@
1
- #require 'rubygems'
2
-
3
- # usage Git::Blames::Pending.new(
4
- # :root => <root folder where build logs are located>
5
- # :rspec => boolean specifying whether or
6
- # not you want to run rspec now to get pending specs
7
- # ).blame
8
- # usage Git::Managed::Branch.new.delete_branches
1
+ # example usage
2
+ # Git::Blames::Pending.new(
3
+ # :root => <root folder where build logs are located>
4
+ # :rspec => boolean specifying whether or
5
+ # not you want to run rspec now to get pending specs
6
+ # ).blame( :email => true )
7
+ # for emailing create a config/email.yml file as specified
8
+ # in this gems own config/email.yml file
9
+ # example usage
10
+ # Git::Managed::Branch.new.delete_branches
11
+
12
+ require 'rubygems'
13
+ require 'net/smtp'
14
+ require 'yaml'
9
15
 
10
16
  module Git
17
+ module Emails
18
+ def load_configuration
19
+ config = YAML::load_file('./config/email.yml')
20
+ @email_from = config['authentication']['from']
21
+ @email_password = config['authentication']['password']
22
+ @email_mappings = config['users']
23
+ end
24
+
25
+ def send_gmail options
26
+ load_configuration
27
+ recipients = options[:recipients]
28
+ msg = "Subject: #{options[:subject]}\n\n#{options[:message]}"
29
+ smtp = Net::SMTP.new 'smtp.gmail.com', 587
30
+ smtp.enable_starttls
31
+ smtp.start( '', @email_from, @email_password, :login ) do
32
+ smtp.send_message(msg, @email_from, recipients.map{ |recipient| @email_mappings[recipient]})
33
+ end
34
+ end
35
+ end
36
+
11
37
  module Managed
12
38
  class Branch
13
39
  end
14
40
  end
41
+
15
42
  module Blames
16
- def blame
43
+ include Git::Emails
44
+ def blame(options = nil)
17
45
  self.tasks.each_pair do |key, attributes|
18
- puts "\nPending Spec Information:"
19
- puts " Description: #{key}"
20
- puts " Contributors: #{attributes[:contributors].join(', ')}"
21
- puts " File: #{attributes[:spec_file]}"
22
- puts " Line: #{attributes[:line_number]}\n"
46
+ if options.nil? || !options[:email]
47
+ stdout key, attributes
48
+ else
49
+ send_gmail :recipients => attributes[:contributors],
50
+ :subject => "Please collaborate to fix spec: " +
51
+ "#{attributes[:spec_file]} : " +
52
+ "#{attributes[:line_number]}",
53
+ :message => "Spec Details:\n " +
54
+ "#{attributes[:details].join('\n')}"
55
+ end
23
56
  end
24
57
  end
58
+ def stdout
59
+ puts "\nPending Spec Information:"
60
+ puts " Description: #{key}"
61
+ puts " Contributors: #{attributes[:contributors].join(', ')}"
62
+ puts " File: #{attributes[:spec_file]}"
63
+ puts " Line: #{attributes[:line_number]}\n"
64
+ end
25
65
  class Pending
26
66
  end
27
67
  class Blame
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_manager
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - kikuchiyo
@@ -18,7 +18,10 @@ cert_chain: []
18
18
  date: 2012-08-21 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: delete old git branches and blame pending specs
21
+ description: |-
22
+ delete old git branches and blame pending specs
23
+ for e-mailing: requires config/email.yml file in root directory
24
+ for using build logs make sure you pass path to Git::Blames::Pending.new through :root parameter
22
25
  email: kikuchiyo6@gmail.com
23
26
  executables: []
24
27
 
@@ -29,6 +32,7 @@ extra_rdoc_files: []
29
32
  files:
30
33
  - lib/git_manager.rb
31
34
  - lib/logs/2012-08-21_00-00-01
35
+ - config/email.yml
32
36
  - spec/git_manager_spec.rb
33
37
  homepage: http://rubygems.org/gems/git_manager
34
38
  licenses: []