rails3_artifactor 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/rails3_artifactor/artifact/crud.rb +1 -78
- data/lib/rails3_artifactor/artifact/crud/create.rb +12 -0
- data/lib/rails3_artifactor/artifact/crud/delete.rb +34 -0
- data/lib/rails3_artifactor/artifact/crud/read.rb +47 -0
- data/lib/rails3_artifactor/artifact/crud/update.rb +25 -0
- data/lib/rails3_artifactor/artifact/{crud/view.rb → view_artifact.rb} +12 -4
- data/rails3_artifactor.gemspec +7 -3
- data/spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb +1 -2
- metadata +8 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
@@ -23,84 +23,7 @@ module Rails3::Assist::Artifact
|
|
23
23
|
include Rails3::Assist::Artifact::CRUD
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
def has_#{plural_name}? *names
|
28
|
-
names.to_strings.each do |name|
|
29
|
-
return false if !has_#{name}? name
|
30
|
-
end
|
31
|
-
true
|
32
|
-
end
|
33
|
-
alias_method :#{plural_name}_files?, :has_#{plural_name}?
|
34
|
-
|
35
|
-
def has_#{name}? name, &block
|
36
|
-
begin
|
37
|
-
found = existing_file_name(name, :#{name}).path.file?
|
38
|
-
rescue IOError
|
39
|
-
found = false
|
40
|
-
end
|
41
|
-
yield if block && found
|
42
|
-
found
|
43
|
-
end
|
44
|
-
alias_method :has_#{name}_file?, :has_#{name}?
|
45
|
-
alias_method :#{name}_file?, :has_#{name}?
|
46
|
-
|
47
|
-
def #{name}_file name, &block
|
48
|
-
begin
|
49
|
-
found = existing_file_name(name, :#{name}).path
|
50
|
-
yield found if block && found
|
51
|
-
found
|
52
|
-
rescue
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def create_#{name} name, options={}, &block
|
58
|
-
create_artifact(name, set(options, :#{name}), &block)
|
59
|
-
end
|
60
|
-
|
61
|
-
def insert_into_#{name}(name, options={}, &block)
|
62
|
-
begin
|
63
|
-
insert_into_artifact(name, set(options, :#{name}), &block)
|
64
|
-
true
|
65
|
-
rescue
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def read_#{name}(name, options={}, &block)
|
71
|
-
begin
|
72
|
-
read_artifact(name, set(options, :#{name}), &block)
|
73
|
-
rescue
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def remove_#{name} name
|
79
|
-
remove_artifact name, :#{name}
|
80
|
-
end
|
81
|
-
|
82
|
-
def remove_#{plural_name} *names
|
83
|
-
remove_artifacts :#{name}, *names
|
84
|
-
end
|
85
|
-
|
86
|
-
def remove_all_#{plural_name}
|
87
|
-
Rails3::Assist::Artifact::Files.#{name}_files.each do |file_name|
|
88
|
-
::File.delete_file! file_name if ::File.file?(file_name)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
alias_method :delete_all_#{plural_name}, :remove_all_#{plural_name}
|
92
|
-
|
93
|
-
def remove_#{plural_name} *names
|
94
|
-
return remove_all_#{plural_name} if names.empty?
|
95
|
-
names.to_strings.each do |name|
|
96
|
-
file_name = #{name}_file(name)
|
97
|
-
::File.delete!(file_name) if file_name && ::File.file?(file_name)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
alias_method :delete_#{plural_name}, :remove_#{plural_name}
|
101
|
-
alias_method :remove_#{name}, :remove_#{plural_name}
|
102
|
-
alias_method :delete_#{name}, :remove_#{plural_name}
|
103
|
-
|
26
|
+
|
104
27
|
multi_aliases_for :#{name}
|
105
28
|
end
|
106
29
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Rails3::Assist::Artifact
|
2
|
+
Rails3::Assist.artifacts.each do |name|
|
3
|
+
plural_name = name.to_s.pluralize
|
4
|
+
class_eval %{
|
5
|
+
module #{name.to_s.camelize}
|
6
|
+
def create_#{name} name, options={}, &block
|
7
|
+
create_artifact(name, set(options, :#{name}), &block)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Rails3::Assist::Artifact
|
2
|
+
Rails3::Assist.artifacts.each do |name|
|
3
|
+
plural_name = name.to_s.pluralize
|
4
|
+
class_eval %{
|
5
|
+
module #{name.to_s.camelize}
|
6
|
+
def remove_#{name} name
|
7
|
+
remove_artifact name, :#{name}
|
8
|
+
end
|
9
|
+
|
10
|
+
def remove_#{plural_name} *names
|
11
|
+
remove_artifacts :#{name}, *names
|
12
|
+
end
|
13
|
+
|
14
|
+
def remove_all_#{plural_name}
|
15
|
+
Rails3::Assist::Artifact::Files.#{name}_files.each do |file_name|
|
16
|
+
::File.delete_file! file_name if ::File.file?(file_name)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
alias_method :delete_all_#{plural_name}, :remove_all_#{plural_name}
|
20
|
+
|
21
|
+
def remove_#{plural_name} *names
|
22
|
+
return remove_all_#{plural_name} if names.empty?
|
23
|
+
names.to_strings.each do |name|
|
24
|
+
file_name = #{name}_file(name)
|
25
|
+
::File.delete!(file_name) if file_name && ::File.file?(file_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
alias_method :delete_#{plural_name}, :remove_#{plural_name}
|
29
|
+
alias_method :remove_#{name}, :remove_#{plural_name}
|
30
|
+
alias_method :delete_#{name}, :remove_#{plural_name}
|
31
|
+
end
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Rails3::Assist::Artifact
|
2
|
+
Rails3::Assist.artifacts.each do |name|
|
3
|
+
plural_name = name.to_s.pluralize
|
4
|
+
class_eval %{
|
5
|
+
module #{name.to_s.camelize}
|
6
|
+
def has_#{plural_name}? *names
|
7
|
+
names.to_strings.each do |name|
|
8
|
+
return false if !has_#{name}? name
|
9
|
+
end
|
10
|
+
true
|
11
|
+
end
|
12
|
+
alias_method :#{plural_name}_files?, :has_#{plural_name}?
|
13
|
+
|
14
|
+
def has_#{name}? name, &block
|
15
|
+
begin
|
16
|
+
found = existing_file_name(name, :#{name}).path.file?
|
17
|
+
rescue IOError
|
18
|
+
found = false
|
19
|
+
end
|
20
|
+
yield if block && found
|
21
|
+
found
|
22
|
+
end
|
23
|
+
alias_method :has_#{name}_file?, :has_#{name}?
|
24
|
+
alias_method :#{name}_file?, :has_#{name}?
|
25
|
+
|
26
|
+
|
27
|
+
def read_#{name}(name, options={}, &block)
|
28
|
+
begin
|
29
|
+
read_artifact(name, set(options, :#{name}), &block)
|
30
|
+
rescue
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def #{name}_file name, &block
|
36
|
+
begin
|
37
|
+
found = existing_file_name(name, :#{name}).path
|
38
|
+
yield found if block && found
|
39
|
+
found
|
40
|
+
rescue
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rails3::Assist::Artifact
|
2
|
+
Rails3::Assist.artifacts.each do |name|
|
3
|
+
plural_name = name.to_s.pluralize
|
4
|
+
class_eval %{
|
5
|
+
module #{name.to_s.camelize}
|
6
|
+
def replace_in_#{name} name, options={}, &block
|
7
|
+
replace_in_artifact(name, set(options, :#{name}), &block)
|
8
|
+
end
|
9
|
+
|
10
|
+
def replace_in_#{plural_name} *names, &block
|
11
|
+
replace_in_artifacts *names, &block
|
12
|
+
end
|
13
|
+
|
14
|
+
def insert_into_#{name}(name, options={}, &block)
|
15
|
+
begin
|
16
|
+
insert_into_artifact(name, set(options, :#{name}), &block)
|
17
|
+
true
|
18
|
+
rescue
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Rails3::Assist::Artifact
|
2
2
|
module View
|
3
3
|
include Rails3::Assist::BaseHelper
|
4
|
+
include Rails3::Assist::Artifact::CRUD
|
4
5
|
|
5
6
|
def has_view? name, *args, &block
|
6
7
|
file_name = view_file_name(name, args)
|
@@ -27,7 +28,7 @@ module Rails3::Assist::Artifact
|
|
27
28
|
end
|
28
29
|
|
29
30
|
# READ
|
30
|
-
def read_view
|
31
|
+
def read_view name, *args, &block
|
31
32
|
file_name = view_file_name(name, args)
|
32
33
|
debug "reading from: #{file_name}"
|
33
34
|
file = File.new(file_name)
|
@@ -43,7 +44,7 @@ module Rails3::Assist::Artifact
|
|
43
44
|
end
|
44
45
|
|
45
46
|
# UPDATE
|
46
|
-
def insert_into_view
|
47
|
+
def insert_into_view name, *args, &block
|
47
48
|
file_name = view_file_name(name, args)
|
48
49
|
debug "file insertion (view): #{file_name}"
|
49
50
|
options = last_option args
|
@@ -53,11 +54,18 @@ module Rails3::Assist::Artifact
|
|
53
54
|
end
|
54
55
|
|
55
56
|
# DELETE
|
56
|
-
def remove_view name,
|
57
|
-
file = view_file_name(name,
|
57
|
+
def remove_view name, *args
|
58
|
+
file = view_file_name(name, args)
|
58
59
|
FileUtils.rm_f(file) if File.exist?(file)
|
59
60
|
end
|
60
61
|
|
62
|
+
# remove_views :edit, :show, :folder => :person
|
63
|
+
def remove_views *args
|
64
|
+
options = last_option args
|
65
|
+
raise ArgumentError, "Missing :folder option in the last argument which must be a Hash" if !options && !options[:folder]
|
66
|
+
args.to_symbols.each{|name| remove_view name, options}
|
67
|
+
end
|
68
|
+
|
61
69
|
def get_view_content args
|
62
70
|
args = args.flatten
|
63
71
|
case args.first
|
data/rails3_artifactor.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails3_artifactor}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.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{2010-
|
12
|
+
s.date = %q{2010-10-05}
|
13
13
|
s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
|
14
14
|
s.email = %q{kmandrup@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,7 +29,10 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/rails3_artifactor/artifact.rb",
|
30
30
|
"lib/rails3_artifactor/artifact/base.rb",
|
31
31
|
"lib/rails3_artifactor/artifact/crud.rb",
|
32
|
-
"lib/rails3_artifactor/artifact/crud/
|
32
|
+
"lib/rails3_artifactor/artifact/crud/create.rb",
|
33
|
+
"lib/rails3_artifactor/artifact/crud/delete.rb",
|
34
|
+
"lib/rails3_artifactor/artifact/crud/read.rb",
|
35
|
+
"lib/rails3_artifactor/artifact/crud/update.rb",
|
33
36
|
"lib/rails3_artifactor/artifact/file_name/artifacts.rb",
|
34
37
|
"lib/rails3_artifactor/artifact/file_name/migration.rb",
|
35
38
|
"lib/rails3_artifactor/artifact/file_name/view.rb",
|
@@ -41,6 +44,7 @@ Gem::Specification.new do |s|
|
|
41
44
|
"lib/rails3_artifactor/artifact/orm/mongo_mapper.rb",
|
42
45
|
"lib/rails3_artifactor/artifact/orm/mongoid.rb",
|
43
46
|
"lib/rails3_artifactor/artifact/orm/none.rb",
|
47
|
+
"lib/rails3_artifactor/artifact/view_artifact.rb",
|
44
48
|
"lib/rails3_artifactor/base.rb",
|
45
49
|
"lib/rails3_artifactor/base/crud.rb",
|
46
50
|
"lib/rails3_artifactor/base/crud/create.rb",
|
@@ -21,13 +21,12 @@ describe 'view API - symbols' do
|
|
21
21
|
context "Non-existant view(s)" do
|
22
22
|
|
23
23
|
it "should not fail trying to remove non-existant views" do
|
24
|
-
pending "TODO"
|
25
24
|
|
26
25
|
remove_views :edit, :show, :folder => :person
|
27
26
|
remove_artifacts :view, :edit, :show, :folder => :person
|
28
27
|
|
29
28
|
remove_view :show, :folder => :person
|
30
|
-
remove_artifact :view, :show, :folder => :person
|
29
|
+
# remove_artifact :view, :show, :folder => :person
|
31
30
|
end
|
32
31
|
|
33
32
|
it "should not find a non-existant view" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 7
|
9
|
+
version: 0.2.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: 2010-
|
17
|
+
date: 2010-10-05 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -133,7 +133,10 @@ files:
|
|
133
133
|
- lib/rails3_artifactor/artifact.rb
|
134
134
|
- lib/rails3_artifactor/artifact/base.rb
|
135
135
|
- lib/rails3_artifactor/artifact/crud.rb
|
136
|
-
- lib/rails3_artifactor/artifact/crud/
|
136
|
+
- lib/rails3_artifactor/artifact/crud/create.rb
|
137
|
+
- lib/rails3_artifactor/artifact/crud/delete.rb
|
138
|
+
- lib/rails3_artifactor/artifact/crud/read.rb
|
139
|
+
- lib/rails3_artifactor/artifact/crud/update.rb
|
137
140
|
- lib/rails3_artifactor/artifact/file_name/artifacts.rb
|
138
141
|
- lib/rails3_artifactor/artifact/file_name/migration.rb
|
139
142
|
- lib/rails3_artifactor/artifact/file_name/view.rb
|
@@ -145,6 +148,7 @@ files:
|
|
145
148
|
- lib/rails3_artifactor/artifact/orm/mongo_mapper.rb
|
146
149
|
- lib/rails3_artifactor/artifact/orm/mongoid.rb
|
147
150
|
- lib/rails3_artifactor/artifact/orm/none.rb
|
151
|
+
- lib/rails3_artifactor/artifact/view_artifact.rb
|
148
152
|
- lib/rails3_artifactor/base.rb
|
149
153
|
- lib/rails3_artifactor/base/crud.rb
|
150
154
|
- lib/rails3_artifactor/base/crud/create.rb
|