coyote 0.7.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Manifest +13 -31
  2. data/README.md +1 -91
  3. data/Rakefile +8 -4
  4. data/bin/coyote +9 -32
  5. data/coyote.gemspec +4 -10
  6. data/lib/coyote.rb +28 -62
  7. data/lib/coyote/asset.rb +51 -0
  8. data/lib/coyote/assets/coffeescript.rb +29 -0
  9. data/lib/coyote/assets/javascript.rb +4 -0
  10. data/lib/coyote/bundle.rb +101 -0
  11. data/lib/coyote/closure_compiler.rb +9 -9
  12. data/lib/coyote/configuration.rb +23 -77
  13. data/lib/coyote/notifications.rb +22 -0
  14. data/test/scripts/input1.js +1 -0
  15. data/test/scripts/input2.js +1 -0
  16. data/test/scripts/input3.js +1 -0
  17. data/test/scripts/input4.js +1 -0
  18. data/test/scripts/lib/input5.coffee +3 -0
  19. data/test/scripts/lib/input6.js +1 -0
  20. data/test/scripts/lib/keystone/input7.js +2 -0
  21. data/test/scripts/vendor/input8.coffee +1 -0
  22. metadata +29 -70
  23. data/config/coyote-icon.png +0 -0
  24. data/config/coyote-usage.txt +0 -16
  25. data/config/coyote.yaml +0 -2
  26. data/lib/coyote/generator.rb +0 -49
  27. data/lib/coyote/notification.rb +0 -62
  28. data/lib/coyote/script.rb +0 -124
  29. data/lib/coyote/scripts/coffeescript.rb +0 -32
  30. data/lib/coyote/scripts/combine.rb +0 -54
  31. data/lib/coyote/scripts/javascript.rb +0 -4
  32. data/test/src/public/assets/javascripts/app/application/interface.coffee +0 -10
  33. data/test/src/public/assets/javascripts/app/application/main.coffee +0 -14
  34. data/test/src/public/assets/javascripts/app/application/pages/home.coffee +0 -9
  35. data/test/src/public/assets/javascripts/app/boot.coffee +0 -1
  36. data/test/src/public/assets/javascripts/lib/extensions.coffee +0 -8
  37. data/test/src/public/assets/javascripts/lib/imulus.coffee +0 -7
  38. data/test/src/public/assets/javascripts/lib/imulus/forms.coffee +0 -46
  39. data/test/src/public/assets/javascripts/lib/imulus/maps/infowindow.coffee +0 -37
  40. data/test/src/public/assets/javascripts/lib/imulus/maps/map.coffee +0 -51
  41. data/test/src/public/assets/javascripts/lib/imulus/maps/marker.coffee +0 -66
  42. data/test/src/public/assets/javascripts/lib/imulus/maps/point.coffee +0 -5
  43. data/test/src/public/assets/javascripts/lib/imulus/maps/results.coffee +0 -117
  44. data/test/src/public/assets/javascripts/lib/imulus/tables.coffee +0 -11
  45. data/test/src/public/assets/javascripts/lib/imulus/triggers.coffee +0 -26
  46. data/test/src/public/assets/javascripts/scripts.coffee +0 -14
  47. data/test/src/public/assets/javascripts/vendor/jquery.js +0 -18
  48. data/test/src/public/assets/javascripts/vendor/jquery/jquery.cookie.js +0 -89
  49. data/test/src/public/assets/javascripts/vendor/jquery/jquery.cycle.js +0 -21
  50. data/test/src/public/assets/javascripts/vendor/jquery/jquery.query.js +0 -224
  51. data/test/src/public/assets/javascripts/vendor/swfobject.js +0 -4
  52. data/test/src/public/scripts/scripts.combine +0 -18
  53. data/test/src/public/scripts/scripts.js +0 -944
data/Manifest CHANGED
@@ -1,11 +1,12 @@
1
1
  README.md
2
2
  Rakefile
3
3
  bin/coyote
4
- config/coyote-icon.png
5
- config/coyote-usage.txt
6
- config/coyote.yaml
7
4
  coyote.gemspec
8
5
  lib/coyote.rb
6
+ lib/coyote/asset.rb
7
+ lib/coyote/assets/coffeescript.rb
8
+ lib/coyote/assets/javascript.rb
9
+ lib/coyote/bundle.rb
9
10
  lib/coyote/closure_compiler.rb
10
11
  lib/coyote/configuration.rb
11
12
  lib/coyote/fs_listener.rb
