reviewlette 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Reviewlette::Vacations do
3
+ describe Vacations do
4
4
 
5
+ subject { Vacations }
5
6
 
6
- describe '.find_vacation' do
7
+ describe '.find_vacations' do
7
8
 
8
9
  it 'parses the vacations dates out of tel' do
9
- expect(Reviewlette::Vacations.find_vacations('jschmid')).to be_a_kind_of Array
10
+ expect_any_instance_of(Net::Telnet).to receive(:cmd).with('testuser1').and_return "Absence : Thu 2015-04-02 - Tue 2015-04-07"
11
+
12
+ vacations = subject.find_vacations('testuser1')
13
+ expect(vacations).to be_kind_of(Array)
14
+ expect(vacations).to eq([Date.parse('2015-04-02')..Date.parse('2015-04-07')])
15
+ end
16
+
17
+ end
18
+
19
+
20
+ describe '.members_on_vacation' do
21
+
22
+ it 'finds members on vacation' do
23
+ MEMBERS_CONFIG['members'] = [{'suse_username' => 'testuser1'}, {'suse_username' =>'testuser2'}, {'suse_username' =>'testuser3'}]
24
+ allow(subject).to receive(:find_vacations).with('testuser1').and_return [(Date.today - 1)..(Date.today + 2)]
25
+ allow(subject).to receive(:find_vacations).with('testuser2').and_return [(Date.today - 1)..(Date.today - 1)]
26
+ allow(subject).to receive(:find_vacations).with('testuser3').and_return []
27
+
28
+ expect(subject.members_on_vacation).to be_kind_of(Array)
29
+ expect(subject.members_on_vacation).to eq(['testuser1'])
10
30
  end
31
+
11
32
  end
12
- end
33
+
34
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviewlette
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
  - jschmid1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-02 00:00:00.000000000 Z
11
+ date: 2015-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-trello
@@ -74,42 +74,28 @@ executables:
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
78
- - .rspec
79
- - .travis.yml
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
80
  - Gemfile
81
81
  - Gemfile.lock
82
- - Guardfile
83
82
  - LICENSE
84
83
  - README.md
85
84
  - Rakefile
86
85
  - bin/reviewlette
87
- - config/.github.yml
88
- - config/.members.yml
89
- - config/.trello.yml
90
- - lib/matching.rb
86
+ - config/github_example.yml
87
+ - config/members_example.yml
88
+ - config/trello_example.yml
91
89
  - lib/reviewlette.rb
92
- - lib/reviewlette/database.rb
93
- - lib/reviewlette/exceptions.rb
94
90
  - lib/reviewlette/github_connection.rb
95
- - lib/reviewlette/graph.html
96
- - lib/reviewlette/graph_gen.rb
97
- - lib/reviewlette/mail.rb
98
- - lib/reviewlette/reviewlette.db
99
91
  - lib/reviewlette/trello_connection.rb
100
92
  - lib/reviewlette/vacations.rb
101
- - lib/reviewlette/version.rb
102
- - prophet.rb
103
- - reviewlette.db
104
93
  - reviewlette.gemspec
105
- - spec/database_spec.rb
106
94
  - spec/github_connection_spec.rb
107
95
  - spec/reviewlette_spec.rb
108
96
  - spec/spec_helper.rb
109
- - spec/support/request_stubbing.rb
110
97
  - spec/trello_connection_spec.rb
111
98
  - spec/vacation_spec.rb
112
- - task
113
99
  homepage: http://rubygems.org/gems/reviewlette
114
100
  licenses:
115
101
  - MIT
@@ -120,26 +106,25 @@ require_paths:
120
106
  - lib
121
107
  required_ruby_version: !ruby/object:Gem::Requirement
122
108
  requirements:
123
- - - '>='
109
+ - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  required_rubygems_version: !ruby/object:Gem::Requirement
127
113
  requirements:
128
- - - '>='
114
+ - - ">="
129
115
  - !ruby/object:Gem::Version
130
116
  version: '0'
131
117
  requirements: []
132
118
  rubyforge_project:
133
- rubygems_version: 2.0.3
119
+ rubygems_version: 2.2.2
134
120
  signing_key:
135
121
  specification_version: 4
136
122
  summary: Randomly assignes a reviewer to your Pullrequest and corresponding Trello
137
123
  Card.
138
124
  test_files:
139
- - spec/database_spec.rb
140
125
  - spec/github_connection_spec.rb
141
126
  - spec/reviewlette_spec.rb
142
127
  - spec/spec_helper.rb
143
- - spec/support/request_stubbing.rb
144
128
  - spec/trello_connection_spec.rb
145
129
  - spec/vacation_spec.rb
