asset_watcher 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/asset_watcher.gemspec +3 -3
- data/lib/asset_watcher.rb +5 -19
- data/lib/asset_watcher/tasks/watch.rake +0 -8
- data/spec/asset_watcher_spec.rb +2 -2
- metadata +5 -5
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.summary = %Q{watch and auto-compile .coffee and .haml files}
|
19
19
|
gem.description = %Q{watch and auto-compile .coffee and .haml files. Need node.js and coffee-script to compile .coffee file and haml to compile .haml.}
|
20
20
|
gem.email = "t.yamada.996@gmail.com"
|
21
|
-
gem.authors = ["
|
21
|
+
gem.authors = ["Tomohiro Yamada"]
|
22
22
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
23
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
24
|
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/asset_watcher.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{asset_watcher}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = ["Tomohiro Yamada"]
|
12
|
+
s.date = %q{2011-01-21}
|
13
13
|
s.description = %q{watch and auto-compile .coffee and .haml files. Need node.js and coffee-script to compile .coffee file and haml to compile .haml.}
|
14
14
|
s.email = %q{t.yamada.996@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/asset_watcher.rb
CHANGED
@@ -3,7 +3,6 @@ require "coffee-haml-filter"
|
|
3
3
|
require "active_support/core_ext/object/blank"
|
4
4
|
require "active_support/core_ext/hash/keys"
|
5
5
|
require "yaml"
|
6
|
-
require "open3"
|
7
6
|
|
8
7
|
class AssetWatcher
|
9
8
|
@@yaml_path = "config/asset_watch.yml"
|
@@ -26,22 +25,18 @@ class AssetWatcher
|
|
26
25
|
current_dir = `pwd`.strip
|
27
26
|
default_config = {
|
28
27
|
:src_dir => current_dir + "/src",
|
29
|
-
:dest_dir => current_dir,
|
28
|
+
:dest_dir => current_dir + "/public",
|
30
29
|
}
|
31
|
-
_config = default_config.dup
|
32
|
-
|
33
|
-
_config[:src_dir] = ARGV[1] if ARGV.count >= 2
|
34
|
-
_config[:dest_dir] = ARGV[2] if ARGV.count >= 3
|
35
30
|
|
36
31
|
# configuration file
|
37
32
|
yaml_path = current_dir + '/' + @@yaml_path
|
38
33
|
if File.exist? yaml_path
|
39
34
|
yaml_config = YAML.load_file yaml_path
|
40
35
|
yaml_config.symbolize_keys!
|
41
|
-
|
36
|
+
default_config.merge! yaml_config
|
42
37
|
end
|
43
38
|
|
44
|
-
@config =
|
39
|
+
@config = default_config.merge config
|
45
40
|
end
|
46
41
|
|
47
42
|
def target_files
|
@@ -62,7 +57,6 @@ class AssetWatcher
|
|
62
57
|
case $1
|
63
58
|
when 'coffee' then compile_coffee src_path
|
64
59
|
when 'haml' then compile_haml src_path
|
65
|
-
else false
|
66
60
|
end
|
67
61
|
else
|
68
62
|
false
|
@@ -79,16 +73,8 @@ class AssetWatcher
|
|
79
73
|
raise "'coffee' command is not found!"
|
80
74
|
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
stdout.each { |line| puts line }
|
85
|
-
error = stderr.read
|
86
|
-
|
87
|
-
unless result = error.empty?
|
88
|
-
puts error
|
89
|
-
puts "fail to compile '#{src_path}'"
|
90
|
-
end
|
91
|
-
return result
|
76
|
+
`coffee -b -o #{dest_dir} #{src_path}`
|
77
|
+
true
|
92
78
|
end
|
93
79
|
|
94
80
|
def compile_haml src_path
|
@@ -10,12 +10,4 @@ namespace :asset do
|
|
10
10
|
watcher.compile src_path
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
desc "Compile .coffee and .haml file when it changes"
|
15
|
-
task :compile do
|
16
|
-
watcher = AssetWatcher.new
|
17
|
-
watcher.target_files.each do |src_path|
|
18
|
-
watcher.compile src_path
|
19
|
-
end
|
20
|
-
end
|
21
13
|
end
|
data/spec/asset_watcher_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe AssetWatcher do
|
|
6
6
|
|
7
7
|
@config = {
|
8
8
|
:src_dir => @target_dir + "/src",
|
9
|
-
:dest_dir => @target_dir,
|
9
|
+
:dest_dir => @target_dir + "/public",
|
10
10
|
}
|
11
11
|
|
12
12
|
FileUtils.makedirs @config[:src_dir]
|
@@ -51,7 +51,7 @@ class CoffeeKlass
|
|
51
51
|
current_dir = `pwd`.strip
|
52
52
|
@default_config = {
|
53
53
|
:src_dir => current_dir + "/src",
|
54
|
-
:dest_dir => current_dir,
|
54
|
+
:dest_dir => current_dir + "/public",
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_watcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
-
-
|
13
|
+
- Tomohiro Yamada
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-01-21 00:00:00 +09:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|