@@ -13,32 +14,13 @@ lib/coyote/fs_listeners/darwin.rb
13
14
  lib/coyote/fs_listeners/linux.rb
14
15
  lib/coyote/fs_listeners/polling.rb
15
16
  lib/coyote/fs_listeners/windows.rb
16
- lib/coyote/generator.rb
17
- lib/coyote/notification.rb
18
- lib/coyote/script.rb
19
- lib/coyote/scripts/coffeescript.rb
20
- lib/coyote/scripts/combine.rb
21
- lib/coyote/scripts/javascript.rb
22
- test/src/public/assets/javascripts/app/application/interface.coffee
23
- test/src/public/assets/javascripts/app/application/main.coffee
24
- test/src/public/assets/javascripts/app/application/pages/home.coffee
25
- test/src/public/assets/javascripts/app/boot.coffee
26
- test/src/public/assets/javascripts/lib/extensions.coffee
27
- test/src/public/assets/javascripts/lib/imulus.coffee
28
- test/src/public/assets/javascripts/lib/imulus/forms.coffee
29
- test/src/public/assets/javascripts/lib/imulus/maps/infowindow.coffee
30
- test/src/public/assets/javascripts/lib/imulus/maps/map.coffee
31
- test/src/public/assets/javascripts/lib/imulus/maps/marker.coffee
32
- test/src/public/assets/javascripts/lib/imulus/maps/point.coffee
33
- test/src/public/assets/javascripts/lib/imulus/maps/results.coffee
34
- test/src/public/assets/javascripts/lib/imulus/tables.coffee
35
- test/src/public/assets/javascripts/lib/imulus/triggers.coffee
36
- test/src/public/assets/javascripts/scripts.coffee
37
- test/src/public/assets/javascripts/vendor/jquery.js
38
- test/src/public/assets/javascripts/vendor/jquery/jquery.cookie.js
39
- test/src/public/assets/javascripts/vendor/jquery/jquery.cycle.js
40
- test/src/public/assets/javascripts/vendor/jquery/jquery.query.js
41
- test/src/public/assets/javascripts/vendor/swfobject.js
42
- test/src/public/scripts/scripts.combine
43
- test/src/public/scripts/scripts.js
17
+ lib/coyote/notifications.rb
18
+ test/scripts/input1.js
19
+ test/scripts/input2.js
20
+ test/scripts/input3.js
21
+ test/scripts/input4.js
22
+ test/scripts/lib/input5.coffee
23
+ test/scripts/lib/input6.js
24
+ test/scripts/lib/keystone/input7.js
25
+ test/scripts/vendor/input8.coffee
44
26
  Manifest
data/README.md CHANGED
@@ -1,94 +1,4 @@
1
1
  COYOTE
2
2
  =============
3
3
 