130
+ has_rdoc:
data/Guardfile DELETED
@@ -1,24 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :rspec do
5
- watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
8
-
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
- watch('config/routes.rb') { "spec/routing" }
15
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
-
17
- # Capybara features specs
18
- watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
- end
24
-
data/config/.github.yml DELETED
@@ -1,2 +0,0 @@
1
- token: 123asdasd2312313asdasd123123123asdasd
2
- repo: jschmid1/reviewlette
data/config/.members.yml DELETED
@@ -1 +0,0 @@
1
- jschmid: 'jschmid1'
data/config/.trello.yml DELETED
@@ -1,4 +0,0 @@
1
- consumerkey: 1223123123asdasdasd123123123asasd
2
- consumersecret: 1231231335454534343asdasdasd434343qweqweqw12
3
- oauthtoken: 123asdasd123123asdasdad123123asdasd123123asdasd
4
- board_id: 'UuKxYj6M'
data/lib/matching.rb DELETED
File without changes
@@ -1,77 +0,0 @@
1
- require 'sequel'
2
- require 'fileutils'
3
- module Reviewlette
4
-
5
- class Database
6
-
7
- FileUtils.mkdir_p("#{File.join(ENV['HOME'])}/.config/reviewlette/") unless Dir.exists?("#{ENV['HOME']}/.config/reviewlette")
8
- FileUtils.cp ("#{File.dirname(__FILE__)}/../../reviewlette.db"), ("#{File.join(Dir.home)}" + '/.config/reviewlette/') unless File.exists?(("#{File.join(Dir.home)}" + '/.config/reviewlette/reviewlette.db'))
9
-
10
- @path = "#{File.join(ENV['HOME'])}/.config/reviewlette"
11
- DATABASE = Sequel.connect("sqlite://#{@path}/reviewlette.db")
12
-
13
- attr_accessor :reviewer, :reviews
14
-
15
- def initialize
16
- @reviewer = DATABASE.from(:reviewer)
17
- @reviews = DATABASE.from(:reviews)
18
- end
19
-
20
- def count_up(reviewer)
21
- pr_reviewer = @reviewer.where(:trello_name => reviewer).select(:trello_name).first.values.first
22
- counter = @reviewer.where(:trello_name => pr_reviewer).select(:reviews).first.values.first
23
- @reviewer.where(:trello_name => reviewer).update(:reviews => counter.next)
24
- end
25
-
26
- def add_pr_to_db(pr_name, reviewer)
27
- @reviews.insert(:name => pr_name, :reviewer => reviewer, :created_at => Date.today)
28
- count_up(reviewer)
29
- end
30
-
31
- def get_users_tel_entries
32
- @reviewer.map([:tel_name]).flatten.select{|user| user unless user.nil?}
33
- end
34
-
35
- def get_users_gh_entries
36
- @reviewer.map([:gh_name]).flatten.select{|user| user unless user.nil?}
37
- end
38
-
39
- def get_users_trello_entries
40
- @reviewer.where(:vacation => 'false').map([:trello_name]).flatten.select{|user| user unless user.nil?}
41
- end
42
-
43
- def count_reviews(reviewer)
44
- @reviews.where(:reviewer => reviewer).count
45
- end
46
-
47
- def find_gh_name_by_trello_name(trello_name)
48
- @reviewer.where(:trello_name => trello_name).select(:gh_name).first.values.first
49
- end
50
-
51
- def set_vacation_flag(reviewer, state)
52
- @reviewer.where(:tel_name => reviewer).update(:vacation => state)
53
- end
54
-
55
- def conscruct_graph_struct
56
- data = []
57
- get_users_trello_entries.each do |x|
58
- data.push({ label: x, value: count_reviews(x) })
59
- end
60
- data
61
- end
62
-
63
- def conscruct_line_data
64
- data = []
65
- date_range = (Date.today - 7 )..(Date.today)
66
- get_users_trello_entries.each do |name|
67
- date_range.each do |date|
68
- abc = {}
69
- abc[:created_at] = date
70
- abc[name] = @reviews.where(:reviewer => name, :created_at => date).select(:created_at).count
71
- data.push(abc)
72
- end
73
- end
74
- data
75
- end
76
- end
77
- end
@@ -1,7 +0,0 @@
1
- module Reviewlette
2
- class AlreadyAssignedException < Exception
3
- end
4
-
5
- class NoTrelloCardException < Exception
6
- end
7
- end
@@ -1,17 +0,0 @@
1
- <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.5.1.css">
2
- <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
3
- <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
4
- <script src="http://cdn.oesmith.co.uk/morris-0.5.1.min.js"></script>
5
-
6
- <div id="Donutgraph" style="height: 250px;"></div>
7
-
8
- <script>
9
- new Morris.Donut({
10
- element: 'Donutgraph',
11
- data: [{"label":"jschmid","value":3},{"label":"vlewin","value":4},{"label":"b4mboo","value":5},{"label":"thomasschmidt","value":6},{"label":"achernikov","value":7}],
12
- xkey: 'label',
13
- colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
14
- ykeys: ['value'],
15
- labels: ['Value']
16
- });
17
- </script>
@@ -1,62 +0,0 @@
1
- require 'json'
2
- require_relative 'database'
3
- module Reviewlette
4
-
5
- class Graphgenerator
6
-
7
- def initialize
8
- @db = Reviewlette::Database.new
9
- end
10
-
11
- def write_to_graphs(filename, content)
12
- File.open(filename, 'w') { |file| file.write(content) }
13
- end
14
-
15
-
16
- def model_graphs(data2, data, type)
17
- @content = %Q|
18
- <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.5.1.css">
19
- <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
20
- <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
21
- <script src="http://cdn.oesmith.co.uk/morris-0.5.1.min.js"></script>
22
- <meta http-equiv="refresh" content="15" />
23
-
24
- <div id="Donut" style="height: 250px;"></div>
25
- <div id="Line" style="height: 250px;"></div>
26
- <div id="Bar" style="height: 250px;"></div>
27
-
28
- <script>
29
- new Morris.#{type}({
30
- element: 'Donut',
31
- data: #{data},
32
- xkey: 'label',
33
- colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
34
- ykeys: ['value'],
35
- labels: ['Value']
36
- });
37
- </script>
38
-
39
- <script>
40
- new Morris.Line({
41
- element: 'Line',
42
- data: #{data2},
43
- xkey: 'created_at',
44
- colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
45
- ykeys: #{@db.get_users_trello_entries},
46
- labels: #{@db.get_users_trello_entries}
47
- });
48
- </script>
49
-
50
- <script>
51
- new Morris.Bar({
52
- element: 'Bar',
53
- data: #{data},
54
- xkey: 'label',
55
- colors: ['#80BFFF', '#F0F0F0', '#0000FF', '#00FFFF', '#FF00FF', '#C0C0C0'],
56
- ykeys: ['value'],
57
- labels: ['Value']
58
- });
59
- </script>|
60
- end
61
- end
62
- end
@@ -1,27 +0,0 @@
1
-
2
- require 'net/smtp'
3
-
4
- module Supporter
5
- class Mailer
6
- def send_email(to,opts={})
7
- opts[:server] ||= 'localhost'
8
- opts[:from] ||= 'review@lette.com'
9
- opts[:from_alias] ||= 'Reviewlette'
10
- opts[:subject] ||= "Commanding Officer of the Week"
11
- opts[:body] ||= ""
12
-
13
- msg = <<END_OF_MESSAGE
14
- From: #{opts[:from_alias]} <#{opts[:from]}>
15
- To: <#{to}>
16
- Subject: #{opts[:subject]}
17
- #{opts[:body]}
18
- END_OF_MESSAGE
19
-
20
- Net::SMTP.start(opts[:server]) do |smtp|
21
- smtp.send_message msg, opts[:from], to
22
- end
23
- end
24
-
25
- end
26
- end
27
- ## make this more generic in order to use it either for COotW and PairProgramming sessions and reviews
File without changes
@@ -1,3 +0,0 @@
1
- module Reviewlette
2
- VERSION = '0.0.6'
3
- end
data/prophet.rb DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'prophet'
3
- system('bundle')
4
- system('rspec')
data/reviewlette.db DELETED
Binary file
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Reviewlette::Database do
4
-
5
-
6
- subject { Reviewlette::Database.new }
7
-
8
- describe '#count_reviews' do
9
-
10
- it 'counts the reviews done by a single user' do
11
- to_be_counted = [1,2,3,4]
12
- expect(subject.instance_variable_get(:@reviews)).to receive(:where).and_return to_be_counted
13
- expect(to_be_counted).to receive(:count).and_return to_be_counted.count
14
- subject.count_reviews(subject.reviewer.first.values[1])
15
- end
16
- end
17
-
18
- describe '#get_users_gh_entries' do
19
- it 'gets all github usernames in #Array' do
20
- expect(subject.reviewer).to receive(:map).and_return [['jschmid']]
21
- subject.get_users_gh_entries
22
- end
23
- end
24
-
25
- describe '#add_pr_to_db' do
26
-
27
- it 'writes the name of the pr to db' do
28
- expect(subject.reviews).to receive(:insert)
29
- expect(subject).to receive(:count_up).with(subject.reviewer.first.values[1])
30
- subject.add_pr_to_db('review_123', subject.reviewer.first.values[1])
31
- end
32
- end
33
-
34
- end