coyote 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/coyote.gemspec +1 -1
- data/lib/coyote.rb +19 -13
- data/lib/coyote/asset.rb +5 -1
- data/lib/coyote/bundle.rb +32 -7
- metadata +9 -9
data/coyote.gemspec
CHANGED
data/lib/coyote.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'benchmark'
|
1
2
|
require 'fileutils'
|
2
3
|
require 'coyote/bundle'
|
3
4
|
require 'coyote/fs_listener'
|
@@ -6,39 +7,44 @@ include Coyote::Notifications
|
|
6
7
|
|
7
8
|
module Coyote
|
8
9
|
|
9
|
-
VERSION = '1.0.
|
10
|
+
VERSION = '1.0.3'
|
10
11
|
|
11
12
|
def self.run(input_path, output_path, options = {})
|
12
13
|
@@input_path = input_path
|
13
14
|
@@output_path = output_path
|
14
15
|
@@options = options
|
15
|
-
bundle
|
16
|
-
build bundle
|
17
|
-
watch
|
16
|
+
@@bundle = Coyote::Bundle.new(input_path, output_path)
|
17
|
+
build { |bundle| bundle.update! }
|
18
|
+
watch if @@options[:watch]
|
18
19
|
end
|
19
20
|
|
21
|
+
|
20
22
|
def self.options
|
21
23
|
['compress', 'watch', 'quiet', 'version']
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
|
27
|
+
def self.build(&block)
|
28
|
+
time = Benchmark.realtime do
|
29
|
+
yield @@bundle unless block.nil?
|
30
|
+
notify @@bundle.manifest unless @@options[:quiet]
|
31
|
+
@@bundle.compress! if @@options[:compress]
|
32
|
+
@@bundle.save
|
33
|
+
end
|
34
|
+
|
35
|
+
notify "#{Time.new.strftime("%I:%M:%S")} Saved bundle to #{@@output_path} [#{@@bundle.files.length} files in #{(time).round(5)}s]", :success
|
29
36
|
end
|
30
37
|
|
31
38
|
|
32
|
-
def self.watch
|
39
|
+
def self.watch
|
33
40
|
listener = Coyote::FSListener.select_and_init
|
34
41
|
|
35
42
|
listener.on_change do |changed_files|
|
36
|
-
changed_files = bundle.files & changed_files
|
43
|
+
changed_files = @@bundle.files & changed_files
|
37
44
|
|
38
45
|
if changed_files.length > 0
|
39
46
|
notify "#{Time.new.strftime("%I:%M:%S")} Detected change, recompiling...", :warning
|
40
|
-
bundle.update! changed_files
|
41
|
-
build bundle
|
47
|
+
build { |bundle| bundle.update! changed_files }
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
data/lib/coyote/asset.rb
CHANGED
@@ -31,7 +31,10 @@ module Coyote
|
|
31
31
|
@contents = File.exists?(@absolute_path) ? File.open(@absolute_path, 'r').read : ""
|
32
32
|
find_dependencies
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
|
+
def dependencies_have_changed?
|
36
|
+
@last_dependencies != @dependencies
|
37
|
+
end
|
35
38
|
|
36
39
|
protected
|
37
40
|
|
@@ -42,6 +45,7 @@ module Coyote
|
|
42
45
|
end
|
43
46
|
|
44
47
|
def find_dependencies
|
48
|
+
@last_dependencies = @dependencies
|
45
49
|
matches = @contents.scan(require_pattern)
|
46
50
|
@dependencies = matches.reverse.collect { |match| "#{@relative_directory}/#{match.last.strip}" }
|
47
51
|
end
|
data/lib/coyote/bundle.rb
CHANGED
@@ -8,11 +8,9 @@ module Coyote
|
|
8
8
|
attr_reader :contents
|
9
9
|
|
10
10
|
def initialize(entry_point, output_path)
|
11
|
+
@entry_point = entry_point
|
11
12
|
@output_path = output_path
|
12
|
-
|
13
|
-
@contents = ""
|
14
|
-
add entry_point
|
15
|
-
update!
|
13
|
+
build
|
16
14
|
end
|
17
15
|
|
18
16
|
|
@@ -35,15 +33,42 @@ module Coyote
|
|
35
33
|
|
36
34
|
|
37
35
|
def update!(changed_files = [])
|
38
|
-
|
36
|
+
bundle_should_rebuild = false
|
39
37
|
|
40
38
|
unless changed_files.empty?
|
41
39
|
changed_files.each do |path|
|
42
|
-
@assets["#{Dir.pwd}/#{path}"]
|
40
|
+
asset = @assets["#{Dir.pwd}/#{path}"]
|
41
|
+
asset.update!
|
42
|
+
if asset.dependencies_have_changed?
|
43
|
+
bundle_should_rebuild = true
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
45
47
|
|
46
|
-
|
48
|
+
if bundle_should_rebuild
|
49
|
+
notify "#{Time.new.strftime("%I:%M:%S")} Dependencies have changed. Refreshing bundle and recompiling...", :failure
|
50
|
+
build
|
51
|
+
else
|
52
|
+
refresh
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def refresh
|
58
|
+
@contents = ""
|
59
|
+
files(true).each { |path| @contents += "#{@assets[path].contents} \n\n" }
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def build
|
64
|
+
empty!
|
65
|
+
add @entry_point
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
def empty!
|
70
|
+
@assets = {}
|
71
|
+
@contents = ""
|
47
72
|
end
|
48
73
|
|
49
74
|
|
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.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-16 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-fsevent
|
16
|
-
requirement: &
|
16
|
+
requirement: &2168553680 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2168553680
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: term-ansicolor
|
27
|
-
requirement: &
|
27
|
+
requirement: &2168552860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.0.5
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2168552860
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rb-fsevent
|
38
|
-
requirement: &
|
38
|
+
requirement: &2168552160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.4.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2168552160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: term-ansicolor
|
49
|
-
requirement: &
|
49
|
+
requirement: &2168551280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.0.5
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2168551280
|
58
58
|
description: An intelligent command-line tool for combining, compressing and compiling
|
59
59
|
your JavaScript and CoffeeScript files.
|
60
60
|
email: developer@imulus.com
|