alloy-kicker 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ html/*.html
7
+ html/*.rid
8
+ html/*.css
9
+ html/classes
10
+ html/files
data/TODO.rdoc CHANGED
@@ -1,14 +1,7 @@
1
1
  == For v2
2
2
 
3
- * Create 3 callback chains
4
- * pre-process: for instance Exclude
5
- * process: normal callbacks
6
- * post-process: for instance the default 'could not handle' callback
7
-
8
3
  * Add -r option to require recipe files that come bundled with Kicker
9
4
 
10
- * Probably easier to let the user mutate the files array instead of having to return an array.
11
-
12
5
  * Might be best to create an array of Pathname's instead of simply file path strings.
13
6
  Probably a subclass of Pathname with some Kicker specific helpers. (relative_path)
14
7
 
@@ -25,20 +18,20 @@
25
18
  def relative_path(path)
26
19
  path[(Dir.pwd.length + 1)..-1]
27
20
  end
28
-
21
+
29
22
  # Regular Rails mappings
30
- Kicker.callback = lambda do |kicker, files|
23
+ Kicker.process_callback = lambda do |kicker, files|
31
24
  test_files = []
32
-
25
+
33
26
  files.delete_if do |file|
34
27
  # Match any ruby test file and run it
35
28
  if relative_path(file) =~ /^test\/.+_test\.rb$/
36
29
  test_files << relative_path(file)
37
-
30
+
38
31
  # Match any file in app/ and map it to a test file
39
32
  elsif match = relative_path(file).match(%r{^app/(\w+)([\w/]*)/([\w\.]+)\.\w+$})
40
33
  type, namespace, file = match[1..3]
41
-
34
+
42
35
  dir = case type
43
36
  when "models"
44
37
  "unit"
@@ -47,32 +40,58 @@
47
40
  when "controllers", "views"
48
41
  "functional"
49
42
  end
50
-
43
+
51
44
  if dir
52
45
  if type == "views"
53
46
  namespace = namespace.split('/')[1..-1]
54
47
  file = "#{namespace.pop}_controller"
55
48
  end
56
-
49
+
57
50
  test_files << File.join("test", dir, namespace, "#{file}_test.rb")
58
51
  end
59
52
  end
60
53
  end
61
-
54
+
62
55
  kicker.execute_command "ruby -r #{test_files.join(' -r ')} -e ''" unless test_files.empty?
63
- files
64
56
  end
65
57
 
66
58
  # Match javascript changes and run with HeadlessSquirrel
67
- Kicker.callback = lambda do |kicker, files|
59
+ Kicker.process_callback = lambda do |kicker, files|
68
60
  test_files = []
69
-
61
+
70
62
  files.delete_if do |file|
71
63
  if relative_path(file) =~ %r{^test/javascripts/(\w+_test)\.(js|html)$}
72
64
  test_files << "test/javascripts/#{$1}.html"
73
65
  end
74
66
  end
75
-
67
+
76
68
  kicker.execute_command "jstest #{test_files.join(' ')}" unless test_files.empty?
77
- files
78
- end
69
+ end
70
+
71
+ # Exclude files
72
+ class Kicker
73
+ module Recipes
74
+ module Exclude
75
+ class << self
76
+ def exclusions
77
+ @exclusions ||= []
78
+ end
79
+
80
+ def exclude(regexp_or_string)
81
+ exclusions << Regexp.new(regexp_or_string)
82
+ end
83
+
84
+ def call(_, files)
85
+ files.reject! { |f| exclusions.any? { |exclusion| f =~ exclusion } }
86
+ end
87
+ end
88
+
89
+ Kicker.pre_process_callback = self
90
+ end
91
+ end
92
+ end
93
+
94
+ Kicker::Recipes::Exclude.exclude(/\w+\.log/)
95
+ Kicker::Recipes::Exclude.exclude(/\.svn/)
96
+
97
+ Kicker::Recipes::Exclude.exclude(File.expand_path('../tmp', __FILE__))
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 9
4
- :patch: 1
4
+ :patch: 2
data/bin/kicker CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $:.unshift File.expand_path('../../lib', __FILE__) if $0 == __FILE__
2
3
 
3
- require File.expand_path('../../lib/kicker', __FILE__)
4
- Kicker.run
4
+ require 'kicker'
5
+ Kicker.run
Binary file
data/kicker.gemspec ADDED
@@ -0,0 +1,84 @@
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{kicker}
8
+ s.version = "1.9.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Eloy Duran"]
12
+ s.date = %q{2009-08-27}
13
+ s.email = %q{eloy.de.enige@gmail.com}
14
+ s.executables = ["kicker", "kicker"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "TODO.rdoc",
25
+ "VERSION.yml",
26
+ "bin/kicker",
27
+ "html/images/kikker.jpg",
28
+ "kicker.gemspec",
29
+ "lib/kicker.rb",
30
+ "lib/kicker/callback_chain.rb",
31
+ "lib/kicker/growl.rb",
32
+ "lib/kicker/options.rb",
33
+ "lib/kicker/recipes/base.rb",
34
+ "lib/kicker/recipes/could_not_handle_file.rb",
35
+ "lib/kicker/recipes/execute_cli_command.rb",
36
+ "lib/kicker/recipes/rails.rb",
37
+ "lib/kicker/utils.rb",
38
+ "lib/kicker/validate.rb",
39
+ "test/callback_chain_test.rb",
40
+ "test/filesystem_change_test.rb",
41
+ "test/initialization_test.rb",
42
+ "test/options_test.rb",
43
+ "test/recipes/base_test.rb",
44
+ "test/recipes/could_not_handle_file_test.rb",
45
+ "test/recipes/execute_cli_command_test.rb",
46
+ "test/recipes/rails_test.rb",
47
+ "test/test_helper.rb",
48
+ "test/utils_test.rb",
49
+ "vendor/growlnotifier/growl.rb",
50
+ "vendor/growlnotifier/growl.rb",
51
+ "vendor/growlnotifier/growl_helpers.rb",
52
+ "vendor/growlnotifier/growl_helpers.rb",
53
+ "vendor/rucola/fsevents.rb",
54
+ "vendor/rucola/fsevents.rb"
55
+ ]
56
+ s.has_rdoc = true
57
+ s.homepage = %q{http://github.com/alloy/kicker}
58
+ s.rdoc_options = ["--charset=UTF-8"]
59
+ s.require_paths = ["lib", "vendor"]
60
+ s.rubygems_version = %q{1.3.2}
61
+ s.summary = %q{A simple OS X CLI tool which uses FSEvents to run a given shell command.}
62
+ s.test_files = [
63
+ "test/callback_chain_test.rb",
64
+ "test/filesystem_change_test.rb",
65
+ "test/initialization_test.rb",
66
+ "test/options_test.rb",
67
+ "test/recipes/base_test.rb",
68
+ "test/recipes/could_not_handle_file_test.rb",
69
+ "test/recipes/execute_cli_command_test.rb",
70
+ "test/recipes/rails_test.rb",
71
+ "test/test_helper.rb",
72
+ "test/utils_test.rb"
73
+ ]
74
+
75
+ if s.respond_to? :specification_version then
76
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
77
+ s.specification_version = 3
78
+
79
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
80
+ else
81
+ end
82
+ else
83
+ end
84
+ end
@@ -0,0 +1,26 @@
1
+ class Kicker
2
+ module Recipes
3
+ class Base
4
+ class NotImplementedError < StandardError; end
5
+
6
+ def self.call(kicker, files)
7
+ new(kicker, files).handle!
8
+ end
9
+
10
+ attr_reader :kicker, :files
11
+
12
+ def initialize(kicker, files)
13
+ @kicker, @files = kicker, files
14
+ after_initialize if respond_to?(:after_initialize)
15
+ end
16
+
17
+ def handle!
18
+ raise NotImplementedError, 'The subclass should implement this method to handle the changed files.'
19
+ end
20
+
21
+ def relative_path(path)
22
+ path[(Dir.pwd.length + 1)..-1]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,6 @@
1
1
  Kicker.option_parser.on('-e', '--execute [COMMAND]', 'The command to execute.') do |command|
2
- Kicker.process_callback = lambda do |kicker, _|
2
+ Kicker.pre_process_callback = lambda do |kicker, files|
3
+ files.clear
3
4
  kicker.execute_command "sh -c #{command.inspect}"
4
5
  end
5
- end
6
+ end
@@ -0,0 +1,28 @@
1
+ class Kicker
2
+ module Recipes
3
+ class Rails < Base
4
+ attr_reader :test_files
5
+
6
+ def after_initialize
7
+ @test_files = []
8
+ end
9
+
10
+ def handle!
11
+ @files.delete_if do |full_path|
12
+ path = relative_path(full_path)
13
+
14
+ # Match any ruby test file and run it
15
+ if path =~ /^test\/.+_test\.rb$/
16
+ @test_files << path
17
+ end
18
+ end
19
+
20
+ run_tests
21
+ end
22
+
23
+ def run_tests
24
+ @kicker.execute_command("ruby -r #{@test_files.join(' -r ')} -e ''")
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require 'kicker/recipes/base'
3
+
4
+ describe "The Kicker::Recipes::Base class, when being called" do
5
+ it "should instantiate a new instance and call the #handle! method" do
6
+ kicker = Kicker.new({})
7
+ files = %w{}
8
+ instance = mock('Kicker::Recipes::Rails')
9
+
10
+ Kicker::Recipes::Base.expects(:new).with(kicker, files).returns(instance)
11
+ instance.expects(:handle!)
12
+
13
+ Kicker::Recipes::Base.call(kicker, files)
14
+ end
15
+ end
16
+
17
+ describe "An instance of Kicker::Recipes::Base" do
18
+ before do
19
+ @kicker = Kicker.new({})
20
+ @files = %w{}
21
+ end
22
+
23
+ it "should assign the kicker instance and files array" do
24
+ instance = Kicker::Recipes::Base.new(@kicker, @files)
25
+ instance.kicker.should.be @kicker
26
+ instance.files.should.be @files
27
+ end
28
+
29
+ it "should call the #after_initialize method when done initializing if it exists" do
30
+ lambda { Kicker::Recipes::Base.new(@kicker, @files) }.should.not.raise
31
+
32
+ Kicker::Recipes::Base.any_instance.expects(:after_initialize)
33
+ Kicker::Recipes::Base.new(@kicker, @files)
34
+ end
35
+
36
+ it "should raise a Kicker::Recipes::Base::NotImplementedError if the subclass doesn't implement #handle!" do
37
+ lambda {
38
+ Kicker::Recipes::Base.new(@kicker, @files).handle!
39
+ }.should.raise Kicker::Recipes::Base::NotImplementedError
40
+ end
41
+
42
+ it "should return a relative representation of a given path, relative to the working dir" do
43
+ path = 'lib/foo.rb'
44
+ instance = Kicker::Recipes::Base.new(@kicker, @files)
45
+ instance.relative_path(File.expand_path(path)).should == path
46
+ end
47
+ end
@@ -2,19 +2,19 @@ require File.expand_path('../../test_helper', __FILE__)
2
2
 
3
3
  describe "Kicker, concerning the `execute a command-line' callback" do
4
4
  it "should parse the command and add the callback" do
5
- before = Kicker.process_chain.length
5
+ before = Kicker.pre_process_chain.length
6
6
 
7
7
  Kicker.parse_options(%w{ -e ls })
8
- Kicker.process_chain.length.should == before + 1
8
+ Kicker.pre_process_chain.length.should == before + 1
9
9
 
10
10
  Kicker.parse_options(%w{ --execute ls })
11
- Kicker.process_chain.length.should == before + 2
11
+ Kicker.pre_process_chain.length.should == before + 2
12
12
  end
13
13
 
14
14
  it "should call execute_command with the given command" do
15
15
  Kicker.parse_options(%w{ -e ls })
16
16
 
17
- callback = Kicker.process_chain.last
17
+ callback = Kicker.pre_process_chain.last
18
18
  callback.should.be.instance_of Proc
19
19
 
20
20
  kicker = Kicker.new({})
@@ -22,4 +22,10 @@ describe "Kicker, concerning the `execute a command-line' callback" do
22
22
 
23
23
  callback.call(kicker, %w{ /file/1 /file/2 }).should.not.be.instance_of Array
24
24
  end
25
- end
25
+
26
+ it "should clear the files array to halt the chain" do
27
+ files = %w{ /file/1 /file/2 }
28
+ Kicker.pre_process_chain.last.call(stub(:execute_command), files)
29
+ files.should.be.empty
30
+ end
31
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+ require 'kicker/recipes/rails'
3
+
4
+ describe "The Kicker::Recipes::Rails handler" do
5
+ before do
6
+ @kicker = Kicker.new({})
7
+ @kicker.stubs(:execute_command)
8
+
9
+ @handler = Kicker::Recipes::Rails.new(@kicker, [])
10
+ end
11
+
12
+ it "should instantiate a new instance and call the #handle! method when called" do
13
+ files = %w{}
14
+ instance = mock('Kicker::Recipes::Rails')
15
+ instance.expects(:handle!)
16
+
17
+ Kicker::Recipes::Rails.expects(:new).with(@kicker, files).returns(instance)
18
+ Kicker::Recipes::Rails.call(@kicker, files)
19
+ end
20
+
21
+ it "should match, extract, and run any test case files that have changed" do
22
+ lib_file = File.expand_path('lib/foo.rb')
23
+ @handler.files << lib_file
24
+ @handler.files << File.expand_path('test/1_test.rb')
25
+ @handler.files << File.expand_path('test/namespace/2_test.rb')
26
+
27
+ @kicker.expects(:execute_command).with("ruby -r test/1_test.rb -r test/namespace/2_test.rb -e ''")
28
+ @handler.handle!
29
+
30
+ @handler.test_files.should == %w{ test/1_test.rb test/namespace/2_test.rb }
31
+ @handler.files.should == [lib_file]
32
+ end
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alloy-kicker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-27 00:00:00 -07:00
12
+ date: 2009-08-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -24,26 +24,33 @@ extra_rdoc_files:
24
24
  - LICENSE
25
25
  - README.rdoc
26
26
  files:
27
+ - .gitignore
27
28
  - LICENSE
28
29
  - README.rdoc
29
30
  - Rakefile
30
31
  - TODO.rdoc
31
32
  - VERSION.yml
32
33
  - bin/kicker
34
+ - html/images/kikker.jpg
35
+ - kicker.gemspec
33
36
  - lib/kicker.rb
34
37
  - lib/kicker/callback_chain.rb
35
38
  - lib/kicker/growl.rb
36
39
  - lib/kicker/options.rb
40
+ - lib/kicker/recipes/base.rb
37
41
  - lib/kicker/recipes/could_not_handle_file.rb
38
42
  - lib/kicker/recipes/execute_cli_command.rb
43
+ - lib/kicker/recipes/rails.rb
39
44
  - lib/kicker/utils.rb
40
45
  - lib/kicker/validate.rb
41
46
  - test/callback_chain_test.rb
42
47
  - test/filesystem_change_test.rb
43
48
  - test/initialization_test.rb
44
49
  - test/options_test.rb
50
+ - test/recipes/base_test.rb
45
51
  - test/recipes/could_not_handle_file_test.rb
46
52
  - test/recipes/execute_cli_command_test.rb
53
+ - test/recipes/rails_test.rb
47
54
  - test/test_helper.rb
48
55
  - test/utils_test.rb
49
56
  - vendor/growlnotifier/growl.rb
@@ -51,6 +58,7 @@ files:
51
58
  - vendor/rucola/fsevents.rb
52
59
  has_rdoc: true
53
60
  homepage: http://github.com/alloy/kicker
61
+ licenses:
54
62
  post_install_message:
55
63
  rdoc_options:
56
64
  - --charset=UTF-8
@@ -72,16 +80,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
80
  requirements: []
73
81
 
74
82
  rubyforge_project:
75
- rubygems_version: 1.2.0
83
+ rubygems_version: 1.3.5
76
84
  signing_key:
77
- specification_version: 2
85
+ specification_version: 3
78
86
  summary: A simple OS X CLI tool which uses FSEvents to run a given shell command.
79
87
  test_files:
80
88
  - test/callback_chain_test.rb
81
89
  - test/filesystem_change_test.rb
82
90
  - test/initialization_test.rb
83
91
  - test/options_test.rb
92
+ - test/recipes/base_test.rb
84
93
  - test/recipes/could_not_handle_file_test.rb
85
94
  - test/recipes/execute_cli_command_test.rb
95
+ - test/recipes/rails_test.rb
86
96
  - test/test_helper.rb
87
97
  - test/utils_test.rb