4
- An intelligent command-line tool for combining, compressing and compiling your JavaScript and CoffeeScript files.
5
-
6
- Coyote selectively concatenates your files, combining them into a single file with the option of running the output through the Google Closure Compiler before save. It can be used to observe your source files for changes and will recompile and save on the fly for easy development.
7
-
8
- Coyote automatically compiles CoffeeScript files (bare, with no safety closure) before combining them with other source files. You can freely combine JavaScript and CoffeeScript source files in your compilation.
9
-
10
-
11
- Installation
12
- ------
13
- $ gem install coyote
14
-
15
- Requirements
16
- ------
17
- - Compiling CoffeeScript files requires that you have nodejs and coffee-script installed
18
- - Growl notifications require that you have Growl installed
19
-
20
- Terminal Usage
21
- ------
22
-
23
- **Configuration**
24
-
25
- $ cd myproject/scripts
26
- $ coyote new
27
-
28
- *This will create the configuration file (coyote.yaml) and will discover any .js and .coffee files in this directory, automatically adding them to the configuration. Open coyote.yaml and modify the input and output configurations to meet your needs. Coyote will combine the input files in the order you define.*
29
-
30
- **Trigger a build**
31
-
32
- $ coyote build
33
-
34
- **Trigger the observer**
35
-
36
- $ coyote watch
37
-
38
- **Input wildcards**
39
-
40
- You can wildcard your input parameters to find files.
41
-
42
- - **/*.js # recursively find all files with the extension '.js'
43
- - /jquery/plugins/*.js # find all .js files in the directory
44
-
45
-
46
- **Dependency discovery**
47
-
48
- If your files depend on other files or libraries to run, you can define those dependencies so Coyote will include them in the compiled output before the files that require them.
49
-
50
- //= require /jquery/jquery.js
51
- #= require /jquery/jquery.js (in CoffeeScript)
52
-
53
- or simply
54
-
55
- //= require jquery
56
- #= require jquery (in CoffeeScript)
57
-
58
- Dependencies are relative to the top level of your directory, likely where your coyote.yaml config file is located.
59
-
60
-
61
- Options
62
- -------
63
- **Compress output with Google Closure Compiler**
64
-
65
- $ coyote build -c
66
- $ coyote build --compress
67
-
68
- or
69
-
70
- $ coyote watch -c
71
- $ coyote watch --compress
72
-
73
- License
74
- -------
75
-
76
- Copyright (C) 2011 by Imulus
77
-
78
- Permission is hereby granted, free of charge, to any person obtaining a copy
79
- of this software and associated documentation files (the "Software"), to deal
80
- in the Software without restriction, including without limitation the rights
81
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
82
- copies of the Software, and to permit persons to whom the Software is
83
- furnished to do so, subject to the following conditions:
84
-
85
- The above copyright notice and this permission notice shall be included in
86
- all copies or substantial portions of the Software.
87
-
88
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
89
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
90
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
91
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
92
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
93
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
94
- THE SOFTWARE.
4
+ TODO: documentation
data/Rakefile CHANGED
@@ -6,21 +6,19 @@ require 'echoe'
6
6
  $: << File.expand_path(File.dirname(__FILE__) + "/lib")
7
7
  require 'coyote'
8
8
 
9
- Echoe.new(Coyote::APP_NAME.downcase, Coyote::VERSION) do |p|
9
+ Echoe.new('coyote', Coyote::VERSION) do |p|
10
10
  p.description = "An intelligent command-line tool for combining, compressing and compiling your JavaScript and CoffeeScript files."
11
11
  p.summary = "Coyote selectively concatenates your files, combining them into a single file with the option of running the output through the Google Closure Compiler before save. It can be used to observe your source files for changes and will recompile and save on the fly for easy development."
12
-
13
12
  p.url = "http://github.com/imulus/coyote"
14
13
  p.author = "Imulus"
15
14
  p.email = "developer@imulus.com"
16
- p.ignore_pattern = ["tmp/*", "script/*", "test/*", "assets/*"]
15
+ p.ignore_pattern = ["tmp/*", "test/*"]
17
16
 
18
17
  dependencies = Array.new
19
18
  target_os = Config::CONFIG['target_os']
20
19
 
21
20
  if target_os =~ /darwin/i
22
21
  dependencies << "rb-fsevent >=0.4.0"
23
- dependencies << "rb-appscript >=0.6.1"
24
22
  dependencies << "term-ansicolor >=1.0.5"
25
23
  elsif target_os =~ /linux/i
26
24
  dependencies << "rb-inotify >=0.8.4"
@@ -30,4 +28,10 @@ Echoe.new(Coyote::APP_NAME.downcase, Coyote::VERSION) do |p|
30
28
 
31
29
  p.development_dependencies = dependencies
32
30
  p.runtime_dependencies = dependencies
31
+ end
32
+
33
+ task :build do
34
+ `rake manifest`
35
+ `rake build_gemspec`
36
+ `gem build coyote.gemspec`
33
37
  end
data/bin/coyote CHANGED
@@ -1,46 +1,23 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  $: << File.expand_path(File.dirname(__FILE__) + "/../lib")
4
- require 'fileutils'
5
4
  require 'rubygems'
5
+ require 'fileutils'
6
6
  require 'optparse'
7
7
  require 'coyote'
8
8
 
9
9
 
10
- @options = {}
10
+ options = {}
11
11
  OptionParser.new do |opts|
12
- opts.on("-c", "--compress", "Compress") do |option|
13
- @options['compress'] = option
14
- end
15
- opts.on("-v", "--verbose", "Verbose") do |option|
16
- @options['verbose'] = option
12
+ Coyote::options.each do |name|
13
+ opts.on("-#{name[0]}", "--#{name}", "#{name.capitalize}") { |o| options[name.to_sym] = o }
17
14
  end
18
15
  end.parse!
19
16
 
17
+ input, output = ARGV[0].split(':', 2)
20
18
 
21
- def config
22
- config = Coyote::Configuration.new @options
23
- ARGV.shift
24
-
25
- if ARGV.empty?
26
- config.load_from_yaml!
27
- else
28
- input, output = ARGV[0].split(':', 2)
29
- config.inputs = input
30
- config.output = output
31
- end
32
-
33
- return config
34
- end
35
-
36
-
37
- case ARGV.first
38
- when 'new'
39
- Coyote::generate
40
- when 'build'
41
- Coyote::build config
42
- when 'watch'
43
- Coyote::watch config
44
- else
45
- Coyote::usage
19
+ coyote :build do |config|
20
+ config.input = input
21
+ config.output = output
22
+ config.options = options
46
23
  end
data/coyote.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{coyote}
5
- s.version = "0.7.0"
5
+ s.version = "1.0.0.beta1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Imulus"]
9
- s.date = %q{2012-01-18}
9
+ s.date = %q{2012-02-13}
10
10
  s.default_executable = %q{coyote}
11
11
  s.description = %q{An intelligent command-line tool for combining, compressing and compiling your JavaScript and CoffeeScript files.}
12
12
  s.email = %q{developer@imulus.com}
13
13
  s.executables = ["coyote"]
14
- s.extra_rdoc_files = ["README.md", "bin/coyote", "lib/coyote.rb", "lib/coyote/closure_compiler.rb", "lib/coyote/configuration.rb", "lib/coyote/fs_listener.rb", "lib/coyote/fs_listeners/darwin.rb", "lib/coyote/fs_listeners/linux.rb", "lib/coyote/fs_listeners/polling.rb", "lib/coyote/fs_listeners/windows.rb", "lib/coyote/generator.rb", "lib/coyote/notification.rb", "lib/coyote/script.rb", "lib/coyote/scripts/coffeescript.rb", "lib/coyote/scripts/combine.rb", "lib/coyote/scripts/javascript.rb"]
15
- s.files = ["README.md", "Rakefile", "bin/coyote", "config/coyote-icon.png", "config/coyote-usage.txt", "config/coyote.yaml", "coyote.gemspec", "lib/coyote.rb", "lib/coyote/closure_compiler.rb", "lib/coyote/configuration.rb", "lib/coyote/fs_listener.rb", "lib/coyote/fs_listeners/darwin.rb", "lib/coyote/fs_listeners/linux.rb", "lib/coyote/fs_listeners/polling.rb", "lib/coyote/fs_listeners/windows.rb", "lib/coyote/generator.rb", "lib/coyote/notification.rb", "lib/coyote/script.rb", "lib/coyote/scripts/coffeescript.rb", "lib/coyote/scripts/combine.rb", "lib/coyote/scripts/javascript.rb", "test/src/public/assets/javascripts/app/application/interface.coffee", "test/src/public/assets/javascripts/app/application/main.coffee", "test/src/public/assets/javascripts/app/application/pages/home.coffee", "test/src/public/assets/javascripts/app/boot.coffee", "test/src/public/assets/javascripts/lib/extensions.coffee", "test/src/public/assets/javascripts/lib/imulus.coffee", "test/src/public/assets/javascripts/lib/imulus/forms.coffee", "test/src/public/assets/javascripts/lib/imulus/maps/infowindow.coffee", "test/src/public/assets/javascripts/lib/imulus/maps/map.coffee", "test/src/public/assets/javascripts/lib/imulus/maps/marker.coffee", "test/src/public/assets/javascripts/lib/imulus/maps/point.coffee", "test/src/public/assets/javascripts/lib/imulus/maps/results.coffee", "test/src/public/assets/javascripts/lib/imulus/tables.coffee", "test/src/public/assets/javascripts/lib/imulus/triggers.coffee", "test/src/public/assets/javascripts/scripts.coffee", "test/src/public/assets/javascripts/vendor/jquery.js", "test/src/public/assets/javascripts/vendor/jquery/jquery.cookie.js", "test/src/public/assets/javascripts/vendor/jquery/jquery.cycle.js", "test/src/public/assets/javascripts/vendor/jquery/jquery.query.js", "test/src/public/assets/javascripts/vendor/swfobject.js", "test/src/public/scripts/scripts.combine", "test/src/public/scripts/scripts.js", "Manifest"]
14
+ s.extra_rdoc_files = ["README.md", "bin/coyote", "lib/coyote.rb", "lib/coyote/asset.rb", "lib/coyote/assets/coffeescript.rb", "lib/coyote/assets/javascript.rb", "lib/coyote/bundle.rb", "lib/coyote/closure_compiler.rb", "lib/coyote/configuration.rb", "lib/coyote/fs_listener.rb", "lib/coyote/fs_listeners/darwin.rb", "lib/coyote/fs_listeners/linux.rb", "lib/coyote/fs_listeners/polling.rb", "lib/coyote/fs_listeners/windows.rb", "lib/coyote/notifications.rb"]
15
+ s.files = ["README.md", "Rakefile", "bin/coyote", "coyote.gemspec", "lib/coyote.rb", "lib/coyote/asset.rb", "lib/coyote/assets/coffeescript.rb", "lib/coyote/assets/javascript.rb", "lib/coyote/bundle.rb", "lib/coyote/closure_compiler.rb", "lib/coyote/configuration.rb", "lib/coyote/fs_listener.rb", "lib/coyote/fs_listeners/darwin.rb", "lib/coyote/fs_listeners/linux.rb", "lib/coyote/fs_listeners/polling.rb", "lib/coyote/fs_listeners/windows.rb", "lib/coyote/notifications.rb", "test/scripts/input1.js", "test/scripts/input2.js", "test/scripts/input3.js", "test/scripts/input4.js", "test/scripts/lib/input5.coffee", "test/scripts/lib/input6.js", "test/scripts/lib/keystone/input7.js", "test/scripts/vendor/input8.coffee", "Manifest"]
16
16
  s.homepage = %q{http://github.com/imulus/coyote}
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Coyote", "--main", "README.md"]
18
18
  s.require_paths = ["lib"]
@@ -25,25 +25,19 @@ Gem::Specification.new do |s|
25
25
 
26
26
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
27
  s.add_runtime_dependency(%q<rb-fsevent>, [">= 0.4.0"])
28
- s.add_runtime_dependency(%q<rb-appscript>, [">= 0.6.1"])
29
28
  s.add_runtime_dependency(%q<term-ansicolor>, [">= 1.0.5"])
30
29
  s.add_development_dependency(%q<rb-fsevent>, [">= 0.4.0"])
31
- s.add_development_dependency(%q<rb-appscript>, [">= 0.6.1"])
32
30
  s.add_development_dependency(%q<term-ansicolor>, [">= 1.0.5"])
33
31
  else
34
32
  s.add_dependency(%q<rb-fsevent>, [">= 0.4.0"])
35
- s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
36
33
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
37
34
  s.add_dependency(%q<rb-fsevent>, [">= 0.4.0"])
38
- s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
39
35
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
40
36
  end
41
37
  else
42
38
  s.add_dependency(%q<rb-fsevent>, [">= 0.4.0"])
43
- s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
44
39
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
45
40
  s.add_dependency(%q<rb-fsevent>, [">= 0.4.0"])
46
- s.add_dependency(%q<rb-appscript>, [">= 0.6.1"])
47
41
  s.add_dependency(%q<term-ansicolor>, [">= 1.0.5"])
48
42
  end
49
43
  end
data/lib/coyote.rb CHANGED
@@ -1,83 +1,49 @@
1
- require 'yaml'
2
- require 'term/ansicolor'
3
- require 'coyote/script'
4
1
  require 'coyote/configuration'
2
+ require 'coyote/bundle'
5
3
  require 'coyote/fs_listener'
6
- require 'coyote/generator'
7
- require 'coyote/closure_compiler'
8
- require 'coyote/notification'
4
+ require 'coyote/notifications'
5
+ include Coyote::Notifications
9
6
 
10
- include Term::ANSIColor
11
7
 
12
8
  module Coyote
13
- APP_NAME = "Coyote"
14
- VERSION = "0.7.0"
15
- ROOT_PATH = Dir.pwd
16
- CONFIG_PATH = File.expand_path(File.dirname(__FILE__) + "/../config")
17
- CONFIG_FILENAME = "coyote.yaml"
18
- CONFIG_ICON = "coyote-icon.png"
19
- USAGE_FILENAME = "coyote-usage.txt"
20
-
21
- module Defaults
22
- OUTPUT = "coyote.js"
9
+
10
+ VERSION = '1.0.0.beta1'
11
+
12
+ def self.run(input_path, output_path, options = {})
13
+ @@input_path = input_path
14
+ @@output_path = output_path
15
+ @@options = options
16
+ bundle = Coyote::Bundle.new(input_path, output_path)
17
+ build bundle
18
+ watch bundle if @@options[:watch]
23
19
  end
24
20
 
25
- def self.generate
26
- Coyote::Generator.new.generate
21
+ def self.options
22
+ ['compress', 'watch', 'quiet']
27
23
  end
28
24
 
29
-
30
-
31
-
32
- def self.build(config)
33
- if config.inputs == config.output
34
- Coyote::Notification.new "Input path cannot be the same as output path\n\n", "Failure"
35
- exit 0
36
- end
37
-
38
- output = Coyote::Script.select_and_init(config.output)
39
- output.empty!
40
-
41
- config.inputs.each do |file, input|
42
- output.append input.contents
43
- print "+ Added #{file}\n" if config.options['verbose']
44
- end
45
-
46
- output.compress! if config.should_compress?
47
- output.save
48
- Coyote::Notification.new "Saved #{config.output}\n\n", "success"
25
+ def self.build(bundle)
26
+ notify bundle.manifest unless @@options[:quiet]
27
+ bundle.compress! if @@options[:compress]
28
+ bundle.save
29
+ notify "#{Time.new.strftime("%I:%M:%S")} Saved bundle to #{@@output_path} [#{bundle.files.length} files]", :success
49
30
  end
50
31
 
51
32
 
52
- def self.watch(config)
53
- self.build config
54
-
33
+ def self.watch(bundle)
55
34
  listener = Coyote::FSListener.select_and_init
56
35
 
57
- inputs = config.inputs.values.collect do |script|
58
- script.relative_path
59
- end
36
+ listener.on_change do |changed_files|
37
+ changed_files = bundle.files & changed_files
60
38
 
61
- listener.on_change do |files|
62
- if files.include? config.source
63
- Coyote::Notification.new "Config file (#{config.source}) changed. Reading it in.\n", "warning"
64
- config.load_from_yaml! config.source
65
- self.build config
66
- else
67
- changed_watched_files = inputs & files
68
- if changed_watched_files.length > 0
69
- self.build config
70
- end
39
+ if changed_files.length > 0
40
+ notify "#{Time.new.strftime("%I:%M:%S")} Detected change, recompiling...", :warning
41
+ bundle.update! changed_files
42
+ build bundle
71
43
  end
72
44
  end
73
45
 
46
+ notify "Watching for changes to your bundle. CTRL+C to stop."
74
47
  listener.start
75
48
  end
76
-
77
-
78
- def self.usage
79
- file = File.open("#{Coyote::CONFIG_PATH}/#{Coyote::USAGE_FILENAME}", 'r')
80
- puts file.read
81
- file.close
82
- end
83
49
  end
@@ -0,0 +1,51 @@
1
+ module Coyote
2
+ autoload :JavaScript, 'coyote/assets/javascript'
3
+ autoload :CoffeeScript, 'coyote/assets/coffeescript'
4
+
5
+ class Asset
6
+
7
+ attr_reader :relative_path, :absolute_path, :relative_directory, :absolute_directory, :dependencies
8
+ attr_accessor :contents
9
+
10
+ # Determine the type of file based on the file extension
11
+ # and return an instance of the proper asset class
12
+ def self.select_and_init(path)
13
+ case File.extname(path)
14
+ when /\.js/i ; JavaScript.new(path)
15
+ when /\.coffee/i ; CoffeeScript.new(path)
16
+ else ; self.new(path)
17
+ end
18
+ end
19
+
20
+
21
+ def initialize(relative_path)
22
+ @relative_path = File.expand_path(relative_path).gsub("#{Dir.pwd}/", '')
23
+ @absolute_path = File.expand_path(@relative_path)
24
+ @relative_directory = File.dirname(@relative_path)
25
+ @absolute_directory = File.expand_path("#{Dir.pwd}/#{@relative_directory}")
26
+ update!
27
+ end
28
+
29
+
30
+ def update!
31
+ @contents = File.exists?(@absolute_path) ? File.open(@absolute_path, 'r').read : ""
32
+ find_dependencies
33
+ end
34
+
35
+
36
+ protected
37
+
38
+ # Defines the regex pattern for scanning the contents of the
39
+ # file to look for require directives
40
+ def require_pattern
41
+ Regexp.new(/\/\/=\s*require\s*(.*)$/i) # '//= require a/b/c.js' => 'a/b/c.js'
42
+ end
43
+
44
+ def find_dependencies
45
+ matches = @contents.scan(require_pattern)
46
+ @dependencies = matches.reverse.collect { |match| "#{@relative_directory}/#{match.last.strip}" }
47
+ end
48
+
49
+
50
+ end
51
+ end