watchful 0.0.0.pre1 → 0.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.
@@ -1,51 +0,0 @@
1
-
2
- # The name MyConfig should be accessible from the command line, e.g.
3
- #
4
- # watchful MyConfiguration
5
- #
6
- # By default (without a named config) watchful should use:
7
- #
8
- # 1) The configuration found in Watchful.rb, which should search PATH
9
- # for known tools
10
- #
11
- # or failing that
12
- #
13
- # 2) The default configuration in the gem
14
- #
15
-
16
- class MyConfiguration < Watchful::Configuration
17
-
18
- # hash style action description
19
-
20
- action :name => 'CSS Minifier' # for messages
21
- :in => ".css",
22
- :out => ".min.css",
23
- :command => "minify $IN $OUT",
24
- :dependencies => ['minify']
25
-
26
- # block style action description
27
-
28
- action 'CSS Minifier' do |a|
29
-
30
- # file matchers should also support blocks
31
-
32
- a.filter do |path|
33
- true if /.+\.css/ =~ path
34
- end
35
-
36
- # or regexps
37
-
38
- a.in = /.+\.css/
39
-
40
- # without $IN assume standard input
41
-
42
- a.command = 'minify -o $OUT' # => "cat $IN | minify -o $OUT"
43
-
44
- a.command = 'minify' # => "cat $IN | minify > $OUT"
45
- # => a.dependencies << 'minify'
46
-
47
- a.dependencies = ['minify']
48
-
49
- end
50
-
51
- end
data/test/action_test.rb DELETED
@@ -1,159 +0,0 @@
1
- require 'test_helper'
2
-
3
- class WatchfulTest < Test::Unit::TestCase
4
-
5
- context 'Action class' do
6
-
7
- should 'throw an exception with incomplete constructor parameters' do
8
- begin
9
- Watchful::Action.new(:name => 'Incomplete Action')
10
- flunk
11
- rescue Exception
12
- assert true
13
- end
14
- end
15
-
16
- should 'properly construct with a complete set of options' do
17
- a = Watchful::Action.new(
18
- :name => 'Test Action',
19
- :dependencies => ['cat'], :command => 'cat %s %s',
20
- :in => '.txt', :out => '.copy'
21
- )
22
- assert a.instance_of? Watchful::Action
23
- assert_equal a.name, 'Test Action'
24
- end
25
-
26
- should 'throw an exception when a non-string, non-array value is passed as dependencies' do
27
- begin
28
- a = Watchful::Action.new(
29
- :name => 'Test Action',
30
- :dependencies => Date.new, :command => 'cat %s %s',
31
- :in => '.txt', :out => '.copy'
32
- )
33
- flunk
34
- rescue Exception
35
- assert true
36
- end
37
- end
38
-
39
- context 'output_path_for' do
40
-
41
- setup do
42
- a = Watchful::Action.new(
43
- :name => 'Test Action',
44
- :dependencies => ['cat'], :command => 'cat %s %s',
45
- :in => '.txt', :out => '.copy'
46
- )
47
- end
48
-
49
- should 'produce correct path' do
50
- a = Watchful::Action.new(
51
- :name => 'Test Action',
52
- :dependencies => ['cat'], :command => 'cat %s %s',
53
- :in => '.txt', :out => '.copy'
54
- )
55
- assert_equal a.output_path_for('/tmp/test.txt'), '/tmp/test.copy'
56
- end
57
-
58
- should 'produce correct path with complex extensions' do
59
- a = Watchful::Action.new(
60
- :name => 'Test Action',
61
- :dependencies => ['cat'], :command => 'cat %s %s',
62
- :in => '.max.txt', :out => '.min.copy'
63
- )
64
- assert_equal a.output_path_for('/tmp/test.max.txt'), '/tmp/test.min.copy'
65
- end
66
-
67
- should 'produce correct with blank output extension' do
68
- a = Watchful::Action.new(
69
- :name => 'Test Action',
70
- :dependencies => ['cat'], :command => 'cat %s %s',
71
- :in => '', :out => '.copy'
72
- )
73
- assert_equal a.output_path_for('/tmp/test.txt'), '/tmp/test.txt.copy'
74
- end
75
-
76
- should 'produce correct with blank source extension' do
77
- a = Watchful::Action.new(
78
- :name => 'Test Action',
79
- :dependencies => ['cat'], :command => 'cat %s %s',
80
- :in => '.txt', :out => ''
81
- )
82
- assert_equal a.output_path_for('/tmp/test.txt'), '/tmp/test'
83
- end
84
-
85
- should 'produce correct with blank extensions' do
86
- a = Watchful::Action.new(
87
- :name => 'Test Action',
88
- :dependencies => ['cat'], :command => 'cat %s %s',
89
- :in => '', :out => ''
90
- )
91
- assert_equal a.output_path_for('/tmp/test'), '/tmp/test'
92
- end
93
-
94
- end
95
-
96
- context 'dependencies' do
97
-
98
- context 'have_command?' do
99
-
100
- should 'raise an exception for an empty string' do
101
- begin
102
- Watchful::Action.have_command?('')
103
- flunk
104
- rescue Exception
105
- assert true
106
- end
107
- end
108
-
109
- should 'raise an exception for a non-string argument' do
110
- begin
111
- Watchful::Action.have_command?(nil)
112
- flunk
113
- rescue Exception
114
- assert true
115
- end
116
- end
117
-
118
- should 'return false for missing commands' do
119
- assert_equal Watchful::Action.have_command?('Y0CbR4CEP2XY'), false
120
- end
121
-
122
- should 'return true for available commands' do
123
- assert_equal Watchful::Action.have_command?('cat'), true
124
- end
125
-
126
- end
127
-
128
- should 'confirm valid dependencies' do
129
- a = Watchful::Action.new(
130
- :name => 'Test Action',
131
- :dependencies => ['cat', 'echo'], :command => 'cat %s %s',
132
- :in => '.txt', :out => '.copy'
133
- )
134
- assert_equal a.has_dependencies?, true
135
- end
136
-
137
- should 'detect a missing binary dependency' do
138
- a = Watchful::Action.new(
139
- :name => 'Test Action',
140
- :dependencies => ['Y0CbR4CEP2XY'], :command => 'Y0CbR4CEP2XY %s %s',
141
- :in => '.txt', :out => '.copy'
142
- )
143
- assert_equal a.has_dependencies?, false
144
- end
145
-
146
- should 'confirm availability of no dependencies' do
147
- a = Watchful::Action.new(
148
- :name => 'Test Action',
149
- :dependencies => nil, :command => '',
150
- :in => '.txt', :out => '.copy'
151
- )
152
- assert_equal a.has_dependencies?, true
153
- end
154
-
155
- end
156
-
157
- end
158
-
159
- end
@@ -1,80 +0,0 @@
1
- require 'test_helper'
2
-
3
- require "watchful/configuration"
4
-
5
- class FirstTestConfiguration < Watchful::Configuration
6
-
7
- action :name => 'Placeholder Action'
8
-
9
- end
10
-
11
- puts "FirstTestConfiguration is a Configuration?".kind_of? Watchful::Configuration
12
-
13
- class WatchfulTest < Test::Unit::TestCase
14
-
15
- context 'Configuration class' do
16
-
17
- context 'dependencies' do
18
-
19
- context 'have_command?' do
20
-
21
- should 'raise an exception for an empty string' do
22
- begin
23
- Watchful::Action.have_command?('')
24
- flunk
25
- rescue Exception
26
- assert true
27
- end
28
- end
29
-
30
- should 'raise an exception for a non-string argument' do
31
- begin
32
- Watchful::Action.have_command?(nil)
33
- flunk
34
- rescue Exception
35
- assert true
36
- end
37
- end
38
-
39
- should 'return false for missing commands' do
40
- assert_equal Watchful::Action.have_command?('Y0CbR4CEP2XY'), false
41
- end
42
-
43
- should 'return true for available commands' do
44
- assert_equal Watchful::Action.have_command?('cat'), true
45
- end
46
-
47
- end
48
-
49
- should 'confirm valid dependencies' do
50
- a = Watchful::Action.new(
51
- :name => 'Test Action',
52
- :dependencies => ['cat', 'echo'], :command => 'cat %s %s',
53
- :in => '.txt', :out => '.copy'
54
- )
55
- assert_equal a.has_dependencies?, true
56
- end
57
-
58
- should 'detect a missing binary dependency' do
59
- a = Watchful::Action.new(
60
- :name => 'Test Action',
61
- :dependencies => ['Y0CbR4CEP2XY'], :command => 'Y0CbR4CEP2XY %s %s',
62
- :in => '.txt', :out => '.copy'
63
- )
64
- assert_equal a.has_dependencies?, false
65
- end
66
-
67
- should 'confirm availability of no dependencies' do
68
- a = Watchful::Action.new(
69
- :name => 'Test Action',
70
- :dependencies => nil, :command => '',
71
- :in => '.txt', :out => '.copy'
72
- )
73
- assert_equal a.has_dependencies?, true
74
- end
75
-
76
- end
77
-
78
- end
79
-
80
- end
@@ -1,20 +0,0 @@
1
- require 'test_helper'
2
- require 'fileutils'
3
-
4
- class WatchfulTest < Test::Unit::TestCase
5
-
6
- def setup
7
- ['/tmp/first', '/tmp/second'].each do |f|
8
- FileUtils.touch(f)
9
- end
10
- end
11
-
12
- class FirstTestConfiguration < Watchful::Configuration
13
- action :name => 'Placeholder Action'
14
- end
15
-
16
- should 'correctly compile list of actions' do
17
- assert_equal FirstTestConfiguration.actions.length, 1
18
- end
19
-
20
- end
data/test/paths_test.rb DELETED
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
- require 'fileutils'
3
-
4
- class WatchfulTest < Test::Unit::TestCase
5
-
6
- def setup
7
- ['/tmp/first', '/tmp/second'].each do |f|
8
- FileUtils.touch(f)
9
- end
10
- end
11
-
12
- context 'younger_than' do
13
-
14
- should 'correctly compare mtimes' do
15
-
16
- sleep 1
17
- FileUtils.touch('/tmp/first')
18
- assert Watchful.younger_than('/tmp/first', '/tmp/second')
19
-
20
- sleep 1
21
- FileUtils.touch('/tmp/second')
22
- assert Watchful.younger_than('/tmp/second', '/tmp/first')
23
-
24
- end
25
-
26
- should 'raise exception when comparing nonexistant files' do
27
- begin
28
- Watchful.younger_than('/tmp/does/not/exist', @files[1])
29
- flunk
30
- rescue Exception
31
- assert true
32
- end
33
- begin
34
- Watchful.younger_than(@files[0], '/tmp/does/not/exist')
35
- flunk
36
- rescue Exception
37
- assert true
38
- end
39
- end
40
-
41
- end
42
-
43
- context 'compound_extension_of' do
44
-
45
- should "detect simple extensions" do
46
- assert_equal Watchful.compound_extension_of('a_long_file_name.css'), '.css'
47
- end
48
-
49
- should "detect compound extensions" do
50
- assert_equal Watchful.compound_extension_of('test.min.css'), '.min.css'
51
- end
52
-
53
- should "return nil for files without extensions" do
54
- assert_nil Watchful.compound_extension_of('test_file')
55
- end
56
-
57
- should 'return nil for files without basenames' do
58
- assert_nil Watchful.compound_extension_of('.extension')
59
- end
60
-
61
- end
62
-
63
- end
data/test/test_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- # todo: move to raw Test::Unit
6
-
7
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
- $LOAD_PATH.unshift(File.dirname(__FILE__))
9
-
10
- require 'watchful'
11
-
12
- class Test::Unit::Watchful
13
- end
data/watchful.gemspec DELETED
@@ -1,78 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{watchful}
8
- s.version = "0.0.0.pre1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["KEM"]
12
- s.date = %q{2010-04-22}
13
- s.default_executable = %q{watchful}
14
- s.description = %q{Applies intermediary tools to modified files}
15
- s.email = %q{kyleevanmitchell@gmail.com}
16
- s.executables = ["watchful"]
17
- s.extra_rdoc_files = [
18
- "LICENSE",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".gitignore",
23
- "LICENSE",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "bin/watchful",
28
- "doc/DSL-Specification.rb",
29
- "lib/watchful.rb",
30
- "lib/watchful/action.rb",
31
- "lib/watchful/configuration.rb",
32
- "lib/watchful/defaultconfiguration.rb",
33
- "lib/watchful/paths.rb",
34
- "lib/watchful/watch.rb",
35
- "test/action_test.rb",
36
- "test/configuration_test.rb",
37
- "test/customconfiguration_test.rb",
38
- "test/paths_test.rb",
39
- "test/test_helper.rb",
40
- "watchful.gemspec"
41
- ]
42
- s.homepage = %q{http://github.com/kemitchell/watchful}
43
- s.rdoc_options = ["--charset=UTF-8"]
44
- s.require_paths = ["lib"]
45
- s.rubyforge_project = %q{watchful}
46
- s.rubygems_version = %q{1.3.6}
47
- s.summary = %q{Watchful, a tool for busy web devs}
48
- s.test_files = [
49
- "test/action_test.rb",
50
- "test/configuration_test.rb",
51
- "test/customconfiguration_test.rb",
52
- "test/paths_test.rb",
53
- "test/test_helper.rb"
54
- ]
55
-
56
- if s.respond_to? :specification_version then
57
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
- s.specification_version = 3
59
-
60
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
61
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
62
- s.add_runtime_dependency(%q<commandline>, [">= 0"])
63
- s.add_runtime_dependency(%q<extensions>, [">= 0"])
64
- s.add_runtime_dependency(%q<open4>, [">= 0"])
65
- else
66
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
67
- s.add_dependency(%q<commandline>, [">= 0"])
68
- s.add_dependency(%q<extensions>, [">= 0"])
69
- s.add_dependency(%q<open4>, [">= 0"])
70
- end
71
- else
72
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
73
- s.add_dependency(%q<commandline>, [">= 0"])
74
- s.add_dependency(%q<extensions>, [">= 0"])
75
- s.add_dependency(%q<open4>, [">= 0"])
76
- end
77
- end
78
-