bind 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,66 @@
1
+
2
+ === 0.2.6 / 2009-03-25
3
+
4
+ * Updated exec doc to match recent changes
5
+
6
+ === 0.2.5 / 2009-03-22
7
+
8
+ * visionmedia-commander >=3.1.6 for options hash symbols
9
+
10
+ === 0.2.4 / 2009-03-22
11
+
12
+ * Removed options_to_hash, using Options#__hash__ now
13
+ * visionmedia-commander >=3.1.5
14
+ * Removed loadpath
15
+
16
+ === 0.2.3 / 2009-03-20
17
+
18
+ * Added more specs for listener
19
+ * Added specs for command helpers
20
+ * Removed loadpath unshift
21
+
22
+ === 0.2.2 / 2009-03-13
23
+
24
+ * Updated dependency visionmedia-commander >= 3.1.1
25
+
26
+ === 0.2.1 / 2009-03-09
27
+
28
+ * Removed a #p call
29
+
30
+ === 0.2.0 / 2009-03-09
31
+
32
+ * Added gitignore
33
+ * Added support for multiple actions
34
+ * Added example for multiple actions
35
+ * Added --eval to common options
36
+ * Added spec runner / globbing example
37
+ * Added #expand_dirs
38
+ * Changed devel dependency visionmedia-commander >=2.5.6
39
+ * Changed option :files to :paths
40
+ * Removed RefreshBrowsersHaml, getting to specific to be helpful
41
+
42
+ === 0.1.0 / 2009-03-03
43
+
44
+ * Changed exec name bind to rbind to avoid collision
45
+
46
+ === 0.0.9 / 2009-03-03
47
+
48
+ * Added RefreshBrowsersHaml example
49
+ * Fixed RefreshBrowsersHaml.. ruby library for haml's exec was not working
50
+ just using shell for now.
51
+
52
+ === 0.0.8 / 2009-03-03
53
+
54
+ * Fixed typo in RefreshBrowsersHaml
55
+
56
+ === 0.0.6 / 2009-03-03
57
+
58
+ * Fixed RefreshBrowsersHaml, forgot to add the file to the manifest :)
59
+
60
+ === 0.0.3 / 2009-03-03
61
+
62
+ * Added action RefreshBrowsersHaml for haml / sass support
63
+
64
+ === 0.0.1 / 2009-03-03
65
+
66
+ * Initial release
@@ -0,0 +1,31 @@
1
+ bin/rbind
2
+ bind.gemspec
3
+ examples/demo.html
4
+ examples/globbing.rb
5
+ examples/log_changes.rb
6
+ examples/refresh_browsers.rb
7
+ examples/style.css
8
+ History.rdoc
9
+ lib/bind/actions/refresh_browsers.rb
10
+ lib/bind/actions.rb
11
+ lib/bind/command_helpers.rb
12
+ lib/bind/listener.rb
13
+ lib/bind/version.rb
14
+ lib/bind.rb
15
+ Manifest
16
+ Rakefile
17
+ README.rdoc
18
+ spec/command_helper_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
24
+ spec/fixtures/style.css
25
+ spec/listener_spec.rb
26
+ spec/spec_helper.rb
27
+ tasks/docs.rake
28
+ tasks/gemspec.rake
29
+ tasks/release.rake
30
+ tasks/spec.rake
31
+ Todo.rdoc
@@ -0,0 +1,68 @@
1
+
2
+ = Bind
3
+
4
+ Bind actions to various file system events, helping aid in
5
+ automation of tasks such as refreshing browser(s) when you
6
+ update a css / sass / js file.
7
+
8
+ == Executable
9
+
10
+ The 'bind' executable allows you to perform arbitrary actions
11
+ based on several events. Currently only the change (mtime) event
12
+ is supported.
13
+
14
+ Bind to a single file, outputting its path when changed
15
+ $ rbind to style.css -e 'puts file.path'
16
+
17
+ Bind to glob
18
+ $ rbind to stylesheets/*.css -e 'puts file.path'
19
+
20
+ Bind to ruby glob (allows recursion) note the quotes
21
+ $ rbind to 'stylesheets/**/*.css' -e 'puts file.path'
22
+
23
+ Refresh Safari, and Firefox in the background to the uri specified when
24
+ style.css or reset.css are modified.
25
+ $ rbind refresh http://localhost/page --paths style.css,reset.css --browsers Safari,Firefox
26
+
27
+ Refresh local static html when the style you are working on is modified.
28
+ $ rbind refresh examples/demo.html -f style.css -b Safari
29
+
30
+ == Library
31
+
32
+ Bind of course supplies a Ruby library as well, which provides the same
33
+ functionality as the executable above.
34
+
35
+
36
+ Refresh Safari and Firefox, using the RefreshBrowsersHaml action, whenever a haml or
37
+ sass file is modified, it will be compiled to '..' (up a directory) preceding the refresh.
38
+
39
+ path = 'http://localhost'
40
+ action = Bind::Actions::RefreshBrowsersHaml.new path, '..', 'Safari', 'Firefox'
41
+ listener = Bind::Listener.new :interval => 1, :debug => $stdout, :action => action, :paths => Dir['*.haml'] + Dir['*.sass']
42
+ listener.run!
43
+
44
+ == License:
45
+
46
+ (The MIT License)
47
+
48
+ Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
49
+
50
+ Permission is hereby granted, free of charge, to any person obtaining
51
+ a copy of this software and associated documentation files (the
52
+ 'Software'), to deal in the Software without restriction, including
53
+ without limitation the rights to use, copy, modify, merge, publish,
54
+ distribute, sublicense, an d/or sell copies of the Software, and to
55
+ permit persons to whom the Software is furnished to do so, subject to
56
+ the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be
59
+ included in all copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
62
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
63
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
64
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
65
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
66
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
67
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
68
+ GS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+
2
+ $:.unshift 'lib'
3
+ require 'bind'
4
+ require 'rubygems'
5
+ require 'rake'
6
+ require 'echoe'
7
+
8
+ Echoe.new "bind", Bind::VERSION do |p|
9
+ p.author = "TJ Holowaychuk"
10
+ p.email = "tj@vision-media.ca"
11
+ p.summary = "bind actions to filesystem events"
12
+ p.url = "http://github.com/visionmedia/bind"
13
+ p.runtime_dependencies = []
14
+ p.runtime_dependencies << 'visionmedia-commander >=3.1.6'
15
+ end
16
+
17
+ Dir['tasks/**/*.rake'].sort.each { |lib| load lib }
@@ -0,0 +1,18 @@
1
+
2
+ == Major:
3
+
4
+ * Native JSpec support
5
+ * Allow --paths to have globs ... and dirs test this
6
+ * Autotest-like functionality for specs / refactoring
7
+ * rbind rake ext:build spec --paths foo,foobar,w/e
8
+ * Test refresh eval
9
+ * Increase readability / Documentation
10
+ * Better specs
11
+
12
+ == Minor:
13
+
14
+ * Add more actions / events like atime
15
+
16
+ == Brainstorming:
17
+
18
+ * Nothing
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'bind'
5
+ require 'bind/command_helpers'
6
+ require 'commander'
7
+
8
+ program :name, 'rbind'
9
+ program :version, Bind::VERSION
10
+ program :description, 'Bind actions to filesystem events'
11
+
12
+ command :to do |c|
13
+ set_common_options 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\"'"
20
+ c.when_called do |args, options|
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
24
+ listener(options).run!
25
+ end
26
+ end
27
+
28
+ command :refresh do |c|
29
+ set_common_options c
30
+ c.syntax = 'rbind refresh <uri> [options]'
31
+ c.summary = 'Bind to <uri>, refreshing browsers.'
32
+ c.description = 'Bind to <uri>, refreshing browsers when the paths you are watching change.'
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'
34
+ c.example 'Bind local static html (no scheme)', 'bind refresh examples/demo.html -f style.css -b Safari'
35
+ c.option '-b', '--browsers BROWSERS', Array, 'List of browsers you wish to refresh. Defaults to Safari'
36
+ c.option '-p', '--paths PATHS', Array, 'List of files, directories, or globs to bind to'
37
+ c.when_called do |args, options|
38
+ common_options options
39
+ uri = expand_path args.shift
40
+ browsers = options.browsers || ['Safari']
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?
43
+ listener(options).run!
44
+ end
45
+ end
@@ -0,0 +1,36 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{bind}
5
+ s.version = "0.2.6"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["TJ Holowaychuk"]
9
+ s.date = %q{2009-03-25}
10
+ s.default_executable = %q{rbind}
11
+ s.description = %q{bind actions to filesystem events}
12
+ s.email = %q{tj@vision-media.ca}
13
+ s.executables = ["rbind"]
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/command_helper_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/listener_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/release.rake", "tasks/spec.rake", "Todo.rdoc"]
16
+ s.has_rdoc = true
17
+ s.homepage = %q{http://github.com/visionmedia/bind}
18
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Bind", "--main", "README.rdoc"]
19
+ s.require_paths = ["lib"]
20
+ s.rubyforge_project = %q{bind}
21
+ s.rubygems_version = %q{1.3.1}
22
+ s.summary = %q{bind actions to filesystem events}
23
+
24
+ if s.respond_to? :specification_version then
25
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
26
+ s.specification_version = 2
27
+
28
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
29
+ s.add_runtime_dependency(%q<visionmedia-commander>, [">= 3.1.6"])
30
+ else
31
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.1.6"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<visionmedia-commander>, [">= 3.1.6"])
35
+ end
36
+ end
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <body>
3
+ <title>Bind Demo</title>
4
+ <link rel="stylesheet" href="style.css" />
5
+ </body>
6
+ <h1>Bind Demo</h1>
7
+ <p>Try binding to style.css and editing it, then watch bind update several browsers simaltaniously.</p>
8
+ </html>
@@ -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!
@@ -0,0 +1,9 @@
1
+
2
+ require File.dirname(__FILE__) + '/../lib/bind'
3
+
4
+ # Execute this file to start the listener, then alter any file in this directory
5
+
6
+ paths = [File.dirname(__FILE__)]
7
+ action = lambda { |file| puts "modified #{file}" }
8
+ listener = Bind::Listener.new :event => :change, :paths => paths, :interval => 1, :actions => [action], :timeout => 10, :debug => $stdout
9
+ listener.run!
@@ -0,0 +1,12 @@
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
+ actions = []
7
+ html = File.expand_path(File.dirname(__FILE__) + '/demo.html')
8
+ style = File.dirname(__FILE__) + '/style.css'
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
12
+ listener.run!
@@ -0,0 +1,3 @@
1
+ h1 {
2
+ color: blue;
3
+ }
@@ -0,0 +1,26 @@
1
+ #--
2
+ # Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ require 'bind/version'
25
+ require 'bind/listener'
26
+ require 'bind/actions'
@@ -0,0 +1,6 @@
1
+
2
+ module Bind
3
+ module Actions
4
+ autoload :RefreshBrowsers, 'bind/actions/refresh_browsers'
5
+ end
6
+ end
@@ -0,0 +1,18 @@
1
+
2
+ module Bind
3
+ module Actions
4
+ class RefreshBrowsers
5
+
6
+ attr_accessor :browsers, :uri
7
+
8
+ def initialize uri, *browsers
9
+ @uri, @browsers = uri, browsers
10
+ end
11
+
12
+ def call file
13
+ @browsers.each { |browser| `open -g -a #{browser} #{uri}` }
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+
2
+ def set_common_options c
3
+ c.option '-i', '--interval SECONDS', Integer, 'Interval in seconds in which to listen for an event.'
4
+ c.option '-t', '--timeout SECONDS', Integer, 'Timeout after n seconds.'
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.'
7
+ c.option '-V', '--verbose', 'Log information to STDOUT.'
8
+ end
9
+
10
+ def listener options
11
+ Bind::Listener.new options.__hash__
12
+ end
13
+
14
+ def common_options options
15
+ options.actions ||= []
16
+ options.actions << lambda { |file| eval options.eval } if options.eval
17
+ options.require.each { |lib| require lib } if options.require
18
+ options.debug = $stdout if options.verbose
19
+ end
20
+
21
+ def expand_path path
22
+ path.include?('://') ? path : File.expand_path(path)
23
+ end
@@ -0,0 +1,113 @@
1
+
2
+ module Bind
3
+ class Listener
4
+
5
+ attr_accessor :paths, :actions, :timeout, :interval, :event
6
+ attr_reader :run_time, :start_time, :finish_time
7
+
8
+ #--
9
+ # Exceptions
10
+ #++
11
+
12
+ class Error < StandardError; end
13
+
14
+ ##
15
+ # Event listener. Must specify the :paths, and :action options.
16
+ #
17
+ # === Options:
18
+ #
19
+ # :paths array of file or directory paths
20
+ # :actions objects responding to #call, which is used as the callbacks for the event handler
21
+ # :timeout time in seconds, after which the listener should stop. Defaults to 0, meaning infinity
22
+ # :event event to bind to, may be one of (:change). Defaults to :change
23
+ # :debug log verbose debugging information to this stream
24
+ # :interval sleep interval in seconds. Defaults to 2
25
+ #
26
+
27
+ def initialize options = {}
28
+ @run_time, @mtimes = 0, {}
29
+ @paths = options.fetch :paths do
30
+ raise ArgumentError, 'specify one or more :paths (or directories) to bind the listener to'
31
+ end
32
+ @actions = options.fetch :actions do
33
+ raise ArgumentError, ':actions must be an array of objects responding to #call'
34
+ end
35
+ @log = options.fetch :debug, false
36
+ @timeout = options.fetch :timeout, 0
37
+ @interval = options.fetch :interval, 2
38
+ @event = options.fetch :event, :change
39
+ end
40
+
41
+ ##
42
+ # Expand directories into file paths, returns array.
43
+
44
+ def expand_dirs paths
45
+ paths.inject [] do |files, path|
46
+ case
47
+ when File.directory?(path) ; files += Dir["#{path}/**/*.*"]
48
+ when File.file?(path) ; files << path
49
+ else files += Dir[path]
50
+ end
51
+ end
52
+ end
53
+
54
+ ##
55
+ # Start the listener.
56
+
57
+ def run!
58
+ files = expand_dirs @paths
59
+ start_time = Time.now
60
+ log "binding to #{files.join(', ')}, watching #{event} every #{interval} second(s)." +
61
+ (timeout > 0 ? " Terminating in #{timeout} seconds" : '')
62
+ catch :halt do
63
+ loop do
64
+ @run_time = Time.now - start_time
65
+ throw :halt if timeout > 0 and @run_time >= timeout
66
+ log '.', true
67
+ files.each { |file| send event, File.new(file) }
68
+ sleep interval
69
+ end
70
+ end
71
+ finish_time = Time.now
72
+ log "binding terminated"
73
+ end
74
+
75
+ private
76
+
77
+ ##
78
+ # Invoke all current actions with a +file+.
79
+
80
+ def call_actions_with file
81
+ actions.each { |action| action.call file }
82
+ end
83
+
84
+ ##
85
+ # Handle change event.
86
+
87
+ def change file
88
+ if changed? file
89
+ log "changed #{file.path}"
90
+ call_actions_with file
91
+ @mtimes[file.path] = file.mtime
92
+ end
93
+ end
94
+
95
+ ##
96
+ # Check if +file+ has been modified since the last check.
97
+
98
+ def changed? file
99
+ file.mtime > (@mtimes[file.path] ||= file.mtime)
100
+ end
101
+
102
+ ##
103
+ # Optionally log a +message+ when a stream has been specified.
104
+
105
+ def log message, print = false
106
+ if @log
107
+ print ? @log.print(message) : @log.puts(message)
108
+ @log.flush
109
+ end
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module Bind
3
+ VERSION = '0.2.6'
4
+ end
@@ -0,0 +1,19 @@
1
+
2
+ require 'bind/command_helpers'
3
+ require 'ostruct'
4
+
5
+ describe Bind do
6
+ describe "Helpers" do
7
+
8
+ describe "#expand_path" do
9
+ it "should expand local files to an asolute path" do
10
+ expand_path('History.rdoc').should include('bind/History.rdoc')
11
+ end
12
+
13
+ it "should leave uris as they are" do
14
+ expand_path('http://foo.com').should == 'http://foo.com'
15
+ end
16
+ end
17
+
18
+ end
19
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,41 @@
1
+
2
+ describe Bind::Listener do
3
+
4
+ def listener *paths, &action
5
+ Bind::Listener.new :event => :change, :paths => paths, :interval => 1, :actions => [action], :timeout => 2
6
+ end
7
+
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 paths to a single file" do
21
+ l = listener {}
22
+ l.expand_dirs(fixture_path('style.css')).should == ['./spec/fixtures/style.css']
23
+ end
24
+
25
+ it "should expand directories using globbing" do
26
+ files = %w(
27
+ ./spec/fixtures/assets/jquery.js
28
+ ./spec/fixtures/assets/js/app.js
29
+ ./spec/fixtures/assets/js/test.js
30
+ )
31
+ l = listener {}
32
+ l.expand_dirs(fixture_path('assets/**/*.js')).should == files
33
+ end
34
+
35
+ it "should record total runtime" do
36
+ l = listener(fixture_path('style.css')) {}
37
+ l.run!
38
+ l.run_time.to_i.should == 2
39
+ end
40
+
41
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require 'bind'
3
+
4
+ def fixture_path path
5
+ File.join File.dirname(__FILE__), 'fixtures', path
6
+ end
@@ -0,0 +1,13 @@
1
+
2
+ namespace :docs do
3
+
4
+ desc 'Remove rdoc products'
5
+ task :remove => [:clobber_docs]
6
+
7
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
8
+ task :open do
9
+ browser = ENV["BROWSER"] || "safari"
10
+ sh "open -a #{browser} doc/index.html"
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+
2
+ desc 'Build gemspec file'
3
+ task :gemspec => [:build_gemspec]
@@ -0,0 +1,14 @@
1
+
2
+ namespace :release do
3
+
4
+ desc 'Release VERSION. Commits, tags, and pushes.'
5
+ task :version do
6
+ abort 'specify the version x.x.x' unless ENV['VERSION'] and ENV['VERSION'].match(/^\d+\.\d+\.\d+$/)
7
+ `rake manifest`
8
+ `rake gemspec`
9
+ `git commit -a -m '- Release #{ENV['VERSION']}'`
10
+ `git tag #{ENV['VERSION']} && git push && git push --tags`
11
+ puts "Release of #{ENV['VERSION']} complete"
12
+ end
13
+
14
+ end
@@ -0,0 +1,25 @@
1
+
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all specifications"
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ t.libs << "lib"
7
+ t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
8
+ end
9
+
10
+ namespace :spec do
11
+
12
+ desc "Run all specifications verbosely"
13
+ Spec::Rake::SpecTask.new(:verbose) do |t|
14
+ t.libs << "lib"
15
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
16
+ end
17
+
18
+ desc "Run specific specification verbosely (specify SPEC)"
19
+ Spec::Rake::SpecTask.new(:select) do |t|
20
+ t.libs << "lib"
21
+ t.spec_files = [ENV["SPEC"]]
22
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bind
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6
5
+ platform: ruby
6
+ authors:
7
+ - TJ Holowaychuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-03-25 00:00:00 -07:00
13
+ default_executable: rbind
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: visionmedia-commander
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.1.6
24
+ version:
25
+ description: bind actions to filesystem events
26
+ email: tj@vision-media.ca
27
+ executables:
28
+ - rbind
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - bin/rbind
33
+ - bind.gemspec
34
+ - lib/bind/actions/refresh_browsers.rb
35
+ - lib/bind/actions.rb
36
+ - lib/bind/command_helpers.rb
37
+ - lib/bind/listener.rb
38
+ - lib/bind/version.rb
39
+ - lib/bind.rb
40
+ - README.rdoc
41
+ - tasks/docs.rake
42
+ - tasks/gemspec.rake
43
+ - tasks/release.rake
44
+ - tasks/spec.rake
45
+ files:
46
+ - bin/rbind
47
+ - bind.gemspec
48
+ - examples/demo.html
49
+ - examples/globbing.rb
50
+ - examples/log_changes.rb
51
+ - examples/refresh_browsers.rb
52
+ - examples/style.css
53
+ - History.rdoc
54
+ - lib/bind/actions/refresh_browsers.rb
55
+ - lib/bind/actions.rb
56
+ - lib/bind/command_helpers.rb
57
+ - lib/bind/listener.rb
58
+ - lib/bind/version.rb
59
+ - lib/bind.rb
60
+ - Manifest
61
+ - Rakefile
62
+ - README.rdoc
63
+ - spec/command_helper_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
69
+ - spec/fixtures/style.css
70
+ - spec/listener_spec.rb
71
+ - spec/spec_helper.rb
72
+ - tasks/docs.rake
73
+ - tasks/gemspec.rake
74
+ - tasks/release.rake
75
+ - tasks/spec.rake
76
+ - Todo.rdoc
77
+ has_rdoc: true
78
+ homepage: http://github.com/visionmedia/bind
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --line-numbers
84
+ - --inline-source
85
+ - --title
86
+ - Bind
87
+ - --main
88
+ - README.rdoc
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "1.2"
102
+ version:
103
+ requirements: []
104
+
105
+ rubyforge_project: bind
106
+ rubygems_version: 1.3.5
107
+ signing_key:
108
+ specification_version: 2
109
+ summary: bind actions to filesystem events
110
+ test_files: []
111
+