visionmedia-bind 0.1.0 → 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/History.rdoc +12 -0
- data/Manifest +11 -3
- data/README.rdoc +1 -1
- data/Rakefile +2 -2
- data/Todo.rdoc +2 -2
- data/bin/rbind +15 -18
- data/bind.gemspec +7 -7
- data/examples/globbing.rb +7 -0
- data/examples/log_changes.rb +3 -3
- data/examples/refresh_browsers.rb +4 -2
- data/examples/style.css +2 -1
- data/lib/bind/actions.rb +0 -1
- data/lib/bind/command_helpers.rb +4 -1
- data/lib/bind/listener.rb +31 -9
- data/lib/bind/version.rb +1 -4
- data/spec/bind_listener_spec.rb +26 -4
- data/spec/fixtures/assets/bar.css +0 -0
- data/spec/fixtures/assets/foo.css +0 -0
- data/spec/fixtures/assets/jquery.js +0 -0
- data/spec/fixtures/assets/js/app.js +0 -0
- data/spec/fixtures/assets/js/test.js +0 -0
- data/spec/spec_helper.rb +5 -1
- metadata +14 -7
- data/examples/refresh_browsers_haml.rb +0 -10
- data/examples/style.sass +0 -2
- data/lib/bind/actions/refresh_browsers_haml.rb +0 -40
data/History.rdoc
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
|
2
|
+
=== 0.2.0 / 2009-03-09
|
3
|
+
|
4
|
+
* Added gitignore
|
5
|
+
* Added support for multiple actions
|
6
|
+
* Added example for multiple actions
|
7
|
+
* Added --eval to common options
|
8
|
+
* Added spec runner / globbing example
|
9
|
+
* Added #expand_dirs
|
10
|
+
* Changed devel dependency visionmedia-commander >=2.5.6
|
11
|
+
* Changed option :files to :paths
|
12
|
+
* Removed RefreshBrowsersHaml, getting to specific to be helpful
|
13
|
+
|
2
14
|
=== 0.1.0 / 2009-03-03
|
3
15
|
|
4
16
|
* Changed exec name bind to rbind to avoid collision
|
data/Manifest
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
bin/rbind
|
2
2
|
bind.gemspec
|
3
3
|
examples/demo.html
|
4
|
+
examples/globbing.rb
|
4
5
|
examples/log_changes.rb
|
5
6
|
examples/refresh_browsers.rb
|
6
|
-
examples/refresh_browsers_haml.rb
|
7
7
|
examples/style.css
|
8
|
-
examples/style.sass
|
9
8
|
History.rdoc
|
10
9
|
lib/bind/actions/refresh_browsers.rb
|
11
|
-
lib/bind/actions/refresh_browsers_haml.rb
|
12
10
|
lib/bind/actions.rb
|
13
11
|
lib/bind/command_helpers.rb
|
14
12
|
lib/bind/listener.rb
|
@@ -18,10 +16,20 @@ Manifest
|
|
18
16
|
Rakefile
|
19
17
|
README.rdoc
|
20
18
|
spec/bind_listener_spec.rb
|
19
|
+
spec/fixtures/assets/bar.css
|
20
|
+
spec/fixtures/assets/foo.css
|
21
|
+
spec/fixtures/assets/jquery.js
|
22
|
+
spec/fixtures/assets/js/app.js
|
23
|
+
spec/fixtures/assets/js/test.js
|
21
24
|
spec/fixtures/style.css
|
22
25
|
spec/spec_helper.rb
|
23
26
|
tasks/docs.rake
|
24
27
|
tasks/gemspec.rake
|
25
28
|
tasks/release.rake
|
26
29
|
tasks/spec.rake
|
30
|
+
test/assets/javascripts/app/foo.js
|
31
|
+
test/assets/javascripts/jquery.js
|
32
|
+
test/assets/stylesheets/foo.css
|
33
|
+
test/assets/stylesheets/style.css
|
34
|
+
test/stylesheets/style.sass
|
27
35
|
Todo.rdoc
|
data/README.rdoc
CHANGED
@@ -32,7 +32,7 @@ sass file is modified, it will be compiled to '..' (up a directory) preceding th
|
|
32
32
|
|
33
33
|
path = 'http://localhost'
|
34
34
|
action = Bind::Actions::RefreshBrowsersHaml.new path, '..', 'Safari', 'Firefox'
|
35
|
-
listener = Bind::Listener.new :interval => 1, :debug => $stdout, :action => action, :
|
35
|
+
listener = Bind::Listener.new :interval => 1, :debug => $stdout, :action => action, :paths => Dir['*.haml'] + Dir['*.sass']
|
36
36
|
listener.run!
|
37
37
|
|
38
38
|
== License:
|
data/Rakefile
CHANGED
@@ -4,13 +4,13 @@ require 'rake'
|
|
4
4
|
require 'echoe'
|
5
5
|
require './lib/bind.rb'
|
6
6
|
|
7
|
-
Echoe.new("bind", Bind::VERSION
|
7
|
+
Echoe.new("bind", Bind::VERSION) do |p|
|
8
8
|
p.author = "TJ Holowaychuk"
|
9
9
|
p.email = "tj@vision-media.ca"
|
10
10
|
p.summary = "bind actions to filesystem events"
|
11
11
|
p.url = "http://github.com/visionmedia/bind"
|
12
12
|
p.runtime_dependencies = []
|
13
|
-
p.runtime_dependencies << 'visionmedia-commander >=2.
|
13
|
+
p.runtime_dependencies << 'visionmedia-commander >=2.5.6'
|
14
14
|
end
|
15
15
|
|
16
16
|
Dir['tasks/**/*.rake'].sort.each { |lib| load lib }
|
data/Todo.rdoc
CHANGED
data/bin/rbind
CHANGED
@@ -11,19 +11,16 @@ program :description, 'Bind actions to filesystem events'
|
|
11
11
|
|
12
12
|
command :to do |c|
|
13
13
|
set_common_options c
|
14
|
-
c.syntax = 'rbind to <
|
15
|
-
c.summary = 'Bind to
|
16
|
-
c.description = 'Bind to modification of a file or
|
17
|
-
c.example 'Bind to a single file, logging its path when changed', "
|
18
|
-
c.
|
14
|
+
c.syntax = 'rbind to <path> [path ...] [options] '
|
15
|
+
c.summary = 'Bind to a file system event'
|
16
|
+
c.description = 'Bind to modification of a file or files within a directory.'
|
17
|
+
c.example 'Bind to a single file, logging its path when changed', "rbind to style.css -e 'puts file.path'"
|
18
|
+
c.example 'Bind to a file, and a directory of files', "rbind to stylesheets style.css -e 'puts file.path'"
|
19
|
+
c.example 'Run specs when ruby files are modified', "rbind to lib/**/*.rb -e 'system \"rake spec\"'"
|
19
20
|
c.when_called do |args, options|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else
|
24
|
-
abort 'invalid option. --eval switch is required in order to perform any action on the bound file(s)'
|
25
|
-
end
|
26
|
-
options.files = args
|
21
|
+
abort 'invalid option. --eval switch is required in order to perform any action on the bound file(s)' unless options.eval
|
22
|
+
common_options options
|
23
|
+
options.paths = args
|
27
24
|
listener(options).run!
|
28
25
|
end
|
29
26
|
end
|
@@ -32,17 +29,17 @@ command :refresh do |c|
|
|
32
29
|
set_common_options c
|
33
30
|
c.syntax = 'rbind refresh <uri> [options]'
|
34
31
|
c.summary = 'Bind to <uri>, refreshing browsers.'
|
35
|
-
c.description = 'Bind to <uri>, refreshing browsers when the
|
32
|
+
c.description = 'Bind to <uri>, refreshing browsers when the paths you are watching change.'
|
36
33
|
c.example = 'Bind a few css files for quick editing in multiple browsers', 'bind refresh http://localhost/page --files style.css,reset.css --browsers Safari,Firefox'
|
37
34
|
c.example = 'Bind local static html (no scheme)', 'bind refresh examples/demo.html -f style.css -b Safari'
|
38
35
|
c.option '-b', '--browsers BROWSERS', Array, 'List of browsers you wish to refresh. Defaults to Safari'
|
39
|
-
c.option '-
|
36
|
+
c.option '-p', '--paths PATHS', Array, 'List of files, directories, or globs to bind to'
|
40
37
|
c.when_called do |args, options|
|
41
|
-
|
42
|
-
|
38
|
+
common_options options
|
39
|
+
uri = expand_path args.shift
|
43
40
|
browsers = options.browsers || ['Safari']
|
44
|
-
options.
|
45
|
-
abort 'invalid option. --
|
41
|
+
options.actions << Bind::Actions::RefreshBrowsers.new(uri, *browsers)
|
42
|
+
abort 'invalid option. --paths switch is required in order to bind' if options.paths.nil?
|
46
43
|
listener(options).run!
|
47
44
|
end
|
48
45
|
end
|
data/bind.gemspec
CHANGED
@@ -2,17 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{bind}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["TJ Holowaychuk"]
|
9
|
-
s.date = %q{2009-03-
|
9
|
+
s.date = %q{2009-03-09}
|
10
10
|
s.default_executable = %q{rbind}
|
11
11
|
s.description = %q{bind actions to filesystem events}
|
12
12
|
s.email = %q{tj@vision-media.ca}
|
13
13
|
s.executables = ["rbind"]
|
14
|
-
s.extra_rdoc_files = ["bin/rbind", "bind.gemspec", "lib/bind/actions/refresh_browsers.rb", "lib/bind/actions
|
15
|
-
s.files = ["bin/rbind", "bind.gemspec", "examples/demo.html", "examples/
|
14
|
+
s.extra_rdoc_files = ["bin/rbind", "bind.gemspec", "lib/bind/actions/refresh_browsers.rb", "lib/bind/actions.rb", "lib/bind/command_helpers.rb", "lib/bind/listener.rb", "lib/bind/version.rb", "lib/bind.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/release.rake", "tasks/spec.rake"]
|
15
|
+
s.files = ["bin/rbind", "bind.gemspec", "examples/demo.html", "examples/globbing.rb", "examples/log_changes.rb", "examples/refresh_browsers.rb", "examples/style.css", "History.rdoc", "lib/bind/actions/refresh_browsers.rb", "lib/bind/actions.rb", "lib/bind/command_helpers.rb", "lib/bind/listener.rb", "lib/bind/version.rb", "lib/bind.rb", "Manifest", "Rakefile", "README.rdoc", "spec/bind_listener_spec.rb", "spec/fixtures/assets/bar.css", "spec/fixtures/assets/foo.css", "spec/fixtures/assets/jquery.js", "spec/fixtures/assets/js/app.js", "spec/fixtures/assets/js/test.js", "spec/fixtures/style.css", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/release.rake", "tasks/spec.rake", "test/assets/javascripts/app/foo.js", "test/assets/javascripts/jquery.js", "test/assets/stylesheets/foo.css", "test/assets/stylesheets/style.css", "test/stylesheets/style.sass", "Todo.rdoc"]
|
16
16
|
s.has_rdoc = true
|
17
17
|
s.homepage = %q{http://github.com/visionmedia/bind}
|
18
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Bind", "--main", "README.rdoc"]
|
@@ -26,11 +26,11 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.specification_version = 2
|
27
27
|
|
28
28
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
-
s.add_runtime_dependency(%q<visionmedia-commander>, [">= 2.
|
29
|
+
s.add_runtime_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
30
30
|
else
|
31
|
-
s.add_dependency(%q<visionmedia-commander>, [">= 2.
|
31
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
32
32
|
end
|
33
33
|
else
|
34
|
-
s.add_dependency(%q<visionmedia-commander>, [">= 2.
|
34
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 2.5.6"])
|
35
35
|
end
|
36
36
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/../lib/bind'
|
3
|
+
|
4
|
+
paths = [File.dirname(__FILE__) + '/*.rb']
|
5
|
+
action = lambda { |file| puts "modified #{file.path}" }
|
6
|
+
listener = Bind::Listener.new :event => :change, :paths => paths, :interval => 1, :actions => [action], :timeout => 10
|
7
|
+
listener.run!
|
data/examples/log_changes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
2
|
require File.dirname(__FILE__) + '/../lib/bind'
|
3
3
|
|
4
|
-
# Execute this file to start the listener, then alter
|
4
|
+
# Execute this file to start the listener, then alter any file in this directory
|
5
5
|
|
6
|
-
|
6
|
+
paths = [File.dirname(__FILE__)]
|
7
7
|
action = lambda { |file| puts "modified #{file}" }
|
8
|
-
listener = Bind::Listener.new :event => :change, :
|
8
|
+
listener = Bind::Listener.new :event => :change, :paths => paths, :interval => 1, :actions => [action], :timeout => 10, :debug => $stdout
|
9
9
|
listener.run!
|
@@ -3,8 +3,10 @@ require File.dirname(__FILE__) + '/../lib/bind'
|
|
3
3
|
|
4
4
|
# Execute this file to start the listener, then alter style.css a few times
|
5
5
|
|
6
|
+
actions = []
|
6
7
|
html = File.expand_path(File.dirname(__FILE__) + '/demo.html')
|
7
8
|
style = File.dirname(__FILE__) + '/style.css'
|
8
|
-
|
9
|
-
|
9
|
+
actions << lambda { |file| puts "modified #{file.path}" }
|
10
|
+
actions << Bind::Actions::RefreshBrowsers.new(html, 'Safari')
|
11
|
+
listener = Bind::Listener.new :event => :change, :paths => [style], :interval => 1, :actions => actions, :timeout => 60
|
10
12
|
listener.run!
|
data/examples/style.css
CHANGED
data/lib/bind/actions.rb
CHANGED
data/lib/bind/command_helpers.rb
CHANGED
@@ -3,6 +3,7 @@ def set_common_options c
|
|
3
3
|
c.option '-i', '--interval SECONDS', Integer, 'Interval in seconds in which to listen for an event.'
|
4
4
|
c.option '-t', '--timeout SECONDS', Integer, 'Timeout after n seconds.'
|
5
5
|
c.option '-r', '--require LIBS', Array, 'Require ruby libraries.'
|
6
|
+
c.option '-e', '--eval STRING', String, 'Evaluate a string of Ruby in context of Bind, so the file local variable is available.'
|
6
7
|
c.option '-V', '--verbose', 'Log information to STDOUT.'
|
7
8
|
end
|
8
9
|
|
@@ -10,7 +11,9 @@ def listener options
|
|
10
11
|
Bind::Listener.new options_to_hash(options)
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def common_options options
|
15
|
+
options.actions ||= []
|
16
|
+
options.actions << lambda { |file| eval options.eval } if options.eval
|
14
17
|
options.require.each { |lib| require lib } if options.require
|
15
18
|
options.debug = $stdout if options.verbose
|
16
19
|
end
|
data/lib/bind/listener.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Bind
|
4
4
|
class Listener
|
5
5
|
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :paths, :actions, :timeout, :interval, :event
|
7
7
|
attr_reader :run_time, :start_time, :finish_time
|
8
8
|
|
9
9
|
#--
|
@@ -13,12 +13,12 @@ module Bind
|
|
13
13
|
class Error < StandardError; end
|
14
14
|
|
15
15
|
##
|
16
|
-
# Event listener. Must specify the :
|
16
|
+
# Event listener. Must specify the :paths, and :action options.
|
17
17
|
#
|
18
18
|
# === Options:
|
19
19
|
#
|
20
|
-
# :
|
21
|
-
# :
|
20
|
+
# :paths array of file or directory paths
|
21
|
+
# :actions objects responding to #call, which is used as the callbacks for the event handler
|
22
22
|
# :timeout time in seconds, after which the listener should stop. Defaults to 0, meaning infinity
|
23
23
|
# :event event to bind to, may be one of (:change). Defaults to :change
|
24
24
|
# :debug log verbose debugging information to this stream
|
@@ -27,22 +27,36 @@ module Bind
|
|
27
27
|
|
28
28
|
def initialize options = {}
|
29
29
|
@run_time, @mtimes = 0, {}
|
30
|
-
@
|
31
|
-
raise ArgumentError, 'specify one or more :
|
30
|
+
@paths = options.fetch :paths do
|
31
|
+
raise ArgumentError, 'specify one or more :paths (or directories) to bind the listener to'
|
32
32
|
end
|
33
|
-
@
|
34
|
-
raise ArgumentError, '
|
33
|
+
@actions = options.fetch :actions do
|
34
|
+
raise ArgumentError, ':actions must be an array of objects responding to #call'
|
35
35
|
end
|
36
36
|
@log = options.fetch :debug, false
|
37
37
|
@timeout = options.fetch :timeout, 0
|
38
38
|
@interval = options.fetch :interval, 2
|
39
39
|
@event = options.fetch :event, :change
|
40
40
|
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Expand directories into file paths.
|
44
|
+
|
45
|
+
def expand_dirs paths
|
46
|
+
paths.inject [] do |files, path|
|
47
|
+
case
|
48
|
+
when File.directory?(path) ; files += Dir["#{path}/**/*.*"]
|
49
|
+
when File.file?(path) ; files << path
|
50
|
+
else files += Dir[path]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
41
54
|
|
42
55
|
##
|
43
56
|
# Start the listener.
|
44
57
|
|
45
58
|
def run!
|
59
|
+
files = expand_dirs @paths
|
46
60
|
start_time = Time.now
|
47
61
|
log "binding to #{files.join(', ')}, watching #{event} every #{interval} second(s)." +
|
48
62
|
(timeout > 0 ? " Terminating in #{timeout} seconds" : '')
|
@@ -61,13 +75,21 @@ module Bind
|
|
61
75
|
|
62
76
|
private
|
63
77
|
|
78
|
+
##
|
79
|
+
# Invoke all current actions with a +file+.
|
80
|
+
|
81
|
+
def call_actions_with file
|
82
|
+
p actions
|
83
|
+
actions.each { |action| action.call file }
|
84
|
+
end
|
85
|
+
|
64
86
|
##
|
65
87
|
# Handle change event.
|
66
88
|
|
67
89
|
def change file
|
68
90
|
if changed? file
|
69
91
|
log "changed #{file.path}"
|
70
|
-
|
92
|
+
call_actions_with file
|
71
93
|
@mtimes[file.path] = file.mtime
|
72
94
|
end
|
73
95
|
end
|
data/lib/bind/version.rb
CHANGED
data/spec/bind_listener_spec.rb
CHANGED
@@ -1,14 +1,36 @@
|
|
1
1
|
|
2
2
|
describe Bind::Listener do
|
3
3
|
|
4
|
-
def listener &action
|
5
|
-
Bind::Listener.new :event => :change, :
|
4
|
+
def listener *paths, &action
|
5
|
+
Bind::Listener.new :event => :change, :paths => paths, :interval => 1, :actions => [action], :timeout => 2
|
6
6
|
end
|
7
7
|
|
8
|
-
it "should
|
8
|
+
it "should expand directories" do
|
9
|
+
files = %w(
|
10
|
+
./spec/fixtures/assets/bar.css
|
11
|
+
./spec/fixtures/assets/foo.css
|
12
|
+
./spec/fixtures/assets/jquery.js
|
13
|
+
./spec/fixtures/assets/js/app.js
|
14
|
+
./spec/fixtures/assets/js/test.js
|
15
|
+
)
|
16
|
+
l = listener {}
|
17
|
+
l.expand_dirs(fixture_path('assets')).should == files
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should expand directories using globbing" do
|
21
|
+
files = %w(
|
22
|
+
./spec/fixtures/assets/jquery.js
|
23
|
+
./spec/fixtures/assets/js/app.js
|
24
|
+
./spec/fixtures/assets/js/test.js
|
25
|
+
)
|
9
26
|
l = listener {}
|
27
|
+
l.expand_dirs(fixture_path('assets/**/*.js')).should == files
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should record total runtime" do
|
31
|
+
l = listener(fixture_path('style.css')) {}
|
10
32
|
l.run!
|
11
33
|
l.run_time.to_i.should == 2
|
12
34
|
end
|
13
|
-
|
35
|
+
|
14
36
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: visionmedia-bind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TJ Holowaychuk
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-03-
|
12
|
+
date: 2009-03-09 00:00:00 -07:00
|
13
13
|
default_executable: rbind
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.
|
23
|
+
version: 2.5.6
|
24
24
|
version:
|
25
25
|
description: bind actions to filesystem events
|
26
26
|
email: tj@vision-media.ca
|
@@ -32,7 +32,6 @@ extra_rdoc_files:
|
|
32
32
|
- bin/rbind
|
33
33
|
- bind.gemspec
|
34
34
|
- lib/bind/actions/refresh_browsers.rb
|
35
|
-
- lib/bind/actions/refresh_browsers_haml.rb
|
36
35
|
- lib/bind/actions.rb
|
37
36
|
- lib/bind/command_helpers.rb
|
38
37
|
- lib/bind/listener.rb
|
@@ -47,14 +46,12 @@ files:
|
|
47
46
|
- bin/rbind
|
48
47
|
- bind.gemspec
|
49
48
|
- examples/demo.html
|
49
|
+
- examples/globbing.rb
|
50
50
|
- examples/log_changes.rb
|
51
51
|
- examples/refresh_browsers.rb
|
52
|
-
- examples/refresh_browsers_haml.rb
|
53
52
|
- examples/style.css
|
54
|
-
- examples/style.sass
|
55
53
|
- History.rdoc
|
56
54
|
- lib/bind/actions/refresh_browsers.rb
|
57
|
-
- lib/bind/actions/refresh_browsers_haml.rb
|
58
55
|
- lib/bind/actions.rb
|
59
56
|
- lib/bind/command_helpers.rb
|
60
57
|
- lib/bind/listener.rb
|
@@ -64,12 +61,22 @@ files:
|
|
64
61
|
- Rakefile
|
65
62
|
- README.rdoc
|
66
63
|
- spec/bind_listener_spec.rb
|
64
|
+
- spec/fixtures/assets/bar.css
|
65
|
+
- spec/fixtures/assets/foo.css
|
66
|
+
- spec/fixtures/assets/jquery.js
|
67
|
+
- spec/fixtures/assets/js/app.js
|
68
|
+
- spec/fixtures/assets/js/test.js
|
67
69
|
- spec/fixtures/style.css
|
68
70
|
- spec/spec_helper.rb
|
69
71
|
- tasks/docs.rake
|
70
72
|
- tasks/gemspec.rake
|
71
73
|
- tasks/release.rake
|
72
74
|
- tasks/spec.rake
|
75
|
+
- test/assets/javascripts/app/foo.js
|
76
|
+
- test/assets/javascripts/jquery.js
|
77
|
+
- test/assets/stylesheets/foo.css
|
78
|
+
- test/assets/stylesheets/style.css
|
79
|
+
- test/stylesheets/style.sass
|
73
80
|
- Todo.rdoc
|
74
81
|
has_rdoc: true
|
75
82
|
homepage: http://github.com/visionmedia/bind
|
@@ -1,10 +0,0 @@
|
|
1
|
-
|
2
|
-
require File.dirname(__FILE__) + '/../lib/bind'
|
3
|
-
|
4
|
-
# Execute this file to start the listener, then alter style.css a few times
|
5
|
-
|
6
|
-
html = File.expand_path(File.dirname(__FILE__) + '/demo.html')
|
7
|
-
style = File.dirname(__FILE__) + '/style.sass'
|
8
|
-
action = Bind::Actions::RefreshBrowsersHaml.new html, '.', 'Safari'
|
9
|
-
listener = Bind::Listener.new :event => :change, :files => [style], :interval => 2, :action => action, :debug => $stdout
|
10
|
-
listener.run!
|
data/examples/style.sass
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
require 'haml'
|
4
|
-
require 'haml/exec'
|
5
|
-
|
6
|
-
module Bind
|
7
|
-
module Actions
|
8
|
-
class RefreshBrowsersHaml
|
9
|
-
|
10
|
-
attr_accessor :browsers, :uri
|
11
|
-
|
12
|
-
def initialize uri, dest, *browsers
|
13
|
-
@uri, @dest, @browsers = uri, File.expand_path(dest), browsers
|
14
|
-
end
|
15
|
-
|
16
|
-
def call file
|
17
|
-
build_haml file if haml? file
|
18
|
-
build_sass file if sass? file
|
19
|
-
@browsers.each { |browser| `open -g -a #{browser} #{uri}` }
|
20
|
-
end
|
21
|
-
|
22
|
-
def build_haml file
|
23
|
-
`haml #{ file.path } #{ File.join(@dest, file.path.sub('.haml', '.html')) }`
|
24
|
-
end
|
25
|
-
|
26
|
-
def build_sass file
|
27
|
-
`sass #{ file.path } #{ File.join(@dest, file.path.sub('.sass', '.css')) }`
|
28
|
-
end
|
29
|
-
|
30
|
-
def haml? file
|
31
|
-
file.path.include? '.haml'
|
32
|
-
end
|
33
|
-
|
34
|
-
def sass? file
|
35
|
-
file.path.include? '.sass'
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|