guard-coffeedripper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +0 -0
- data/lib/guard/coffeedripper.rb +110 -0
- data/lib/guard/coffeedripper/templates/Guardfile +3 -0
- data/lib/guard/coffeedripper/version.rb +5 -0
- metadata +93 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011 amacou
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
|
data/README.md
ADDED
File without changes
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
require 'guard/watcher'
|
4
|
+
require 'yaml'
|
5
|
+
module Guard
|
6
|
+
class CoffeeDripper < Guard
|
7
|
+
|
8
|
+
attr_accessor :config
|
9
|
+
def initialize(watchers=[], options={})
|
10
|
+
super
|
11
|
+
@watchers, @options = watchers, options
|
12
|
+
@options[:output] ||= 'app/coffeescripts/'
|
13
|
+
@options[:input] ||= 'app/coffeescripts/'
|
14
|
+
@options[:ext] ||= 'coffeebean'
|
15
|
+
@options[:config] ||= 'config/coffeedripper.yaml'
|
16
|
+
load_config
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_config
|
20
|
+
@config = YAML.load_file File.join Dir.pwd, @options[:config]
|
21
|
+
return true if @config
|
22
|
+
return false
|
23
|
+
end
|
24
|
+
|
25
|
+
def change_bean(bean)
|
26
|
+
@config.each do |coffee, beans|
|
27
|
+
if beans.include? bean
|
28
|
+
drip(coffee)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def drip_all
|
34
|
+
@config.each do |coffee, beans|
|
35
|
+
drip(coffee)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def drip(coffee_script)
|
40
|
+
beans = @config[coffee_script]
|
41
|
+
output = File.join Dir.pwd, @options[:output], coffee_script
|
42
|
+
str = ""
|
43
|
+
beans.each do |bean|
|
44
|
+
str += load_bean(bean)
|
45
|
+
end
|
46
|
+
write(output, str)
|
47
|
+
end
|
48
|
+
|
49
|
+
def load_bean(bean)
|
50
|
+
str = ""
|
51
|
+
input = File.join Dir.pwd, @options[:input], bean
|
52
|
+
f = open(input)
|
53
|
+
str = f.read
|
54
|
+
f.close
|
55
|
+
str << "\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_coffee(coffee)
|
59
|
+
str = ""
|
60
|
+
output = File.join Dir.pwd, @options[:output], coffee
|
61
|
+
f = open(output)
|
62
|
+
str = f.read
|
63
|
+
f.close
|
64
|
+
return str
|
65
|
+
end
|
66
|
+
|
67
|
+
def write(output,str)
|
68
|
+
f = File.open(output,'w')
|
69
|
+
f.puts str
|
70
|
+
f.close
|
71
|
+
end
|
72
|
+
# =================
|
73
|
+
# = Guard methods =
|
74
|
+
# =================
|
75
|
+
|
76
|
+
# If one of those methods raise an exception, the Guard::GuardName instance
|
77
|
+
# will be removed from the active guards.
|
78
|
+
|
79
|
+
# Called once when Guard starts
|
80
|
+
# Please override initialize method to init stuff
|
81
|
+
def start
|
82
|
+
run_all
|
83
|
+
end
|
84
|
+
|
85
|
+
# Called on Ctrl-C signal (when Guard quits)
|
86
|
+
def stop
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
# Called on Ctrl-Z signal
|
91
|
+
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
|
92
|
+
def reload
|
93
|
+
load_config
|
94
|
+
run_all
|
95
|
+
end
|
96
|
+
|
97
|
+
# Called on Ctrl-\ signal
|
98
|
+
# This method should be principally used for long action like running all specs/tests/...
|
99
|
+
def run_all
|
100
|
+
drip_all
|
101
|
+
end
|
102
|
+
|
103
|
+
# Called on file(s) modifications
|
104
|
+
def run_on_change(paths)
|
105
|
+
paths.each do |bean|
|
106
|
+
change_bean(bean.split("/").last)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-coffeedripper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- amacou
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-06-12 00:00:00 +09:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: guard
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0.4"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "1.0"
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rspec
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "2.6"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
description: Guard::CoffeeDripper automatically generates your coffescript from your parts of coffee
|
50
|
+
email:
|
51
|
+
- amacou.abf@gmail.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- lib/guard/coffeedripper/templates/Guardfile
|
60
|
+
- lib/guard/coffeedripper/version.rb
|
61
|
+
- lib/guard/coffeedripper.rb
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://github.com/amacou/guard-coffeedripper
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.3.6
|
85
|
+
requirements: []
|
86
|
+
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.6.2
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Guard gem for Marge CoffeeScript
|
92
|
+
test_files: []
|
93
|
+
|