rails3_assist 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/rails3_assist/file.rb +20 -0
- data/rails3_assist.gemspec +2 -2
- data/spec/rails3_assist/file_spec.rb +54 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/lib/rails3_assist/file.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_all File.dirname(__FILE__) + '/file'
|
2
|
+
# require 'sugar-high/file'
|
2
3
|
|
3
4
|
module Rails3::Assist
|
4
5
|
module File
|
@@ -33,6 +34,25 @@ module Rails3::Assist
|
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
def read_#{name} name
|
38
|
+
fname = #{name}_file(name)
|
39
|
+
::File.read(fname) if ::File.file?(fname)
|
40
|
+
end
|
41
|
+
alias_method :read_#{name}_file, :read_#{name}
|
42
|
+
|
43
|
+
def replace_#{name}_content name, args = {}, &block
|
44
|
+
if !(args.kind_of?(Hash) && args[:where])
|
45
|
+
raise ArgumentError, "#replace_#{name}_content Must take a hash argument with a :where option that is the content to be matched and replaced"
|
46
|
+
end
|
47
|
+
|
48
|
+
replace_content = block ? yield : args[:with]
|
49
|
+
if !replace_content
|
50
|
+
raise ArgumentError, "#replace_#{name}_content Must take a block or a :with hash option that is the content to replace with"
|
51
|
+
end
|
52
|
+
|
53
|
+
::File.replace_content_from #{name}_file(name), :where => args[:where], :with => replace_content
|
54
|
+
end
|
55
|
+
|
36
56
|
def remove_all_#{plural_name}
|
37
57
|
return if !::File.directory?(Rails3::Assist::Artifact::Directory.#{name}_dir)
|
38
58
|
#{name}_files.each{|f| ::File.delete_file! f}
|
data/rails3_assist.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails3_assist}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = %q{2011-01-
|
12
|
+
s.date = %q{2011-01-07}
|
13
13
|
s.description = %q{Basic file operation helpers for working with Rails 3 artifacts}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,60 @@ describe Rails3::Assist::File do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe '#read_initializer' do
|
34
|
+
it "should create replace initializer content using hash args" do
|
35
|
+
name = 'my_init'
|
36
|
+
CLASS.remove_initializers(name)
|
37
|
+
CLASS.create_initializer(name) do
|
38
|
+
'hello'
|
39
|
+
end
|
40
|
+
CLASS.read_initializer(name).should match /hello/
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#read_initializer_file' do
|
45
|
+
it "should create replace initializer content using hash args" do
|
46
|
+
name = 'my_init'
|
47
|
+
CLASS.remove_initializers(name)
|
48
|
+
CLASS.create_initializer(name) do
|
49
|
+
'hello'
|
50
|
+
end
|
51
|
+
CLASS.read_initializer_file(name).should match /hello/
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
describe '#replace_initializer_content' do
|
57
|
+
it "should create replace initializer content using hash args" do
|
58
|
+
name = 'my_init'
|
59
|
+
CLASS.remove_initializers(name)
|
60
|
+
CLASS.create_initializer(name) do
|
61
|
+
'hello'
|
62
|
+
end
|
63
|
+
CLASS.replace_initializer_content name, :where => 'hello', :with => 'goodbye'
|
64
|
+
|
65
|
+
CLASS.read_initializer(name).should match /goodbye/
|
66
|
+
CLASS.read_initializer(name).should_not match /hello/
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should create replace initializer content using hash arg and block" do
|
70
|
+
name = 'my_init'
|
71
|
+
CLASS.remove_initializers(name)
|
72
|
+
CLASS.create_initializer(name) do
|
73
|
+
'hello'
|
74
|
+
end
|
75
|
+
CLASS.replace_initializer_content name, :where => 'hello' do
|
76
|
+
'goodbye'
|
77
|
+
end
|
78
|
+
|
79
|
+
CLASS.read_initializer(name).should match /goodbye/
|
80
|
+
CLASS.read_initializer(name).should_not match /hello/
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
33
87
|
describe '#create_javascript' do
|
34
88
|
it "should create the javascript file 'my_init' " do
|
35
89
|
name = :effects
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 7
|
9
|
+
version: 0.3.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-07 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|