technicaldebt-techincaldebt 0.1.1
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.
- data/.gitignore +0 -0
- data/LICENSE +20 -0
- data/README.rdoc +18 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/debtify +11 -0
- data/bin/senddebt +7 -0
- data/lib/technical_debt.rb +137 -0
- data/spec/git_diffs.rb +15 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/technical_debt_spec.rb +253 -0
- data/techincaldebt.gemspec +57 -0
- metadata +81 -0
data/.gitignore
ADDED
File without changes
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jeremy Grant
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
= techincaldebt
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but
|
13
|
+
bump version in a commit by itself I can ignore when I pull)
|
14
|
+
* Send me a pull request. Bonus points for topic branches.
|
15
|
+
|
16
|
+
== Copyright
|
17
|
+
|
18
|
+
Copyright (c) 2009 Jeremy Grant. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "techincaldebt"
|
8
|
+
gem.summary = %Q{Gem to push details of technical debt to technicaldebt.us}
|
9
|
+
gem.description = %Q{Gem to push details of technical debt to technicaldebt.us}
|
10
|
+
gem.email = "technicaldebt@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/techincaldebt/technical_debt"
|
12
|
+
gem.authors = ["Chris Herring", "Jeremy Grant","Gareth Stokes","Carl Woodward"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION')
|
39
|
+
version = File.read('VERSION')
|
40
|
+
else
|
41
|
+
version = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "techincaldebt #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bin/debtify
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
+
|
4
|
+
require 'technical_debt'
|
5
|
+
|
6
|
+
if ARGV[0]
|
7
|
+
debt = TechnicalDebt.new(ARGV)
|
8
|
+
debt.debtify
|
9
|
+
else
|
10
|
+
puts "You need to pass a project deirectory to set up the push to technical Debt"
|
11
|
+
end
|
data/bin/senddebt
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support'
|
3
|
+
require 'timeout'
|
4
|
+
require 'net/http'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
class TechnicalDebt
|
8
|
+
|
9
|
+
def initialize(dir)
|
10
|
+
@project = dir
|
11
|
+
end
|
12
|
+
|
13
|
+
def project
|
14
|
+
@project
|
15
|
+
end
|
16
|
+
|
17
|
+
def git_version
|
18
|
+
`git --version`.gsub(/git version/, "").strip
|
19
|
+
end
|
20
|
+
|
21
|
+
def last_commit_sha
|
22
|
+
`git rev-parse head`.strip
|
23
|
+
end
|
24
|
+
|
25
|
+
def minimum_git_version?
|
26
|
+
git_version >= "1.6"
|
27
|
+
end
|
28
|
+
|
29
|
+
def last_commit
|
30
|
+
`git diff master~1 head`
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_git_token
|
34
|
+
`git config --global technicaldebt.token`.strip
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_token_exists?
|
38
|
+
!get_git_token.blank?
|
39
|
+
end
|
40
|
+
|
41
|
+
def split_commit
|
42
|
+
last_commit.split("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def regex_debt_matcher
|
46
|
+
/^\+\s*#\s*[dD][eE][bB][tT]\s+(.*)$*/
|
47
|
+
end
|
48
|
+
|
49
|
+
#DEBT
|
50
|
+
def committed_lines_only
|
51
|
+
split_commit.reject { |commited_line| !(commited_line =~ /^\+[^\+]/)}
|
52
|
+
end
|
53
|
+
|
54
|
+
def debt_lines_only
|
55
|
+
committed_lines_only.reject{ |committed_line| !(committed_line =~ regex_debt_matcher)}
|
56
|
+
end
|
57
|
+
|
58
|
+
def debt_lines_with_logged
|
59
|
+
if log_file_exists?
|
60
|
+
debt = debt_lines_only + read_logged_debt
|
61
|
+
File.delete(log_file)
|
62
|
+
else
|
63
|
+
debt = debt_lines_only
|
64
|
+
end
|
65
|
+
debt
|
66
|
+
end
|
67
|
+
|
68
|
+
def push_to_technical_debt
|
69
|
+
debt_lines_with_logged.each do |debt_line|
|
70
|
+
send_to_server(debt_line)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def check_connection
|
75
|
+
begin
|
76
|
+
status = Timeout::timeout(2){
|
77
|
+
Net::HTTP.get(URI.parse("http://google.com"))
|
78
|
+
return true
|
79
|
+
}
|
80
|
+
rescue Exception
|
81
|
+
return false
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def connection_exists?
|
86
|
+
check_connection ? true : false
|
87
|
+
end
|
88
|
+
|
89
|
+
#DEBT 1 hour Just a sanity check
|
90
|
+
def register_debt
|
91
|
+
if git_token_exists? && connection_exists?
|
92
|
+
push_to_technical_debt
|
93
|
+
else
|
94
|
+
log_debt
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
def log_debt
|
100
|
+
File.open(log_file, 'a') { |f| f.write(debt_lines_only.join(",") + ",")}
|
101
|
+
no_token_message unless git_token_exists?
|
102
|
+
end
|
103
|
+
|
104
|
+
def no_token_message
|
105
|
+
puts "You don't have a token for Technical Debt access. To install it get your token from the website and:\ngit config --global technicaldebt.token your_token_here\nVisit http://technicaldebt.r09.railsrumble.com/account to obtain your token\n"
|
106
|
+
end
|
107
|
+
|
108
|
+
def log_file_exists?
|
109
|
+
File.exists?("#{project}/.git/technical_debt")
|
110
|
+
end
|
111
|
+
|
112
|
+
def read_logged_debt
|
113
|
+
File.open(log_file,'r') { |f| f.read.split(",")}
|
114
|
+
end
|
115
|
+
|
116
|
+
def log_file
|
117
|
+
"#{project}/.git/technical_debt"
|
118
|
+
end
|
119
|
+
|
120
|
+
def send_to_server(debt)
|
121
|
+
Net::HTTP.post_form(URI.parse("http://techdebt.dev/transactions"), {:message => stripped_debt_line(debt), :sha => last_commit_sha, :git_token => get_git_token })
|
122
|
+
end
|
123
|
+
|
124
|
+
def stripped_debt_line(debt_line)
|
125
|
+
debt_line[regex_debt_matcher, 1]
|
126
|
+
end
|
127
|
+
|
128
|
+
def debtify
|
129
|
+
path = File.expand_path(project.to_s)
|
130
|
+
command = "#/bin/sh\ncd #{path} && senddebt ."
|
131
|
+
post_commit_file = "#{path}/.git/hooks/post-commit"
|
132
|
+
File.open(post_commit_file,'w'){ |f| f.write(command) }
|
133
|
+
File.chmod(0755, post_commit_file)
|
134
|
+
puts "Your project is now debtified."
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
data/spec/git_diffs.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module GitDiffs
|
2
|
+
|
3
|
+
def git_diff
|
4
|
+
"diff --git a/gem/techincal_debt/lib/techincal_debt.rb b/gem/techincal_debt/lib/techincal_debt.rb\nindex c8c56b2..04dd2e9 100644\n--- a/gem/techincal_debt/lib/techincal_debt.rb\n+++ b/gem/techincal_debt/lib/techincal_debt.rb\n@@ -7,4 +7,8 @@ class TechnicalDebt\n def minimum_git_version?\n git_version >= \"1.6\"\n end\n+ \n+ def last_commit\n+ `git diff`\n+ end\n end\n\\ndiff --git a/gem/techincal_debt/spec/spec_helper.rb b/gem/techincal_debt/spec/spec_helper.rb\nindex 50ed73c..cd7e0f6 100644\n--- a/gem/techincal_debt/spec/spec_helper.rb\n+++ b/gem/techincal_debt/spec/spec_helper.rb\n@@ -1,9 +1,9 @@\n $LOAD_PATH.unshift(File.dirname(__FILE__))\n $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))\n-require 'techincaldebt'\n+require 'techincal_debt'\n require 'spec'\n require 'spec/autorun'\n \n Spec::Runner.configure do |config|\n- \n+ include GitDiffs\n end\ndiff --git a/gem/techincal_debt/spec/techincal_debt_spec.rb b/gem/techincal_debt/spec/techincal_debt_spec.rb\nindex 13c4a63..d3cf868 100644\n--- a/gem/techincal_debt/spec/techincal_debt_spec.rb\n+++ b/gem/techincal_debt/spec/techincal_debt_spec.rb\n@@ -27,3 +27,22 @@ describe TechnicalDebt,\"minimum_git_version?\" do\n end\n \n end\n+\n+describe TechnicalDebt,\"last_commit\" do\n+ before do\n+ @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:project).and_return(`pwd`)\n+ end\n+ \n+ it \"should return the last commit for the project\" do\n+ @techdebt.last_commit.should include(\"diff --git\")\n+ end\n+ \n+end\n+\n+describe TechnicalDebt,\"split_commit\" do\n+ before do\n+ @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:last_commit).and_return()\n+ end\n+end\n\\n"
|
5
|
+
end
|
6
|
+
|
7
|
+
def git_diff_with_debt
|
8
|
+
"diff --git a/gem/techincal_debt/lib/techincal_debt.rb b/gem/techincal_debt/lib/techincal_debt.rb\nindex c8c56b2..04dd2e9 100644\n--- a/gem/techincal_debt/lib/techincal_debt.rb\n+++ b/gem/techincal_debt/lib/techincal_debt.rb\n@@ -7,4 +7,8 @@ class TechnicalDebt\n def minimum_git_version?\n git_version >= \"1.6\"\n end\n+ \n+ def last_commit\n+ `git diff`\n+ end\n end\n\\ndiff --git a/gem/techincal_debt/spec/spec_helper.rb b/gem/techincal_debt/spec/spec_helper.rb\nindex 50ed73c..cd7e0f6 100644\n--- a/gem/techincal_debt/spec/spec_helper.rb\n+++ b/gem/techincal_debt/spec/spec_helper.rb\n@@ -1,9 +1,9 @@\n $LOAD_PATH.unshift(File.dirname(__FILE__))\n $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))\n-require 'techincaldebt'\n+require 'techincal_debt'\n require 'spec'\n require 'spec/autorun'\n \n Spec::Runner.configure do |config|\n- \n+ include GitDiffs\n end\ndiff --git a/gem/techincal_debt/spec/techincal_debt_spec.rb b/gem/techincal_debt/spec/techincal_debt_spec.rb\nindex 13c4a63..d3cf868 100644\n--- a/gem/techincal_debt/spec/techincal_debt_spec.rb\n+++ b/gem/techincal_debt/spec/techincal_debt_spec.rb\n@@ -27,3 +27,22 @@ describe TechnicalDebt,\"minimum_git_version?\" do\n end\n \n end\n+\n+describe TechnicalDebt,\"last_commit\" do\n+ before do\n+ #DEBT @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:project).and_return(`pwd`)\n+ end\n+ \n+ it \"should return the last commit for the project\" do\n+ @techdebt.last_commit.should include(\"diff --git\")\n+ end\n+ \n+end\n+\n+describe TechnicalDebt,\"split_commit\" do\n+ before do\n+ @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:last_commit).and_return()\n+ end\n+end\n\\n"
|
9
|
+
end
|
10
|
+
|
11
|
+
def git_diff_with_debt_start_end
|
12
|
+
"diff --git a/gem/techincal_debt/lib/techincal_debt.rb b/gem/techincal_debt/lib/techincal_debt.rb\nindex c8c56b2..04dd2e9 100644\n--- a/gem/techincal_debt/lib/techincal_debt.rb\n+++ b/gem/techincal_debt/lib/techincal_debt.rb\n@@ -7,4 +7,8 @@ class TechnicalDebt\n def minimum_git_version?\n git_version >= \"1.6\"\n end\n+ \n+ def last_commit\n+ `git diff`\n+ end\n end\n\\ndiff --git a/gem/techincal_debt/spec/spec_helper.rb b/gem/techincal_debt/spec/spec_helper.rb\nindex 50ed73c..cd7e0f6 100644\n--- a/gem/techincal_debt/spec/spec_helper.rb\n+++ b/gem/techincal_debt/spec/spec_helper.rb\n@@ -1,9 +1,9 @@\n $LOAD_PATH.unshift(File.dirname(__FILE__))\n $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))\n-require 'techincaldebt'\n+require 'techincal_debt'\n require 'spec'\n require 'spec/autorun'\n \n Spec::Runner.configure do |config|\n- \n+ include GitDiffs\n end\ndiff --git a/gem/techincal_debt/spec/techincal_debt_spec.rb b/gem/techincal_debt/spec/techincal_debt_spec.rb\nindex 13c4a63..d3cf868 100644\n--- a/gem/techincal_debt/spec/techincal_debt_spec.rb\n+++ b/gem/techincal_debt/spec/techincal_debt_spec.rb\n@@ -27,3 +27,22 @@ describe TechnicalDebt,\"minimum_git_version?\" do\n end\n \n end\n+\n+describe TechnicalDebt,\"last_commit\" do\n+ before do\n+ #STARTDEBT @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:project).and_return(`pwd`)\n+ #ENDDEBT end\n+ \n+ it \"should return the last commit for the project\" do\n+ @techdebt.last_commit.should include(\"diff --git\")\n+ end\n+ \n+end\n+\n+describe TechnicalDebt,\"split_commit\" do\n+ before do\n+ @techdebt = TechnicalDebt.new\n+ @techdebt.stub!(:last_commit).and_return()\n+ end\n+end\n\\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'technical_debt'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
require 'git_diffs'
|
7
|
+
require 'active_support'
|
8
|
+
|
9
|
+
Spec::Runner.configure do |config|
|
10
|
+
include GitDiffs
|
11
|
+
end
|
@@ -0,0 +1,253 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe TechnicalDebt,"git_version" do
|
4
|
+
before do
|
5
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should check the git version if git exists" do
|
9
|
+
@techdebt.git_version.should_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe TechnicalDebt,"minimum_git_version?" do
|
15
|
+
before do
|
16
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return true for 1.6 or higher" do
|
20
|
+
@techdebt.stub!(:git_version).and_return("1.6.3.1")
|
21
|
+
@techdebt.should be_minimum_git_version
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return false for anything less than 1.6" do
|
25
|
+
@techdebt.stub!(:git_version).and_return("1.5.5.1")
|
26
|
+
@techdebt.should_not be_minimum_git_version
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
describe TechnicalDebt,"last_commit" do
|
32
|
+
before do
|
33
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
34
|
+
@techdebt.stub!(:project).and_return(`pwd`)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return the last commit for the project" do
|
38
|
+
@techdebt.last_commit.should include("diff --git")
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe TechnicalDebt,"split_commit" do
|
44
|
+
|
45
|
+
before do
|
46
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
47
|
+
@techdebt.stub!(:last_commit).and_return(git_diff)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should split the git diff into an array of lines" do
|
51
|
+
@techdebt.split_commit.should be_instance_of(Array)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should not be nil for the git diff array" do
|
55
|
+
@techdebt.split_commit.should_not be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe TechnicalDebt,"commited_lines_only" do
|
60
|
+
before do
|
61
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
62
|
+
@techdebt.stub!(:last_commit).and_return(git_diff)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should only keep lines that have one + at the start" do
|
66
|
+
@techdebt.committed_lines_only.each do |line|
|
67
|
+
line[0].should == 43
|
68
|
+
line[1].should_not == 43
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have lines in the commit" do
|
73
|
+
@techdebt.committed_lines_only.size.should > 0
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe TechnicalDebt,"debt_lines_only" do
|
79
|
+
before do
|
80
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should return 0 for a commit with no debt included in any lines" do
|
84
|
+
@techdebt.stub!(:last_commit).and_return(git_diff)
|
85
|
+
@techdebt.debt_lines_only.size.should == 0
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should return the number of lines for a commit with no debt included in any lines" do
|
89
|
+
@techdebt.stub!(:last_commit).and_return(git_diff_with_debt)
|
90
|
+
@techdebt.debt_lines_only.size.should == 1
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
describe TechnicalDebt do
|
96
|
+
before do
|
97
|
+
@argv = `pwd`
|
98
|
+
@techdebt = TechnicalDebt.new(@argv)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should make the project" do
|
102
|
+
@techdebt.project.should == @argv
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
describe TechnicalDebt,"push_to_technical_debt" do
|
108
|
+
before do
|
109
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
110
|
+
@techdebt.stub!(:last_commit).and_return(git_diff_with_debt)
|
111
|
+
@techdebt.stub!(:send_to_server).and_return(true)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "send information to technical debt" do
|
115
|
+
@techdebt.should_receive(:send_to_server).exactly(@techdebt.debt_lines_only.size).times
|
116
|
+
@techdebt.push_to_technical_debt
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
describe TechnicalDebt,"connection_exists?" do
|
122
|
+
before do
|
123
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should return true if we can get to the net" do
|
127
|
+
@techdebt.stub!(:check_connection).and_return(true)
|
128
|
+
@techdebt.should be_connection_exists
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
it "should return false if it times out" do
|
133
|
+
@techdebt.stub!(:check_connection).and_return(false)
|
134
|
+
@techdebt.should_not be_connection_exists
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
describe TechnicalDebt,"register_debt" do
|
140
|
+
before do
|
141
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should call push to technical debt if there is a connection and git_token_exists?" do
|
145
|
+
@techdebt.stub!(:check_connection).and_return(true)
|
146
|
+
@techdebt.stub!(:git_token_exists?).and_return(true)
|
147
|
+
@techdebt.should_receive(:push_to_technical_debt)
|
148
|
+
@techdebt.register_debt
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should log to a file if there is no connection" do
|
152
|
+
@techdebt.stub!(:check_connection).and_return(false)
|
153
|
+
@techdebt.stub!(:git_token_exists?).and_return(true)
|
154
|
+
@techdebt.should_receive(:log_debt)
|
155
|
+
@techdebt.register_debt
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should log to a file if there is no git_token" do
|
159
|
+
@techdebt.stub!(:check_connection).and_return(true)
|
160
|
+
@techdebt.stub!(:git_token_exists?).and_return(false)
|
161
|
+
@techdebt.should_receive(:log_debt)
|
162
|
+
@techdebt.register_debt
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
describe TechnicalDebt,"log_debt" do
|
168
|
+
before do
|
169
|
+
@arg = `pwd`
|
170
|
+
@techdebt = TechnicalDebt.new(@arg)
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should write to the existing file if it's here" do
|
174
|
+
File.stub!(:open)
|
175
|
+
File.should_receive(:open).with(@techdebt.log_file, 'a')
|
176
|
+
@techdebt.log_debt
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
describe TechnicalDebt,"log_file_exists?" do
|
182
|
+
before do
|
183
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should call File.exists?" do
|
187
|
+
File.should_receive(:exists?)
|
188
|
+
@techdebt.log_file_exists?
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe TechnicalDebt,"read existing data" do
|
193
|
+
before do
|
194
|
+
@arg = `pwd`
|
195
|
+
@techdebt = TechnicalDebt.new(@arg)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should read the file" do
|
199
|
+
File.should_receive(:open).with(@techdebt.log_file, 'r')
|
200
|
+
@techdebt.read_logged_debt
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
describe TechnicalDebt,"debt_lines_with_logged" do
|
206
|
+
before do
|
207
|
+
@arg = `pwd`
|
208
|
+
@techdebt = TechnicalDebt.new(@arg)
|
209
|
+
@techdebt.stub!(:log_file_exists?).and_return(true)
|
210
|
+
@techdebt.stub!(:read_logged_debt).and_return(["+ #DEBT"])
|
211
|
+
File.stub!(:delete)
|
212
|
+
end
|
213
|
+
|
214
|
+
it "should delete the file if it exists" do
|
215
|
+
File.should_receive(:delete)
|
216
|
+
@techdebt.debt_lines_with_logged
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
describe TechnicalDebt,"strip # DEBT from debt lines" do
|
222
|
+
before do
|
223
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
224
|
+
@techdebt.stub!(:last_commit).and_return(git_diff_with_debt)
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should not start with the word DEBT" do
|
228
|
+
@techdebt.stripped_debt_line(@techdebt.debt_lines_only.first).should_not include("+ #DEBT")
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
233
|
+
describe TechnicalDebt,"git_token_exists?" do
|
234
|
+
before do
|
235
|
+
@techdebt = TechnicalDebt.new(ARGV)
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should return true when the git_token is entered" do
|
239
|
+
@techdebt.stub!(:get_git_token).and_return("eba45741fb2bd08580328d6b991a9b6a")
|
240
|
+
@techdebt.should be_git_token_exists
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should return false when the git token is empty" do
|
244
|
+
@techdebt.stub!(:get_git_token).and_return("")
|
245
|
+
@techdebt.should_not be_git_token_exists
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should return false when the git token is nil" do
|
249
|
+
@techdebt.stub!(:get_git_token).and_return(nil)
|
250
|
+
@techdebt.should_not be_git_token_exists
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{techincaldebt}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Chris Herring", "Jeremy Grant", "Gareth Stokes", "Carl Woodward"]
|
12
|
+
s.date = %q{2009-08-24}
|
13
|
+
s.description = %q{Gem to push details of technical debt to technicaldebt.us}
|
14
|
+
s.email = %q{technicaldebt@gmail.com}
|
15
|
+
s.executables = ["debtify", "senddebt"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"bin/debtify",
|
27
|
+
"bin/senddebt",
|
28
|
+
"lib/technical_debt.rb",
|
29
|
+
"spec/git_diffs.rb",
|
30
|
+
"spec/spec_helper.rb",
|
31
|
+
"spec/technical_debt_spec.rb",
|
32
|
+
"techincaldebt.gemspec"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://github.com/techincaldebt/technical_debt}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.4}
|
38
|
+
s.summary = %q{Gem to push details of technical debt to technicaldebt.us}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/git_diffs.rb",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"spec/technical_debt_spec.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
51
|
+
else
|
52
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: technicaldebt-techincaldebt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Herring
|
8
|
+
- Jeremy Grant
|
9
|
+
- Gareth Stokes
|
10
|
+
- Carl Woodward
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2009-08-24 00:00:00 -07:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: rspec
|
20
|
+
type: :development
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: "0"
|
27
|
+
version:
|
28
|
+
description: Gem to push details of technical debt to technicaldebt.us
|
29
|
+
email: technicaldebt@gmail.com
|
30
|
+
executables:
|
31
|
+
- debtify
|
32
|
+
- senddebt
|
33
|
+
extensions: []
|
34
|
+
|
35
|
+
extra_rdoc_files:
|
36
|
+
- LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- LICENSE
|
41
|
+
- README.rdoc
|
42
|
+
- Rakefile
|
43
|
+
- VERSION
|
44
|
+
- bin/debtify
|
45
|
+
- bin/senddebt
|
46
|
+
- lib/technical_debt.rb
|
47
|
+
- spec/git_diffs.rb
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
- spec/technical_debt_spec.rb
|
50
|
+
- techincaldebt.gemspec
|
51
|
+
has_rdoc: false
|
52
|
+
homepage: http://github.com/techincaldebt/technical_debt
|
53
|
+
licenses:
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.5
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: Gem to push details of technical debt to technicaldebt.us
|
78
|
+
test_files:
|
79
|
+
- spec/git_diffs.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/technical_debt_spec.rb
|