coyote 1.2.0.rc2 → 1.2.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  output.js
2
3
  output.css
3
4
  .DS_Store
@@ -5,7 +6,3 @@ test
5
6
  coverage
6
7
  Gemfile.lock
7
8
 
8
- /pkg/*
9
- Manifest
10
- *.gemspec
11
- *.gem
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "coyote"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "coyote"
7
+ s.version = Coyote::VERSION
8
+ s.authors = ["Imulus","Casey O'Hara"]
9
+ s.email = ["developer@imulus.com","casey.ohara@imulus.com"]
10
+ s.homepage = "http://github.com/imulus/coyote"
11
+ s.summary = "Coyote combines your source files into a single script or stylesheet to reduce HTTP overhead and make development easier. It has built-in support for Sprockets-style dependency syntax (`#= require x`) and a lightning-fast, built-in watch mechanism to detect changes to your source files and recompile on the fly. For increased optimization, you can optionally run the final compilation through the Google Closure Compiler before save."
12
+ s.description = "A speedy tool for combining and compressing your JavaScript, CoffeeScript, CSS and LESS source files."
13
+
14
+ s.rubyforge_project = "coyote"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_runtime_dependency(%q<rb-fsevent>, [">= 0.4.0"])
23
+ s.add_runtime_dependency(%q<colored>, [">= 1.2"])
24
+ s.add_development_dependency(%q<rb-fsevent>, [">= 0.4.0"])
25
+ s.add_development_dependency(%q<colored>, [">= 1.2"])
26
+ end
@@ -20,9 +20,14 @@ module Coyote::Assets
20
20
  end
21
21
 
22
22
  def find_dependencies
23
+ @last_dependencies = @dependencies
23
24
  matches = self.contents.scan self.class.require_pattern
24
25
  @dependencies = matches.reverse.map { |match| match.last.strip }
25
26
  end
27
+
28
+ def dependencies_have_changed?
29
+ @last_dependencies != @dependencies
30
+ end
26
31
 
27
32
  def update!
28
33
  self.contents = IO.read(@path)
@@ -82,20 +82,32 @@ module Coyote::Bundles
82
82
 
83
83
  def update!(changed_files=[])
84
84
  reset!
85
- changed_files.each { |path| assets[path].update! }
85
+ changed_files.each do |path|
86
+ asset = assets[path]
87
+ asset.update!
88
+ rebuild! and return if asset.dependencies_have_changed?
89
+ end
86
90
  end
87
91
 
88
92
 
89
93
  def manifest
90
94
  files.reverse.map { |path| "+ #{path}" }.join("\n")
91
- end
95
+ end
92
96
 
93
97
 
94
98
  def reset!
95
99
  @contents = nil
96
100
  end
97
-
98
-
101
+
102
+
103
+ def rebuild!
104
+ notify "Dependencies have changed. Refreshing bundle and recompiling...", :timestamp, :warning
105
+ entry_point = files.first
106
+ empty!
107
+ add entry_point
108
+ end
109
+
110
+
99
111
  def save!
100
112
  File.open target, 'w+' do |file|
101
113
  file.write contents
@@ -1,5 +1,7 @@
1
1
  require 'coyote/bundles'
2
2
  require 'coyote/fs_listeners'
3
+ require 'benchmark'
4
+
3
5
 
4
6
  module Coyote
5
7
  class Compiler
@@ -20,9 +22,12 @@ module Coyote
20
22
 
21
23
  def save!
22
24
  notify "\n" + @bundle.manifest unless @options.fetch(:quiet, false)
23
- @bundle.compress! if @options.fetch(:compress, false)
24
- @bundle.save!
25
- notify "Saved bundle to #{@output} [#{@bundle.files.length} files]", :timestamp, :success
25
+ time = Benchmark.realtime do
26
+ @bundle.compress! if @options.fetch(:compress, false)
27
+ @bundle.save!
28
+ end
29
+
30
+ notify "Saved bundle to #{@output} [#{@bundle.files.length} files] [#{'%.4f' % time} sec]", :timestamp, :success
26
31
  end
27
32
 
28
33
 
@@ -1,3 +1,3 @@
1
1
  module Coyote
2
- VERSION = "1.2.0.rc2"
2
+ VERSION = "1.2.0.rc3"
3
3
  end
@@ -85,13 +85,10 @@ module Coyote::Bundles
85
85
 
86
86
  context "#update!" do
87
87
  it "tells the changed files's assets to update" do
88
- input1 = "spec/assets/bundles/base/script1.js"
89
- input2 = "spec/assets/bundles/base/script2.js"
90
- bundle.add(input1)
91
- bundle.add(input2)
92
- bundle.assets[File.expand_path(input1)].should_receive(:update!)
93
- bundle.assets[File.expand_path(input2)].should_receive(:update!)
94
- bundle.update!([File.expand_path(input1),File.expand_path(input2)])
88
+ input = "spec/assets/bundles/base/script1.js"
89
+ bundle.add(input)
90
+ bundle.assets[File.expand_path(input)].should_receive(:update!)
91
+ bundle.update!([File.expand_path(input)])
95
92
  end
96
93
 
97
94
  it "resets the cache" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coyote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.rc2
4
+ version: 1.2.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-11 00:00:00.000000000Z
13
+ date: 2012-06-20 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rb-fsevent
17
- requirement: &2165746400 !ruby/object:Gem::Requirement
17
+ requirement: &2162766400 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.4.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2165746400
25
+ version_requirements: *2162766400
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: colored
28
- requirement: &2165745880 !ruby/object:Gem::Requirement
28
+ requirement: &2162750260 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '1.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2165745880
36
+ version_requirements: *2162750260
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rb-fsevent
39
- requirement: &2165745400 !ruby/object:Gem::Requirement
39
+ requirement: &2162749740 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 0.4.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2165745400
47
+ version_requirements: *2162749740
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: colored
50
- requirement: &2165744900 !ruby/object:Gem::Requirement
50
+ requirement: &2162749160 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '1.2'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2165744900
58
+ version_requirements: *2162749160
59
59
  description: A speedy tool for combining and compressing your JavaScript, CoffeeScript,
60
60
  CSS and LESS source files.
61
61
  email:
@@ -74,6 +74,7 @@ files:
74
74
  - README.md
75
75
  - Rakefile
76
76
  - bin/coyote
77
+ - coyote.gemspec
77
78
  - lib/coyote.rb
78
79
  - lib/coyote/assets.rb
79
80
  - lib/coyote/assets/base.rb