rails3_artifactor 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/DESIGN_NOTES.markdown +0 -0
- data/VERSION +1 -1
- data/lib/rails3_artifactor/artifact/crud.rb +8 -1
- data/lib/rails3_artifactor/artifact/markers.rb +1 -1
- data/lib/rails3_artifactor/artifact/orm/active_record.rb +2 -2
- data/lib/rails3_artifactor/artifact/orm/data_mapper.rb +2 -2
- data/lib/rails3_artifactor/artifact/orm/mongo_mapper.rb +1 -1
- data/lib/rails3_artifactor/artifact/orm/mongoid.rb +1 -1
- data/lib/rails3_artifactor/artifact/orm/none.rb +3 -4
- data/lib/rails3_artifactor/artifact/orm.rb +1 -1
- data/lib/rails3_artifactor/base/crud/create.rb +14 -15
- data/lib/rails3_artifactor/base/crud/delete.rb +6 -2
- data/lib/rails3_artifactor/base/crud/read.rb +5 -12
- data/lib/rails3_artifactor/base/crud/update.rb +33 -13
- data/rails3_artifactor.gemspec +136 -0
- data/spec/fixtures/app/models/account.rb +6 -0
- data/spec/rails3_artifactor/artifact/base_spec.rb +17 -0
- data/spec/rails3_artifactor/base/crud/create_spec.rb +23 -5
- data/spec/rails3_artifactor/base/crud/delete_spec.rb +40 -5
- data/spec/rails3_artifactor/base/crud/read_spec.rb +63 -7
- data/spec/rails3_artifactor/base/crud/update_spec.rb +58 -8
- metadata +6 -5
- data/lib/rails3_artifactor/base/class_methods.rb +0 -9
- data/spec/fixtures/app/models/account_observer.rb +0 -4
File without changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
@@ -6,7 +6,7 @@ module Rails3::Assist::Artifact
|
|
6
6
|
class_eval %{
|
7
7
|
module #{name.to_s.camelize}
|
8
8
|
def new_#{name}_content name, content=nil, &block
|
9
|
-
new_artifact_content name, :#{name}, content, &block
|
9
|
+
new_artifact_content name, :type => :#{name}, :content => content, &block
|
10
10
|
end
|
11
11
|
end
|
12
12
|
}
|
@@ -18,6 +18,13 @@ module Rails3::Assist::Artifact
|
|
18
18
|
include Rails3::Assist::BaseHelper
|
19
19
|
include Rails3::Assist::Artifact::CRUD
|
20
20
|
|
21
|
+
def has_#{name.to_s.pluralize}? *names
|
22
|
+
names.flatten.each do |name|
|
23
|
+
return false if !has_#{name}? name
|
24
|
+
end
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
21
28
|
def has_#{name}? name, &block
|
22
29
|
begin
|
23
30
|
found = existing_file_name(name, :#{name}).path.file?
|
@@ -62,7 +62,7 @@ module Rails3::Assist::Artifact
|
|
62
62
|
include Rails3::Assist::BaseHelper
|
63
63
|
|
64
64
|
def model_marker name, options={}
|
65
|
-
return send :orm_marker_name, options if respond_to?(:orm_marker_name)
|
65
|
+
return send :orm_marker_name, name, options if respond_to?(:orm_marker_name)
|
66
66
|
name.to_s.camelize
|
67
67
|
end
|
68
68
|
|
@@ -2,13 +2,13 @@ module Rails3::Assist::Orm
|
|
2
2
|
module ActiveRecord
|
3
3
|
include Rails3::Assist::Orm::Base
|
4
4
|
|
5
|
-
def orm_marker_name options=nil
|
5
|
+
def orm_marker_name name, options=nil
|
6
6
|
'ActiveRecord::Base'
|
7
7
|
end
|
8
8
|
|
9
9
|
def new_model_content name, options={}, &block
|
10
10
|
content = options[:content] || yield if block
|
11
|
-
file_w_inherit(name, orm_marker_name(options)) { content }
|
11
|
+
file_w_inherit(name, orm_marker_name(name, options)) { content }
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -6,13 +6,13 @@ module Rails3::Assist::Orm
|
|
6
6
|
'DataMapper'
|
7
7
|
end
|
8
8
|
|
9
|
-
def orm_marker_name options=nil
|
9
|
+
def orm_marker_name name, options=nil
|
10
10
|
"#{orm_name}::Resource"
|
11
11
|
end
|
12
12
|
|
13
13
|
def new_model_content name, options={}, &block
|
14
14
|
content = options[:content] || yield if block
|
15
|
-
file_w_include(name, orm_marker_name(options)) { content }
|
15
|
+
file_w_include(name, orm_marker_name(name, options)) { content }
|
16
16
|
end
|
17
17
|
|
18
18
|
def field_name
|
@@ -8,7 +8,7 @@ module Rails3::Assist::Orm
|
|
8
8
|
|
9
9
|
def new_model_content name, options={}, &block
|
10
10
|
content = options[:content] || yield if block
|
11
|
-
file_w_include(name, orm_marker_name(options)) { content }
|
11
|
+
file_w_include(name, orm_marker_name(name, options)) { content }
|
12
12
|
end
|
13
13
|
|
14
14
|
def field_name
|
@@ -12,7 +12,7 @@ module Rails3::Assist::Orm
|
|
12
12
|
|
13
13
|
def new_model_content name, options={}, &block
|
14
14
|
content = options[:content] || yield if block
|
15
|
-
file_w_include(name, orm_marker_name(options)) { content }
|
15
|
+
file_w_include(name, orm_marker_name(name, options)) { content }
|
16
16
|
end
|
17
17
|
|
18
18
|
def field name, type = nil
|
@@ -4,14 +4,13 @@ module Rails3::Assist::Orm
|
|
4
4
|
module None
|
5
5
|
include Rails3::Assist::Orm::Base
|
6
6
|
|
7
|
-
def orm_marker_name options=nil
|
8
|
-
|
7
|
+
def orm_marker_name name, options=nil
|
8
|
+
name.to_s.camelize
|
9
9
|
end
|
10
10
|
|
11
11
|
def new_model_content name, options={}, &block
|
12
12
|
content = block ? yield : options[:content]
|
13
|
-
|
14
|
-
simple_file(name, orm_marker_name(options)) { content }
|
13
|
+
simple_file(name, orm_marker_name(name, options)) { content }
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
@@ -8,7 +8,7 @@ module Rails3::Assist::Artifact::CRUD
|
|
8
8
|
return nil if File.exist?(file)
|
9
9
|
|
10
10
|
create_artifact_dir(file)
|
11
|
-
content = get_content(name, type,
|
11
|
+
content = get_content(name, type, options, &block)
|
12
12
|
return if content.blank?
|
13
13
|
|
14
14
|
File.overwrite file, content
|
@@ -16,14 +16,20 @@ module Rails3::Assist::Artifact::CRUD
|
|
16
16
|
|
17
17
|
protected
|
18
18
|
|
19
|
-
def new_artifact_content name, type, content=nil, &block
|
20
|
-
|
19
|
+
# def new_artifact_content name, type, content=nil, &block
|
20
|
+
def new_artifact_content name, options = {}, &block
|
21
|
+
type = get_type(options)
|
22
|
+
content = get_content(name, type, options, &block)
|
21
23
|
%Q{class #{marker(name, type)}
|
22
24
|
#{content}
|
23
25
|
end}
|
24
|
-
end
|
26
|
+
end
|
25
27
|
|
26
|
-
|
28
|
+
def create_artifact_dir file
|
29
|
+
# make dir
|
30
|
+
dir = File.dirname(file)
|
31
|
+
FileUtils.mkdir_p dir if !File.directory?(dir)
|
32
|
+
end
|
27
33
|
|
28
34
|
def content_method type
|
29
35
|
method = :"new_#{type}_content"
|
@@ -31,18 +37,11 @@ end}
|
|
31
37
|
method
|
32
38
|
end
|
33
39
|
|
34
|
-
|
35
|
-
def create_artifact_dir file
|
36
|
-
# make dir
|
37
|
-
dir = File.dirname(file)
|
38
|
-
FileUtils.mkdir_p dir if !File.directory?(dir)
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_content name, type, content, options = {}, &block
|
40
|
+
def get_content name, type, options = {}, &block
|
42
41
|
content = block ? yield : options[:content]
|
43
42
|
content = type == :model ? content : options.merge(:content => content)
|
44
43
|
method = content_method(type)
|
45
|
-
send method, name, content
|
46
|
-
end
|
44
|
+
send method, name, :content => content
|
45
|
+
end
|
47
46
|
end
|
48
47
|
end
|
@@ -1,13 +1,17 @@
|
|
1
|
+
require 'sugar-high/array'
|
2
|
+
|
1
3
|
module Rails3::Assist::Artifact::CRUD
|
2
4
|
module Delete
|
3
5
|
def remove_artifact name, type
|
6
|
+
type = type[:type] if type.kind_of? Hash
|
4
7
|
file = existing_file_name name, type
|
5
8
|
debug "removed artifact: #{name}" if File.exist?(file) && FileUtils.rm_f(file)
|
6
9
|
end
|
7
10
|
alias_method :delete_artifact, :remove_artifact
|
8
11
|
|
9
|
-
def remove_artifacts
|
10
|
-
|
12
|
+
def remove_artifacts *names
|
13
|
+
type = last_option(names)[:type]
|
14
|
+
names.flatten.select_labels.each{|name| remove_artifact(name, type) }
|
11
15
|
end
|
12
16
|
alias_method :delete_artifacts, :remove_artifacts
|
13
17
|
end
|
@@ -1,20 +1,13 @@
|
|
1
|
+
require 'sugar-high/file'
|
2
|
+
|
1
3
|
module Rails3::Assist::Artifact::CRUD
|
2
|
-
module Read
|
3
|
-
|
4
|
+
module Read
|
4
5
|
# TODO: Support :before and :after hash options!
|
5
|
-
def read_artifact(name, options, &block)
|
6
|
+
def read_artifact(name, options = {}, &block)
|
6
7
|
type = get_type(options)
|
7
8
|
file_name = existing_file_name(name, type)
|
8
9
|
debug "reading from: #{file_name}"
|
9
|
-
|
10
|
-
file = File.new(file_name)
|
11
|
-
content = file.read
|
12
|
-
debug "read content: #{content}"
|
13
|
-
yield content if block
|
14
|
-
content
|
15
|
-
rescue
|
16
|
-
raise "Rails #{type} at: #{file_name} can't be read"
|
17
|
-
end
|
10
|
+
File.read_from file_name, options, &block
|
18
11
|
end
|
19
12
|
end
|
20
13
|
end
|
@@ -8,13 +8,16 @@ module Rails3::Assist::Artifact::CRUD
|
|
8
8
|
|
9
9
|
raise "No file could be determined: #{file} from name: #{name} of type: #{type}" if !file
|
10
10
|
raise "File to insert in not found: #{file} for #{type}" if !File.file?(file)
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
marker = marker_option(name, options)
|
13
|
+
|
14
|
+
blip = send :"#{type}_marker", name, options
|
15
|
+
options1 = options.merge marker
|
13
16
|
|
14
17
|
res = File.insert_into file, options1, &block
|
15
18
|
if !res
|
16
19
|
# try with :embedded option if default doesn't work
|
17
|
-
mrk_opt = marker_option name,
|
20
|
+
mrk_opt = marker_option name, options.merge(:model_type => :embedded)
|
18
21
|
options.merge! mrk_opt
|
19
22
|
|
20
23
|
File.insert_into file, options, &block
|
@@ -23,22 +26,39 @@ module Rails3::Assist::Artifact::CRUD
|
|
23
26
|
alias_method :update_artifact, :insert_into_artifact
|
24
27
|
|
25
28
|
def remove_from_artifact name, options={}, &block
|
26
|
-
|
29
|
+
type = options[:type]
|
30
|
+
file = existing_file_name(name, type)
|
31
|
+
File.remove_content_from file, options, &block
|
27
32
|
end
|
28
33
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
34
|
+
def remove_from_artifacts *names, &block
|
35
|
+
options = last_option(names)
|
36
|
+
type = options[:type]
|
37
|
+
artifacts = names.flatten.select_labels
|
38
|
+
|
39
|
+
artifacts.each do |name|
|
32
40
|
file = existing_file_name(name, type)
|
33
|
-
File.remove_content_from file,
|
41
|
+
File.remove_content_from file, options, &block
|
34
42
|
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# TODO
|
38
|
-
aliases_for :remove_content_from, :delete_content_from, :delete_from, :remove_from
|
43
|
+
end
|
44
|
+
alias_hash :remove_from_artifact => :delete_from_artifact, :pluralize => true
|
39
45
|
|
40
46
|
def replace_in_artifact name, options={}, &block
|
41
|
-
|
47
|
+
type = options[:type]
|
48
|
+
file = existing_file_name(name, type)
|
49
|
+
File.replace_content_from file, options, &block
|
42
50
|
end
|
51
|
+
|
52
|
+
def replace_in_artifacts *names, &block
|
53
|
+
options = last_option(names)
|
54
|
+
type = options[:type]
|
55
|
+
artifacts = names.flatten.select_labels
|
56
|
+
|
57
|
+
artifacts.each do |name|
|
58
|
+
file = existing_file_name(name, type)
|
59
|
+
File.replace_content_from file, options, &block
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias_hash :replace_in_artifact => :update_artifact, :pluralize => true
|
43
63
|
end
|
44
64
|
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rails3_artifactor}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Kristian Mandrup"]
|
12
|
+
s.date = %q{2010-09-04}
|
13
|
+
s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
|
14
|
+
s.email = %q{kmandrup@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.markdown"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
".rspec",
|
23
|
+
"DESIGN_NOTES.markdown",
|
24
|
+
"LICENSE",
|
25
|
+
"README.markdown",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/rails3_artifactor.rb",
|
29
|
+
"lib/rails3_artifactor/artifact/crud.rb",
|
30
|
+
"lib/rails3_artifactor/artifact/crud/view.rb",
|
31
|
+
"lib/rails3_artifactor/artifact/file_name/artifacts.rb",
|
32
|
+
"lib/rails3_artifactor/artifact/file_name/migration.rb",
|
33
|
+
"lib/rails3_artifactor/artifact/file_name/view.rb",
|
34
|
+
"lib/rails3_artifactor/artifact/markers.rb",
|
35
|
+
"lib/rails3_artifactor/artifact/migration.rb",
|
36
|
+
"lib/rails3_artifactor/artifact/orm.rb",
|
37
|
+
"lib/rails3_artifactor/artifact/orm/active_record.rb",
|
38
|
+
"lib/rails3_artifactor/artifact/orm/data_mapper.rb",
|
39
|
+
"lib/rails3_artifactor/artifact/orm/mongo_mapper.rb",
|
40
|
+
"lib/rails3_artifactor/artifact/orm/mongoid.rb",
|
41
|
+
"lib/rails3_artifactor/artifact/orm/none.rb",
|
42
|
+
"lib/rails3_artifactor/base/crud.rb",
|
43
|
+
"lib/rails3_artifactor/base/crud/create.rb",
|
44
|
+
"lib/rails3_artifactor/base/crud/delete.rb",
|
45
|
+
"lib/rails3_artifactor/base/crud/read.rb",
|
46
|
+
"lib/rails3_artifactor/base/crud/update.rb",
|
47
|
+
"lib/rails3_artifactor/base/file_name.rb",
|
48
|
+
"lib/rails3_artifactor/namespaces.rb",
|
49
|
+
"lib/rails3_artifactor/rspec/configure.rb",
|
50
|
+
"lib/rails3_artifactor/rspec/macro.rb",
|
51
|
+
"rails3_artifactor.gemspec",
|
52
|
+
"spec/fixtures.rb",
|
53
|
+
"spec/fixtures/app/controllers/account_controller.rb",
|
54
|
+
"spec/fixtures/app/helpers/account_helper.rb",
|
55
|
+
"spec/fixtures/app/models/account.rb",
|
56
|
+
"spec/fixtures/app/views/account/edit.html.erb",
|
57
|
+
"spec/fixtures/app/views/account/show.html.erb",
|
58
|
+
"spec/fixtures/db/migrations/20100904095012_create_account.rb",
|
59
|
+
"spec/rails3_artifactor/artifact/crud/controller_spec.rb",
|
60
|
+
"spec/rails3_artifactor/artifact/crud/helper_spec.rb",
|
61
|
+
"spec/rails3_artifactor/artifact/crud/migration_spec.rb",
|
62
|
+
"spec/rails3_artifactor/artifact/crud/model_spec.rb",
|
63
|
+
"spec/rails3_artifactor/artifact/crud/observer_spec.rb",
|
64
|
+
"spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb",
|
65
|
+
"spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb",
|
66
|
+
"spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb",
|
67
|
+
"spec/rails3_artifactor/artifact/file_name/migration_spec.rb",
|
68
|
+
"spec/rails3_artifactor/artifact/file_name/view_spec.rb",
|
69
|
+
"spec/rails3_artifactor/artifact/markers_spec.rb",
|
70
|
+
"spec/rails3_artifactor/artifact/migration_spec.rb",
|
71
|
+
"spec/rails3_artifactor/artifact/orm/active_record_spec.rb",
|
72
|
+
"spec/rails3_artifactor/artifact/orm/data_mapper_spec.rb",
|
73
|
+
"spec/rails3_artifactor/artifact/orm/mongo_mapper_spec.rb",
|
74
|
+
"spec/rails3_artifactor/artifact/orm/mongoid_spec.rb",
|
75
|
+
"spec/rails3_artifactor/artifact/orm/none_spec.rb",
|
76
|
+
"spec/rails3_artifactor/base/crud/create_spec.rb",
|
77
|
+
"spec/rails3_artifactor/base/crud/delete_spec.rb",
|
78
|
+
"spec/rails3_artifactor/base/crud/read_spec.rb",
|
79
|
+
"spec/rails3_artifactor/base/crud/update_spec.rb",
|
80
|
+
"spec/rails3_artifactor/base/file_name_spec.rb",
|
81
|
+
"spec/spec_helper.rb"
|
82
|
+
]
|
83
|
+
s.homepage = %q{http://github.com/kristianmandrup/rails3_artifact_helper}
|
84
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
85
|
+
s.require_paths = ["lib"]
|
86
|
+
s.rubygems_version = %q{1.3.7}
|
87
|
+
s.summary = %q{Helpers for handling Rails 3 artifacts}
|
88
|
+
s.test_files = [
|
89
|
+
"spec/fixtures/app/controllers/account_controller.rb",
|
90
|
+
"spec/fixtures/app/helpers/account_helper.rb",
|
91
|
+
"spec/fixtures/app/models/account.rb",
|
92
|
+
"spec/fixtures/db/migrations/20100904095012_create_account.rb",
|
93
|
+
"spec/fixtures.rb",
|
94
|
+
"spec/rails3_artifactor/artifact/base_spec.rb",
|
95
|
+
"spec/rails3_artifactor/artifact/crud/controller_spec.rb",
|
96
|
+
"spec/rails3_artifactor/artifact/crud/helper_spec.rb",
|
97
|
+
"spec/rails3_artifactor/artifact/crud/migration_spec.rb",
|
98
|
+
"spec/rails3_artifactor/artifact/crud/model_spec.rb",
|
99
|
+
"spec/rails3_artifactor/artifact/crud/observer_spec.rb",
|
100
|
+
"spec/rails3_artifactor/artifact/crud/view_controller_action_spec.rb",
|
101
|
+
"spec/rails3_artifactor/artifact/crud/view_controller_default_action_spec.rb",
|
102
|
+
"spec/rails3_artifactor/artifact/file_name/artifacts_spec.rb",
|
103
|
+
"spec/rails3_artifactor/artifact/file_name/migration_spec.rb",
|
104
|
+
"spec/rails3_artifactor/artifact/file_name/view_spec.rb",
|
105
|
+
"spec/rails3_artifactor/artifact/markers_spec.rb",
|
106
|
+
"spec/rails3_artifactor/artifact/migration_spec.rb",
|
107
|
+
"spec/rails3_artifactor/artifact/orm/active_record_spec.rb",
|
108
|
+
"spec/rails3_artifactor/artifact/orm/data_mapper_spec.rb",
|
109
|
+
"spec/rails3_artifactor/artifact/orm/mongo_mapper_spec.rb",
|
110
|
+
"spec/rails3_artifactor/artifact/orm/mongoid_spec.rb",
|
111
|
+
"spec/rails3_artifactor/artifact/orm/none_spec.rb",
|
112
|
+
"spec/rails3_artifactor/base/crud/create_spec.rb",
|
113
|
+
"spec/rails3_artifactor/base/crud/delete_spec.rb",
|
114
|
+
"spec/rails3_artifactor/base/crud/read_spec.rb",
|
115
|
+
"spec/rails3_artifactor/base/crud/update_spec.rb",
|
116
|
+
"spec/rails3_artifactor/base/file_name_spec.rb",
|
117
|
+
"spec/spec_helper.rb"
|
118
|
+
]
|
119
|
+
|
120
|
+
if s.respond_to? :specification_version then
|
121
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
122
|
+
s.specification_version = 3
|
123
|
+
|
124
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
125
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
|
126
|
+
s.add_runtime_dependency(%q<require_all>, ["~> 1.1.0"])
|
127
|
+
else
|
128
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
129
|
+
s.add_dependency(%q<require_all>, ["~> 1.1.0"])
|
130
|
+
end
|
131
|
+
else
|
132
|
+
s.add_dependency(%q<rspec>, ["~> 2.0.0"])
|
133
|
+
s.add_dependency(%q<require_all>, ["~> 1.1.0"])
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Helper
|
4
|
+
include Rails3::Assist::BaseHelper
|
5
|
+
end
|
6
|
+
|
7
|
+
describe 'BaseHelper' do
|
8
|
+
describe '#marker_option' do
|
9
|
+
|
10
|
+
it "should return marker option" do
|
11
|
+
helper = Helper.new
|
12
|
+
helper.stubs(:model_marker).returns 'Account'
|
13
|
+
res = helper.send :marker_option, :account, :type => :model
|
14
|
+
res[:after].should == 'Account'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,13 +1,31 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'model without orm' do
|
4
|
+
use_orm :none
|
5
|
+
use_helper :model
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
# remove_model :account
|
13
|
+
end
|
14
|
+
|
2
15
|
describe '#new_artifact_content' do
|
3
|
-
it "should
|
4
|
-
|
16
|
+
it "should create artifact content" do
|
17
|
+
content = new_artifact_content :person, :content => '# Hello', :type => :model
|
18
|
+
content.should have_comment 'Hello'
|
5
19
|
end
|
6
20
|
end
|
7
21
|
|
8
22
|
describe '#create_artifact' do
|
9
|
-
it "should
|
10
|
-
|
23
|
+
it "should create artifact" do
|
24
|
+
create_artifact :person, :type => :model do
|
25
|
+
'# Hello'
|
26
|
+
end
|
27
|
+
|
28
|
+
has_model?(:person).should be_true
|
11
29
|
end
|
12
30
|
end
|
13
31
|
end
|
@@ -1,13 +1,48 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'model without orm' do
|
4
|
+
use_orm :none
|
5
|
+
use_helper :model
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
# remove_model :account
|
13
|
+
end
|
14
|
+
|
2
15
|
describe '#remove_artifact' do
|
3
|
-
|
4
|
-
|
16
|
+
before :each do
|
17
|
+
create_artifact :person, :type => :model do
|
18
|
+
'# Hello'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should remove artifact" do
|
23
|
+
has_model?(:person).should be_true
|
24
|
+
remove_artifact :person, :type => :model
|
25
|
+
has_model?(:person).should be_false
|
5
26
|
end
|
6
27
|
end
|
7
28
|
|
8
29
|
describe '#remove_artifacts' do
|
9
|
-
|
10
|
-
|
30
|
+
before :each do
|
31
|
+
create_artifact :person, :type => :model do
|
32
|
+
'# Hello'
|
33
|
+
end
|
34
|
+
create_artifact :user, :type => :model do
|
35
|
+
'# Hi'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should delete model artifacts :person and :user" do
|
40
|
+
|
41
|
+
has_models?(:user, :person).should be_true
|
42
|
+
|
43
|
+
remove_artifacts :person, :user, :type => :model
|
44
|
+
|
45
|
+
has_models?(:person, :user).should be_false
|
11
46
|
end
|
12
47
|
end
|
13
48
|
end
|
@@ -1,21 +1,77 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
CONTENT = %q{
|
4
|
+
# Hello
|
5
|
+
# Intro
|
6
|
+
# Goodbye
|
7
|
+
}
|
8
|
+
|
9
|
+
describe 'model without orm' do
|
10
|
+
use_orm :none
|
11
|
+
use_helper :model
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
after :each do
|
18
|
+
# remove_model :account
|
19
|
+
end
|
20
|
+
|
2
21
|
describe '#read_artifact' do
|
3
|
-
|
4
|
-
|
22
|
+
before :each do
|
23
|
+
create_artifact :person, :type => :model do
|
24
|
+
CONTENT
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
after :each do
|
29
|
+
remove_model :person
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should read artifact" do
|
33
|
+
content = read_artifact :person, :type => :model
|
34
|
+
content.should have_comment 'Hello'
|
5
35
|
end
|
6
36
|
end
|
7
37
|
|
8
38
|
describe '#read_artifact :before' do
|
9
|
-
|
10
|
-
|
39
|
+
before :each do
|
40
|
+
create_artifact :person, :type => :model do
|
41
|
+
CONTENT
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
after :each do
|
46
|
+
remove_model :person
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should read before 'Hello'" do
|
50
|
+
content = read_artifact :person, :type => :model, :before => 'Intro'
|
51
|
+
content.should have_comment 'Hello'
|
52
|
+
content.should_not have_comment 'Goodbye'
|
11
53
|
end
|
12
54
|
end
|
13
55
|
|
14
56
|
describe '#read_artifact :after' do
|
15
|
-
|
16
|
-
|
57
|
+
before :each do
|
58
|
+
create_artifact :person, :type => :model do
|
59
|
+
CONTENT
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
after :each do
|
64
|
+
remove_model :person
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should read after 'Hello' " do
|
68
|
+
content = read_artifact :person, :type => :model, :after => 'Intro'
|
69
|
+
content.should have_comment 'Goodbye'
|
70
|
+
content.should_not have_comment 'Hello'
|
17
71
|
end
|
18
72
|
end
|
73
|
+
|
74
|
+
|
19
75
|
end
|
20
76
|
|
21
77
|
|
@@ -1,21 +1,71 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'model without orm' do
|
4
|
+
use_orm :none
|
5
|
+
use_helper :model
|
6
|
+
|
7
|
+
before :each do
|
8
|
+
Rails3::Assist::Directory.rails_root = fixtures_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
# remove_model :account
|
13
|
+
end
|
14
|
+
|
2
15
|
describe '#insert_into_artifact' do
|
3
|
-
it "should
|
4
|
-
|
16
|
+
it "should insert_into_artifact" do
|
17
|
+
insert_into_artifact :account, :type => :model do
|
18
|
+
'# hi there'
|
19
|
+
end
|
20
|
+
|
21
|
+
insert_into_artifact :account, :type => :model, :content => '# hi there'
|
22
|
+
|
23
|
+
content = read_artifact :account, :type => :model, :after => 'Account'
|
24
|
+
content.should have_comment 'hi there'
|
5
25
|
end
|
6
26
|
end
|
7
27
|
|
28
|
+
describe '#replace_from_artifact' do
|
29
|
+
it "should replace content from artifact" do
|
30
|
+
replace_in_artifact :account, :type => :model, :content => '# hi there', :with => '# howdy'
|
31
|
+
|
32
|
+
content = read_artifact :account, :type => :model, :after => 'Account'
|
33
|
+
content.should have_comment 'howdy'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#update_artifacts' do
|
38
|
+
it "should remove content from artifact" do
|
39
|
+
update_artifacts :account, :type => :model, :content => 'howdy', :with => 'hi there'
|
40
|
+
|
41
|
+
content = read_artifact :account, :type => :model, :after => 'Account'
|
42
|
+
content.should have_comment 'hi there'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
8
47
|
describe '#remove_from_artifact' do
|
9
|
-
it "should
|
10
|
-
|
48
|
+
it "should remove content from artifact" do
|
49
|
+
remove_from_artifact :account, :type => :model, :content => '# hi there'
|
50
|
+
|
51
|
+
content = read_artifact :account, :type => :model, :after => 'Account'
|
52
|
+
content.should_not have_comment 'hi there'
|
11
53
|
end
|
12
54
|
end
|
13
55
|
|
14
|
-
describe '#
|
15
|
-
it "should
|
16
|
-
|
56
|
+
describe '#remove_from_artifacts' do
|
57
|
+
it "should remove content from artifact" do
|
58
|
+
insert_into_artifact :account, :type => :model do
|
59
|
+
'# hi there'
|
60
|
+
end
|
61
|
+
|
62
|
+
remove_from_artifacts :account, :type => :model, :content => '# hi there'
|
63
|
+
|
64
|
+
content = read_artifact :account, :type => :model, :after => 'Account'
|
65
|
+
content.should_not have_comment 'hi there'
|
17
66
|
end
|
18
67
|
end
|
68
|
+
|
19
69
|
end
|
20
70
|
|
21
71
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Mandrup
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- .document
|
61
61
|
- .gitignore
|
62
62
|
- .rspec
|
63
|
+
- DESIGN_NOTES.markdown
|
63
64
|
- LICENSE
|
64
65
|
- README.markdown
|
65
66
|
- Rakefile
|
@@ -78,7 +79,6 @@ files:
|
|
78
79
|
- lib/rails3_artifactor/artifact/orm/mongo_mapper.rb
|
79
80
|
- lib/rails3_artifactor/artifact/orm/mongoid.rb
|
80
81
|
- lib/rails3_artifactor/artifact/orm/none.rb
|
81
|
-
- lib/rails3_artifactor/base/class_methods.rb
|
82
82
|
- lib/rails3_artifactor/base/crud.rb
|
83
83
|
- lib/rails3_artifactor/base/crud/create.rb
|
84
84
|
- lib/rails3_artifactor/base/crud/delete.rb
|
@@ -88,11 +88,11 @@ files:
|
|
88
88
|
- lib/rails3_artifactor/namespaces.rb
|
89
89
|
- lib/rails3_artifactor/rspec/configure.rb
|
90
90
|
- lib/rails3_artifactor/rspec/macro.rb
|
91
|
+
- rails3_artifactor.gemspec
|
91
92
|
- spec/fixtures.rb
|
92
93
|
- spec/fixtures/app/controllers/account_controller.rb
|
93
94
|
- spec/fixtures/app/helpers/account_helper.rb
|
94
95
|
- spec/fixtures/app/models/account.rb
|
95
|
-
- spec/fixtures/app/models/account_observer.rb
|
96
96
|
- spec/fixtures/app/views/account/edit.html.erb
|
97
97
|
- spec/fixtures/app/views/account/show.html.erb
|
98
98
|
- spec/fixtures/db/migrations/20100904095012_create_account.rb
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- spec/rails3_artifactor/base/crud/update_spec.rb
|
120
120
|
- spec/rails3_artifactor/base/file_name_spec.rb
|
121
121
|
- spec/spec_helper.rb
|
122
|
+
- spec/rails3_artifactor/artifact/base_spec.rb
|
122
123
|
has_rdoc: true
|
123
124
|
homepage: http://github.com/kristianmandrup/rails3_artifact_helper
|
124
125
|
licenses: []
|
@@ -155,9 +156,9 @@ test_files:
|
|
155
156
|
- spec/fixtures/app/controllers/account_controller.rb
|
156
157
|
- spec/fixtures/app/helpers/account_helper.rb
|
157
158
|
- spec/fixtures/app/models/account.rb
|
158
|
-
- spec/fixtures/app/models/account_observer.rb
|
159
159
|
- spec/fixtures/db/migrations/20100904095012_create_account.rb
|
160
160
|
- spec/fixtures.rb
|
161
|
+
- spec/rails3_artifactor/artifact/base_spec.rb
|
161
162
|
- spec/rails3_artifactor/artifact/crud/controller_spec.rb
|
162
163
|
- spec/rails3_artifactor/artifact/crud/helper_spec.rb
|
163
164
|
- spec/rails3_artifactor/artifact/crud/migration_spec.rb
|