tailor-hook 0.1.2 → 0.2.0
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/.rvmrc +1 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +11 -9
- data/Guardfile +8 -0
- data/README.rdoc +4 -2
- data/VERSION +1 -1
- data/lib/tailor-hook.rb +3 -0
- data/lib/tailor-hook/git_repo.rb +20 -0
- data/lib/tailor-hook/hook.rb +35 -0
- data/pre-commit +4 -41
- data/{test → spec}/helper.rb +7 -2
- data/spec/tailor-hook/git_repo_spec.rb +15 -0
- data/spec/tailor-hook/hook_spec.rb +9 -0
- data/tailor-hook.gemspec +19 -8
- metadata +44 -17
- data/test/test_tailor-hook.rb +0 -7
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.2-p180@tailor-hook
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source "http://rubygems.org"
|
|
3
3
|
# Example:
|
4
4
|
# gem "activesupport", ">= 2.3.5"
|
5
5
|
|
6
|
-
gem "tailor",
|
6
|
+
gem "tailor", "~> 0.1.5"
|
7
7
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
@@ -12,4 +12,6 @@ group :development do
|
|
12
12
|
gem "bundler", "~> 1.0.0"
|
13
13
|
gem "jeweler", "~> 1.6.4"
|
14
14
|
gem "rcov", ">= 0"
|
15
|
+
gem "rr"
|
16
|
+
gem "guard-minitest"
|
15
17
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/sergio-fry/tailor.git
|
3
|
-
revision: 7f737091752ed8581762a6586547428a52c9e622
|
4
|
-
specs:
|
5
|
-
tailor (0.1.3.1)
|
6
|
-
term-ansicolor (>= 1.0.5)
|
7
|
-
term-ansicolor (>= 1.0.5)
|
8
|
-
|
9
1
|
GEM
|
10
2
|
remote: http://rubygems.org/
|
11
3
|
specs:
|
12
4
|
git (1.2.5)
|
5
|
+
guard (0.7.0)
|
6
|
+
thor (~> 0.14.6)
|
7
|
+
guard-minitest (0.4.0)
|
8
|
+
guard (~> 0.4)
|
13
9
|
jeweler (1.6.4)
|
14
10
|
bundler (~> 1.0)
|
15
11
|
git (>= 1.2.5)
|
16
12
|
rake
|
17
13
|
rake (0.9.2)
|
18
14
|
rcov (0.9.10)
|
15
|
+
rr (1.0.4)
|
19
16
|
shoulda (2.11.3)
|
17
|
+
tailor (0.1.5)
|
18
|
+
term-ansicolor (>= 1.0.5)
|
20
19
|
term-ansicolor (1.0.6)
|
20
|
+
thor (0.14.6)
|
21
21
|
|
22
22
|
PLATFORMS
|
23
23
|
ruby
|
24
24
|
|
25
25
|
DEPENDENCIES
|
26
26
|
bundler (~> 1.0.0)
|
27
|
+
guard-minitest
|
27
28
|
jeweler (~> 1.6.4)
|
28
29
|
rcov
|
30
|
+
rr
|
29
31
|
shoulda
|
30
|
-
tailor
|
32
|
+
tailor (~> 0.1.5)
|
data/Guardfile
ADDED
data/README.rdoc
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
= tailor-hook
|
2
2
|
|
3
|
-
This gem creates git pre-commit hook
|
3
|
+
This gem creates git pre-commit hook to validate updated .rb files with Tailor gem.
|
4
|
+
|
5
|
+
TailorHook validates only staged files. Very handy. Just check it out!
|
4
6
|
|
5
7
|
== Installation
|
6
8
|
|
7
9
|
* Install "tailor-hook" gem
|
8
|
-
* Run "tailor-hook-install" command inside your project path to add hook.
|
10
|
+
* Run "tailor-hook-install" command inside your project path to add the hook.
|
9
11
|
|
10
12
|
== Contributing to tailor-hook
|
11
13
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/tailor-hook.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module TailorHook
|
2
|
+
class GitRepo
|
3
|
+
def initialize(path)
|
4
|
+
@path = File.expand_path path
|
5
|
+
end
|
6
|
+
|
7
|
+
def staged_ruby_files
|
8
|
+
staged_files.find_all { |f| f.match /\.rb$/ }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def staged_files
|
14
|
+
files = `cd #{@path} ; git diff --name-only --staged`.split
|
15
|
+
|
16
|
+
# filter deleted files
|
17
|
+
files.map { |p| File.expand_path(p) }.find_all { |p| File.exists? p }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module TailorHook
|
2
|
+
class Hook
|
3
|
+
def initialize(path)
|
4
|
+
@git_repo = GitRepo.new(path)
|
5
|
+
end
|
6
|
+
|
7
|
+
def hook!
|
8
|
+
@errors = []
|
9
|
+
|
10
|
+
@git_repo.staged_ruby_files.each do |path|
|
11
|
+
check_file(path)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
if @errors.empty?
|
16
|
+
result = 0
|
17
|
+
else
|
18
|
+
@errors.each { |e| print e }
|
19
|
+
result = 1
|
20
|
+
end
|
21
|
+
|
22
|
+
result
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def check_file(path)
|
28
|
+
output = `tailor #{path}`
|
29
|
+
|
30
|
+
unless $?.success?
|
31
|
+
@errors << output
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/pre-commit
CHANGED
@@ -1,44 +1,7 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
LAST_LINE = "The following files are out of style"
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@errors = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def hook!
|
11
|
-
ruby_files.each do |filename|
|
12
|
-
check_file(filename)
|
13
|
-
end
|
14
|
-
|
15
|
-
if @errors.empty?
|
16
|
-
exit 0
|
17
|
-
else
|
18
|
-
@errors.each { |e| print e }
|
19
|
-
exit 1
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def check_file(filename)
|
26
|
-
output = `tailor #{filename}`
|
27
|
-
|
28
|
-
unless output.split("\n")[-1].include? LAST_LINE
|
29
|
-
@errors << output
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def ruby_files
|
34
|
-
`git status -s`.split("\n").collect do |line|
|
35
|
-
filename = line.split[1]
|
36
|
-
filename if filename.match(/\.rb$/)
|
37
|
-
end.compact
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
hook = TailorHook.new
|
42
|
-
hook.hook!
|
3
|
+
require 'tailor-hook'
|
43
4
|
|
5
|
+
hook = TailorHook::Hook.new(File.join(File.dirname(__FILE__), "../.."))
|
6
|
+
exit hook.hook! # exit value
|
44
7
|
|
data/{test → spec}/helper.rb
RENAMED
@@ -7,12 +7,17 @@ rescue Bundler::BundlerError => e
|
|
7
7
|
$stderr.puts "Run `bundle install` to install missing gems"
|
8
8
|
exit e.status_code
|
9
9
|
end
|
10
|
-
require '
|
10
|
+
require 'minitest/spec'
|
11
|
+
require 'minitest/autorun'
|
11
12
|
require 'shoulda'
|
13
|
+
require 'rr'
|
12
14
|
|
13
15
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
16
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
17
|
require 'tailor-hook'
|
16
18
|
|
17
|
-
|
19
|
+
include TailorHook
|
20
|
+
|
21
|
+
class MiniTest::Unit::TestCase
|
22
|
+
include RR::Adapters::MiniTest
|
18
23
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe GitRepo do
|
4
|
+
before do
|
5
|
+
@parser = GitRepo.new(".")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should list staged ruby files" do
|
9
|
+
stub(@parser).staged_files { ["file.rb", "Gemfile"] }
|
10
|
+
@parser.staged_ruby_files.must_equal ["file.rb"]
|
11
|
+
|
12
|
+
stub(@parser).staged_files { ["file.rb", "Gemfile", "file_2.rb"] }
|
13
|
+
@parser.staged_ruby_files.sort.must_equal ["file.rb", "file_2.rb"]
|
14
|
+
end
|
15
|
+
end
|
data/tailor-hook.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "tailor-hook"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sergei O. Udalov"]
|
12
|
-
s.date = "2011-09-
|
12
|
+
s.date = "2011-09-29"
|
13
13
|
s.description = "pre-commit hook, that checks ruby-style"
|
14
14
|
s.email = "sergei.udalov@gmail.com"
|
15
15
|
s.executables = ["tailor-hook-install"]
|
@@ -19,18 +19,23 @@ Gem::Specification.new do |s|
|
|
19
19
|
]
|
20
20
|
s.files = [
|
21
21
|
".document",
|
22
|
+
".rvmrc",
|
22
23
|
"Gemfile",
|
23
24
|
"Gemfile.lock",
|
25
|
+
"Guardfile",
|
24
26
|
"LICENSE.txt",
|
25
27
|
"README.rdoc",
|
26
28
|
"Rakefile",
|
27
29
|
"VERSION",
|
28
30
|
"bin/tailor-hook-install",
|
29
31
|
"lib/tailor-hook.rb",
|
32
|
+
"lib/tailor-hook/git_repo.rb",
|
33
|
+
"lib/tailor-hook/hook.rb",
|
30
34
|
"pre-commit",
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"
|
35
|
+
"spec/helper.rb",
|
36
|
+
"spec/tailor-hook/git_repo_spec.rb",
|
37
|
+
"spec/tailor-hook/hook_spec.rb",
|
38
|
+
"tailor-hook.gemspec"
|
34
39
|
]
|
35
40
|
s.homepage = "http://github.com/sergio-fry/tailor-hook"
|
36
41
|
s.licenses = ["MIT"]
|
@@ -42,24 +47,30 @@ Gem::Specification.new do |s|
|
|
42
47
|
s.specification_version = 3
|
43
48
|
|
44
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
-
s.add_runtime_dependency(%q<tailor>, ["
|
50
|
+
s.add_runtime_dependency(%q<tailor>, ["~> 0.1.5"])
|
46
51
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
47
52
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
48
53
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
49
54
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<rr>, [">= 0"])
|
56
|
+
s.add_development_dependency(%q<guard-minitest>, [">= 0"])
|
50
57
|
else
|
51
|
-
s.add_dependency(%q<tailor>, ["
|
58
|
+
s.add_dependency(%q<tailor>, ["~> 0.1.5"])
|
52
59
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
53
60
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
61
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
55
62
|
s.add_dependency(%q<rcov>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
64
|
+
s.add_dependency(%q<guard-minitest>, [">= 0"])
|
56
65
|
end
|
57
66
|
else
|
58
|
-
s.add_dependency(%q<tailor>, ["
|
67
|
+
s.add_dependency(%q<tailor>, ["~> 0.1.5"])
|
59
68
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
60
69
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
61
70
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
62
71
|
s.add_dependency(%q<rcov>, [">= 0"])
|
72
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
73
|
+
s.add_dependency(%q<guard-minitest>, [">= 0"])
|
63
74
|
end
|
64
75
|
end
|
65
76
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailor-hook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-29 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: tailor
|
16
|
-
requirement: &
|
16
|
+
requirement: &84635070 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.1.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *84635070
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &84634830 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *84634830
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &84634590 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *84634590
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &84634350 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,32 @@ dependencies:
|
|
54
54
|
version: 1.6.4
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *84634350
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rcov
|
60
|
-
requirement: &
|
60
|
+
requirement: &84634110 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *84634110
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rr
|
71
|
+
requirement: &84633870 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *84633870
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: guard-minitest
|
82
|
+
requirement: &84633630 !ruby/object:Gem::Requirement
|
61
83
|
none: false
|
62
84
|
requirements:
|
63
85
|
- - ! '>='
|
@@ -65,7 +87,7 @@ dependencies:
|
|
65
87
|
version: '0'
|
66
88
|
type: :development
|
67
89
|
prerelease: false
|
68
|
-
version_requirements: *
|
90
|
+
version_requirements: *84633630
|
69
91
|
description: pre-commit hook, that checks ruby-style
|
70
92
|
email: sergei.udalov@gmail.com
|
71
93
|
executables:
|
@@ -76,18 +98,23 @@ extra_rdoc_files:
|
|
76
98
|
- README.rdoc
|
77
99
|
files:
|
78
100
|
- .document
|
101
|
+
- .rvmrc
|
79
102
|
- Gemfile
|
80
103
|
- Gemfile.lock
|
104
|
+
- Guardfile
|
81
105
|
- LICENSE.txt
|
82
106
|
- README.rdoc
|
83
107
|
- Rakefile
|
84
108
|
- VERSION
|
85
109
|
- bin/tailor-hook-install
|
86
110
|
- lib/tailor-hook.rb
|
111
|
+
- lib/tailor-hook/git_repo.rb
|
112
|
+
- lib/tailor-hook/hook.rb
|
87
113
|
- pre-commit
|
114
|
+
- spec/helper.rb
|
115
|
+
- spec/tailor-hook/git_repo_spec.rb
|
116
|
+
- spec/tailor-hook/hook_spec.rb
|
88
117
|
- tailor-hook.gemspec
|
89
|
-
- test/helper.rb
|
90
|
-
- test/test_tailor-hook.rb
|
91
118
|
homepage: http://github.com/sergio-fry/tailor-hook
|
92
119
|
licenses:
|
93
120
|
- MIT
|
@@ -103,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
103
130
|
version: '0'
|
104
131
|
segments:
|
105
132
|
- 0
|
106
|
-
hash: -
|
133
|
+
hash: -412855309
|
107
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
135
|
none: false
|
109
136
|
requirements:
|