cog 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cog.rb +1 -1
- data/lib/cog/cogfile.rb +0 -1
- data/lib/cog/has_template.rb +17 -2
- data/lib/cog_version.rb +1 -1
- metadata +3 -3
data/lib/cog.rb
CHANGED
@@ -10,7 +10,7 @@ module Cog
|
|
10
10
|
# grandparent, and so on.
|
11
11
|
#
|
12
12
|
# === Returns
|
13
|
-
# An instance of
|
13
|
+
# An instance of Cogfile which has been configured with a Cogfile. Or +nil+ if
|
14
14
|
# no +Cogfile+ could be found.
|
15
15
|
def self.load_cogfile
|
16
16
|
parts = Dir.pwd.split File::SEPARATOR
|
data/lib/cog/cogfile.rb
CHANGED
data/lib/cog/has_template.rb
CHANGED
@@ -24,15 +24,30 @@ module Cog
|
|
24
24
|
#
|
25
25
|
# === Parameters
|
26
26
|
# * +path+ - the path to the template to use which is relative to
|
27
|
-
#
|
27
|
+
# Cogfile#template_dir and does not include the +.erb+ extension.
|
28
28
|
# * +dest+ - the destination path to the generated file which is relative
|
29
|
-
# to
|
29
|
+
# to Cogfile#code_dir. If this is not provided, then the generated code
|
30
30
|
# will be returned as a string.
|
31
31
|
#
|
32
32
|
# === Returns
|
33
33
|
# +nil+ if generated to a file, otherwise returns the generated code as a
|
34
34
|
# string.
|
35
35
|
def stamp(path, dest=nil)
|
36
|
+
t = get_template path
|
37
|
+
scratch = "#{path}.scratch"
|
38
|
+
File.open(scratch, 'w') do |file|
|
39
|
+
file.write t.result(make_protected_binding)
|
40
|
+
# TODO: ...
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def same?(original, scratch) # :nodoc:
|
46
|
+
if File.exists? original
|
47
|
+
File.read(original) == File.read(scratch)
|
48
|
+
else
|
49
|
+
false
|
50
|
+
end
|
36
51
|
end
|
37
52
|
end
|
38
53
|
|
data/lib/cog_version.rb
CHANGED
metadata
CHANGED