modalfields 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +133 -0
- data/Rakefile +49 -0
- data/TODO +33 -0
- data/VERSION +1 -0
- data/lib/modalfields.rb +13 -0
- data/lib/modalfields/modalfields.rb +428 -0
- data/lib/modalfields/standardfields.rb +13 -0
- data/lib/modalfields/tasks.rb +1 -0
- data/lib/tasks/check.rake +6 -0
- data/lib/tasks/migrate.rake +17 -0
- data/lib/tasks/update.rake +6 -0
- data/test/create_database.rb +47 -0
- data/test/database.yml +11 -0
- data/test/helper.rb +61 -0
- data/test/model_cases/bare/after/author.rb +12 -0
- data/test/model_cases/bare/after/book.rb +12 -0
- data/test/model_cases/bare/before/author.rb +3 -0
- data/test/model_cases/bare/before/book.rb +4 -0
- data/test/model_cases/clean/after/author.rb +14 -0
- data/test/model_cases/clean/after/book.rb +14 -0
- data/test/model_cases/clean/before/author.rb +14 -0
- data/test/model_cases/clean/before/book.rb +14 -0
- data/test/model_cases/dirty/after/author.rb +14 -0
- data/test/model_cases/dirty/after/book.rb +14 -0
- data/test/model_cases/dirty/before/author.rb +15 -0
- data/test/model_cases/dirty/before/book.rb +14 -0
- data/test/schema.rb +17 -0
- data/test/test_diff.rb +127 -0
- data/test/test_update.rb +52 -0
- metadata +228 -0
data/test/test_update.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.dirname(__FILE__)+'/helper'
|
2
|
+
|
3
|
+
def setup_model_case(case_id)
|
4
|
+
load_schema
|
5
|
+
FileUtils.mkdir_p File.dirname(__FILE__)+"/app/models"
|
6
|
+
FileUtils.cp Dir[File.dirname(__FILE__)+"/model_cases/#{case_id}/before/*.rb"], File.dirname(__FILE__)+"/app/models/"
|
7
|
+
Dir[File.dirname(__FILE__)+"/app/models/*.rb"].each do |model_file|
|
8
|
+
puts "Loading #{model_file}"
|
9
|
+
load model_file
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown_model_case(case_id)
|
14
|
+
Object.send(:remove_const, :Author) if defined?(Author)
|
15
|
+
Object.send(:remove_const, :Book) if defined?(Book)
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_model_case(case_id)
|
19
|
+
ModalFields.update
|
20
|
+
Dir[File.dirname(__FILE__)+"/model_cases/#{case_id}/after/*.rb"].each do |ref_model_file|
|
21
|
+
model_file = File.dirname(__FILE__)+"/app/models/" + File.basename(ref_model_file)
|
22
|
+
assert_equal File.read(ref_model_file), File.read(model_file)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class TestUpdate < Test::Unit::TestCase
|
27
|
+
|
28
|
+
context "Given model definitions without field declarations, update" do
|
29
|
+
setup { setup_model_case 'bare' }
|
30
|
+
should "annotate the models with proper field declarations" do
|
31
|
+
check_model_case 'bare'
|
32
|
+
end
|
33
|
+
teardown { teardown_model_case 'bare' }
|
34
|
+
end
|
35
|
+
|
36
|
+
context "Given model definitions with up-to-date field declarations, update" do
|
37
|
+
setup { setup_model_case 'clean' }
|
38
|
+
should "not modify them" do
|
39
|
+
check_model_case 'clean'
|
40
|
+
end
|
41
|
+
teardown { teardown_model_case 'clean' }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "Given model definitions with outdated field declarations, update" do
|
45
|
+
setup { setup_model_case 'dirty' }
|
46
|
+
should "fix them preserving comments and specifiers" do
|
47
|
+
check_model_case 'dirty'
|
48
|
+
end
|
49
|
+
teardown { teardown_model_case 'dirty' }
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modalfields
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Javier Goizueta
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.5
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.3.5
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activerecord
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.3.5
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.3.5
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: shoulda
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rdoc
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.12'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.12'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: bundler
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: jeweler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.3
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.8.3
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: sqlite3
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: pg
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rails
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 2.3.0
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 2.3.0
|
158
|
+
description: ModelFields is a Rails plugin that adds fields declarations to your models.
|
159
|
+
email: jgoizueta@gmail.com
|
160
|
+
executables: []
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files:
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.rdoc
|
165
|
+
- TODO
|
166
|
+
files:
|
167
|
+
- .document
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.rdoc
|
172
|
+
- Rakefile
|
173
|
+
- TODO
|
174
|
+
- VERSION
|
175
|
+
- lib/modalfields.rb
|
176
|
+
- lib/modalfields/modalfields.rb
|
177
|
+
- lib/modalfields/standardfields.rb
|
178
|
+
- lib/modalfields/tasks.rb
|
179
|
+
- lib/tasks/check.rake
|
180
|
+
- lib/tasks/migrate.rake
|
181
|
+
- lib/tasks/update.rake
|
182
|
+
- test/create_database.rb
|
183
|
+
- test/database.yml
|
184
|
+
- test/helper.rb
|
185
|
+
- test/model_cases/bare/after/author.rb
|
186
|
+
- test/model_cases/bare/after/book.rb
|
187
|
+
- test/model_cases/bare/before/author.rb
|
188
|
+
- test/model_cases/bare/before/book.rb
|
189
|
+
- test/model_cases/clean/after/author.rb
|
190
|
+
- test/model_cases/clean/after/book.rb
|
191
|
+
- test/model_cases/clean/before/author.rb
|
192
|
+
- test/model_cases/clean/before/book.rb
|
193
|
+
- test/model_cases/dirty/after/author.rb
|
194
|
+
- test/model_cases/dirty/after/book.rb
|
195
|
+
- test/model_cases/dirty/before/author.rb
|
196
|
+
- test/model_cases/dirty/before/book.rb
|
197
|
+
- test/schema.rb
|
198
|
+
- test/test_diff.rb
|
199
|
+
- test/test_update.rb
|
200
|
+
homepage: http://github.com/jgoizueta/modalfields
|
201
|
+
licenses:
|
202
|
+
- MIT
|
203
|
+
post_install_message:
|
204
|
+
rdoc_options: []
|
205
|
+
require_paths:
|
206
|
+
- lib
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
208
|
+
none: false
|
209
|
+
requirements:
|
210
|
+
- - ! '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
segments:
|
214
|
+
- 0
|
215
|
+
hash: -737536039734340939
|
216
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: '0'
|
222
|
+
requirements: []
|
223
|
+
rubyforge_project:
|
224
|
+
rubygems_version: 1.8.21
|
225
|
+
signing_key:
|
226
|
+
specification_version: 3
|
227
|
+
summary: Model annotator with Ruby (Hobo-like) syntax and hooks.
|
228
|
+
test_files: []
|