hobo 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/hobo +24 -7
- data/hobo_files/plugin/CHANGES.txt +501 -0
- data/hobo_files/plugin/generators/hobo/hobo_generator.rb +8 -6
- data/hobo_files/plugin/generators/hobo/templates/application.dryml +3 -0
- data/hobo_files/plugin/generators/hobo/templates/dryml-support.js +132 -0
- data/hobo_files/plugin/generators/hobo_front_controller/hobo_front_controller_generator.rb +4 -5
- data/hobo_files/plugin/generators/hobo_model_resource/hobo_model_resource_generator.rb +75 -0
- data/hobo_files/plugin/generators/hobo_model_resource/templates/controller.rb +7 -0
- data/hobo_files/plugin/generators/hobo_model_resource/templates/functional_test.rb +8 -0
- data/hobo_files/plugin/generators/hobo_model_resource/templates/helper.rb +2 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +30 -11
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/application.css +149 -92
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +0 -48
- data/hobo_files/plugin/init.rb +45 -13
- data/hobo_files/plugin/lib/action_view_extensions/base.rb +4 -3
- data/hobo_files/plugin/lib/active_record/association_proxy.rb +18 -0
- data/hobo_files/plugin/lib/active_record/association_reflection.rb +5 -0
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +7 -11
- data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +8 -0
- data/hobo_files/plugin/lib/extensions/test_case.rb +1 -1
- data/hobo_files/plugin/lib/hobo.rb +38 -60
- data/hobo_files/plugin/lib/hobo/authentication_support.rb +1 -1
- data/hobo_files/plugin/lib/hobo/bundle.rb +131 -34
- data/hobo_files/plugin/lib/hobo/composite_model.rb +1 -1
- data/hobo_files/plugin/lib/hobo/controller.rb +7 -8
- data/hobo_files/plugin/lib/hobo/dev_controller.rb +21 -0
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +14 -8
- data/hobo_files/plugin/lib/hobo/dryml/dryml_support_controller.rb +13 -0
- data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +6 -7
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +207 -73
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +67 -55
- data/hobo_files/plugin/lib/hobo/dryml/template_handler.rb +53 -3
- data/hobo_files/plugin/lib/hobo/hobo_helper.rb +75 -107
- data/hobo_files/plugin/lib/hobo/model.rb +236 -429
- data/hobo_files/plugin/lib/hobo/model_controller.rb +277 -437
- data/hobo_files/plugin/lib/hobo/model_router.rb +62 -29
- data/hobo_files/plugin/lib/hobo/rapid_helper.rb +48 -9
- data/hobo_files/plugin/lib/hobo/scopes.rb +98 -0
- data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +31 -0
- data/hobo_files/plugin/lib/hobo/scopes/automatic_scopes.rb +282 -0
- data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +88 -0
- data/hobo_files/plugin/lib/hobo/scopes/scope_reflection.rb +18 -0
- data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +59 -0
- data/hobo_files/plugin/lib/hobo/undefined.rb +2 -0
- data/hobo_files/plugin/lib/hobo/user.rb +31 -14
- data/hobo_files/plugin/lib/hobo/user_controller.rb +41 -27
- data/hobo_files/plugin/taglibs/core.dryml +9 -11
- data/hobo_files/plugin/taglibs/rapid.dryml +51 -108
- data/hobo_files/plugin/taglibs/rapid_editing.dryml +25 -25
- data/hobo_files/plugin/taglibs/rapid_forms.dryml +111 -79
- data/hobo_files/plugin/taglibs/rapid_generics.dryml +74 -0
- data/hobo_files/plugin/taglibs/rapid_navigation.dryml +23 -21
- data/hobo_files/plugin/taglibs/rapid_pages.dryml +83 -169
- data/hobo_files/plugin/taglibs/rapid_plus.dryml +16 -2
- data/hobo_files/plugin/taglibs/rapid_support.dryml +3 -3
- data/hobo_files/plugin/taglibs/rapid_user_pages.dryml +104 -0
- metadata +60 -55
- data/hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb +0 -276
- data/hobo_files/plugin/generators/hobo_migration/templates/migration.rb +0 -9
- data/hobo_files/plugin/lib/active_record/table_definition.rb +0 -34
- data/hobo_files/plugin/lib/extensions.rb +0 -375
- data/hobo_files/plugin/lib/hobo/email_address.rb +0 -12
- data/hobo_files/plugin/lib/hobo/enum_string.rb +0 -50
- data/hobo_files/plugin/lib/hobo/field_declaration_dsl.rb +0 -43
- data/hobo_files/plugin/lib/hobo/field_spec.rb +0 -68
- data/hobo_files/plugin/lib/hobo/html_string.rb +0 -7
- data/hobo_files/plugin/lib/hobo/lazy_hash.rb +0 -40
- data/hobo_files/plugin/lib/hobo/markdown_string.rb +0 -11
- data/hobo_files/plugin/lib/hobo/migrations.rb +0 -12
- data/hobo_files/plugin/lib/hobo/model_queries.rb +0 -117
- data/hobo_files/plugin/lib/hobo/password_string.rb +0 -7
- data/hobo_files/plugin/lib/hobo/percentage.rb +0 -14
- data/hobo_files/plugin/lib/hobo/predicate_dispatch.rb +0 -78
- data/hobo_files/plugin/lib/hobo/proc_binding.rb +0 -32
- data/hobo_files/plugin/lib/hobo/text.rb +0 -3
- data/hobo_files/plugin/lib/hobo/textile_string.rb +0 -25
- data/hobo_files/plugin/lib/hobo/where_fragment.rb +0 -28
@@ -1,34 +0,0 @@
|
|
1
|
-
module ActiveRecord::ConnectionAdapters
|
2
|
-
|
3
|
-
class TableDefinition
|
4
|
-
|
5
|
-
def fkey(*args)
|
6
|
-
options = take_options!(args)
|
7
|
-
args.each {|col| column("#{col}_id".to_sym, :integer, options)}
|
8
|
-
end
|
9
|
-
|
10
|
-
def auto_dates
|
11
|
-
column :created_at, :datetime
|
12
|
-
column :updated_at, :datetime
|
13
|
-
end
|
14
|
-
|
15
|
-
def method_missing(name, *args)
|
16
|
-
if name.in? [:integer, :float, :decimal, :datetime, :date, :timestamp,
|
17
|
-
:time, :text, :string, :binary, :boolean ]
|
18
|
-
options = take_options!(args)
|
19
|
-
args.each {|col| column(col, name, options)}
|
20
|
-
else
|
21
|
-
super
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def take_options!(args)
|
29
|
-
args.last.is_a?(Hash) ? args.pop : {}
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,375 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
|
3
|
-
def inheriting_attr_accessor(*names)
|
4
|
-
for name in names
|
5
|
-
class_eval %{
|
6
|
-
def #{name}
|
7
|
-
if defined? @#{name}
|
8
|
-
@#{name}
|
9
|
-
elsif superclass.respond_to?('#{name}')
|
10
|
-
superclass.#{name}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
}
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
# Custom alias_method_chain that won't cause inifinite recursion if
|
18
|
-
# called twice.
|
19
|
-
# Calling alias_method_chain on alias_method_chain
|
20
|
-
# was just way to confusing, so I copied it :-/
|
21
|
-
def alias_method_chain(target, feature)
|
22
|
-
# Strip out punctuation on predicates or bang methods since
|
23
|
-
# e.g. target?_without_feature is not a valid method name.
|
24
|
-
aliased_target, punctuation = target.to_s.sub(/([?!=])$/, ''), $1
|
25
|
-
yield(aliased_target, punctuation) if block_given?
|
26
|
-
without = "#{aliased_target}_without_#{feature}#{punctuation}"
|
27
|
-
unless instance_methods.include?(without)
|
28
|
-
alias_method without, target
|
29
|
-
alias_method target, "#{aliased_target}_with_#{feature}#{punctuation}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
# Fix delegate so it doesn't go bang if 'to' is nil
|
35
|
-
def delegate(*methods)
|
36
|
-
options = methods.pop
|
37
|
-
unless options.is_a?(Hash) && to = options[:to]
|
38
|
-
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
|
39
|
-
end
|
40
|
-
|
41
|
-
methods.each do |method|
|
42
|
-
module_eval(<<-EOS, "(__DELEGATION__)", 1)
|
43
|
-
def #{method}(*args, &block)
|
44
|
-
(_to = #{to}) && _to.__send__(#{method.inspect}, *args, &block)
|
45
|
-
end
|
46
|
-
EOS
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def bool_attr_accessor(*args)
|
53
|
-
options = extract_options_from_args!(args)
|
54
|
-
(args + options.keys).each {|n| class_eval "def #{n}=(x); @#{n} = x; end" }
|
55
|
-
|
56
|
-
args.each {|n| class_eval "def #{n}?; !!@#{n}; end" }
|
57
|
-
|
58
|
-
options.keys.each do |n|
|
59
|
-
class_eval %(def #{n}?
|
60
|
-
if @#{n}.nil? && !instance_variables.include?("@\#{@#{n}}")
|
61
|
-
@#{n} = #{options[n].inspect}
|
62
|
-
else
|
63
|
-
@#{n}
|
64
|
-
end
|
65
|
-
end)
|
66
|
-
set_field_type(n => TrueClass) if respond_to?(:set_field_type)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
module Kernel
|
73
|
-
|
74
|
-
def extract_options_from_args!(args) #:nodoc:
|
75
|
-
args.last.is_a?(Hash) ? args.pop : {}
|
76
|
-
end
|
77
|
-
|
78
|
-
def it() It.new end
|
79
|
-
alias its it
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
|
84
|
-
class It
|
85
|
-
|
86
|
-
undef_method(*(instance_methods - %w*__id__ __send__*))
|
87
|
-
|
88
|
-
def initialize
|
89
|
-
@methods = []
|
90
|
-
end
|
91
|
-
|
92
|
-
def method_missing(*args, &block)
|
93
|
-
@methods << [args, block] unless args == [:respond_to?, :to_proc]
|
94
|
-
self
|
95
|
-
end
|
96
|
-
|
97
|
-
def to_proc
|
98
|
-
lambda do |obj|
|
99
|
-
@methods.inject(obj) do |current,(args,block)|
|
100
|
-
current.send(*args, &block)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
class Object
|
108
|
-
|
109
|
-
def in?(array)
|
110
|
-
array.include?(self)
|
111
|
-
end
|
112
|
-
|
113
|
-
def not_in?(array)
|
114
|
-
not array.include?(self)
|
115
|
-
end
|
116
|
-
|
117
|
-
alias_method :is_a_without_multiple_args?, :is_a?
|
118
|
-
def is_a?(*args)
|
119
|
-
args.any? {|a| is_a_without_multiple_args?(a) }
|
120
|
-
end
|
121
|
-
|
122
|
-
# metaid
|
123
|
-
def metaclass; class << self; self; end; end
|
124
|
-
def meta_eval &blk; metaclass.instance_eval &blk; end
|
125
|
-
|
126
|
-
# Adds methods to a metaclass
|
127
|
-
def meta_def name, &blk
|
128
|
-
meta_eval { define_method name, &blk }
|
129
|
-
end
|
130
|
-
|
131
|
-
# Defines an instance method within a class
|
132
|
-
def class_def name, &blk
|
133
|
-
class_eval { define_method name, &blk }
|
134
|
-
end
|
135
|
-
|
136
|
-
def _?()
|
137
|
-
self
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
class NilClass
|
144
|
-
def _?()
|
145
|
-
SafeNil.instance
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
|
150
|
-
class SafeNil
|
151
|
-
include Singleton
|
152
|
-
|
153
|
-
def method_missing(method, *args, &b)
|
154
|
-
return nil unless nil.respond_to? method
|
155
|
-
nil.send(method, *args, &b) rescue nil
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
alias DelegateClass_without_safe_nil DelegateClass
|
160
|
-
def DelegateClass(klass)
|
161
|
-
c = DelegateClass_without_safe_nil(klass)
|
162
|
-
c.class_eval do
|
163
|
-
def _?
|
164
|
-
self
|
165
|
-
end
|
166
|
-
end
|
167
|
-
c
|
168
|
-
end
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
class TrueClass
|
173
|
-
|
174
|
-
def implies(x)
|
175
|
-
x
|
176
|
-
end
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
class FalseClass
|
181
|
-
|
182
|
-
def implies(x)
|
183
|
-
true
|
184
|
-
end
|
185
|
-
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
module Enumerable
|
190
|
-
|
191
|
-
def search(not_found=nil)
|
192
|
-
each do |x|
|
193
|
-
val = yield(x)
|
194
|
-
return val if val
|
195
|
-
end
|
196
|
-
not_found
|
197
|
-
end
|
198
|
-
|
199
|
-
def every(method, *args)
|
200
|
-
map { |x| x.send(method, *args) }
|
201
|
-
end
|
202
|
-
|
203
|
-
def map_with_index
|
204
|
-
res = []
|
205
|
-
each_with_index {|x, i| res << yield(x, i)}
|
206
|
-
res
|
207
|
-
end
|
208
|
-
|
209
|
-
def build_hash
|
210
|
-
res = {}
|
211
|
-
each do |x|
|
212
|
-
k, v = yield x
|
213
|
-
res[k] = v
|
214
|
-
end
|
215
|
-
res
|
216
|
-
end
|
217
|
-
|
218
|
-
def map_hash
|
219
|
-
res = {}
|
220
|
-
each do |x|
|
221
|
-
v = yield x
|
222
|
-
res[x] = v
|
223
|
-
end
|
224
|
-
res
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
228
|
-
|
229
|
-
class Hash
|
230
|
-
|
231
|
-
def self.build(array)
|
232
|
-
array.inject({}) do |res, x|
|
233
|
-
k, v = yield x
|
234
|
-
res[k] = v
|
235
|
-
res
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
def select_hash(new_keys=nil)
|
240
|
-
res = {}
|
241
|
-
if block_given?
|
242
|
-
each {|k,v| res[k] = v if yield(k,v) }
|
243
|
-
else
|
244
|
-
new_keys.each {|k| res[k] = self[k] if self.has_key?(k)}
|
245
|
-
end
|
246
|
-
res
|
247
|
-
end
|
248
|
-
|
249
|
-
def map_hash(&b)
|
250
|
-
res = {}
|
251
|
-
each {|k,v| res[k] = b.arity == 1 ? yield(v) : yield(k, v) }
|
252
|
-
res
|
253
|
-
end
|
254
|
-
|
255
|
-
#alias_method :hobo_original_reject, :reject
|
256
|
-
def rejectX(keys=nil, &b)
|
257
|
-
if b
|
258
|
-
hobo_original_reject(&b)
|
259
|
-
else
|
260
|
-
res = {}.update(self) # can't use dup because it breaks with symbols
|
261
|
-
keys.each {|k| res.delete(k)}
|
262
|
-
res
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
def partition_hash(keys=nil)
|
267
|
-
yes = {}
|
268
|
-
no = {}
|
269
|
-
each do |k,v|
|
270
|
-
if block_given? ? yield(k,v) : keys.include?(k)
|
271
|
-
yes[k] = v
|
272
|
-
else
|
273
|
-
no[k] = v
|
274
|
-
end
|
275
|
-
end
|
276
|
-
[yes, no]
|
277
|
-
end
|
278
|
-
|
279
|
-
def -(keys)
|
280
|
-
res = {}
|
281
|
-
each_pair {|k, v| res[k] = v unless k.in?(keys)}
|
282
|
-
res
|
283
|
-
end
|
284
|
-
|
285
|
-
def &(keys)
|
286
|
-
res = {}
|
287
|
-
keys.each {|k| res[k] = self[k] if has_key?(k)}
|
288
|
-
res
|
289
|
-
end
|
290
|
-
|
291
|
-
end
|
292
|
-
|
293
|
-
|
294
|
-
class HashWithIndifferentAccess
|
295
|
-
|
296
|
-
def -(keys)
|
297
|
-
res = HashWithIndifferentAccess.new
|
298
|
-
keys = keys.map {|k| k.is_a?(Symbol) ? k.to_s : k }
|
299
|
-
each_pair { |k, v| res[k] = v unless k.in?(keys) }
|
300
|
-
res
|
301
|
-
end
|
302
|
-
|
303
|
-
def &(keys)
|
304
|
-
res = HashWithIndifferentAccess.new
|
305
|
-
keys.each do |k|
|
306
|
-
k = k.to_s if k.is_a?(Symbol)
|
307
|
-
res[k] = self[k] if has_key?(k)
|
308
|
-
end
|
309
|
-
res
|
310
|
-
end
|
311
|
-
|
312
|
-
def partition_hash(keys=nil)
|
313
|
-
keys = keys._?.map {|k| k.is_a?(Symbol) ? k.to_s : k }
|
314
|
-
yes = HashWithIndifferentAccess.new
|
315
|
-
no = HashWithIndifferentAccess.new
|
316
|
-
each do |k,v|
|
317
|
-
if block_given? ? yield(k,v) : keys.include?(k)
|
318
|
-
yes[k] = v
|
319
|
-
else
|
320
|
-
no[k] = v
|
321
|
-
end
|
322
|
-
end
|
323
|
-
[yes, no]
|
324
|
-
end
|
325
|
-
|
326
|
-
|
327
|
-
end
|
328
|
-
|
329
|
-
|
330
|
-
class <<ActiveRecord::Base
|
331
|
-
alias_method :[], :find
|
332
|
-
end
|
333
|
-
|
334
|
-
|
335
|
-
# --- Fix Chronic - can't parse '12th Jan' --- #
|
336
|
-
begin
|
337
|
-
require 'chronic'
|
338
|
-
|
339
|
-
module Chronic
|
340
|
-
|
341
|
-
class << self
|
342
|
-
def parse_with_hobo_fix(s)
|
343
|
-
parse_without_hobo_fix(if s =~ /^\s*\d+\s*(st|nd|rd|th)\s+[a-zA-Z]+(\s+\d+)?\s*$/
|
344
|
-
s.sub(/\s*\d+(st|nd|rd|th)/) {|s| s[0..-3]}
|
345
|
-
else
|
346
|
-
s
|
347
|
-
end)
|
348
|
-
end
|
349
|
-
alias_method_chain :parse, :hobo_fix
|
350
|
-
end
|
351
|
-
end
|
352
|
-
rescue MissingSourceFile; end
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
# --- Fix pp dumps - these break sometimes without this --- #
|
357
|
-
require 'pp'
|
358
|
-
module PP::ObjectMixin
|
359
|
-
|
360
|
-
alias_method :orig_pretty_print, :pretty_print
|
361
|
-
def pretty_print(q)
|
362
|
-
orig_pretty_print(q)
|
363
|
-
rescue
|
364
|
-
"[#PP-ERROR#]"
|
365
|
-
end
|
366
|
-
|
367
|
-
end
|
368
|
-
|
369
|
-
class Proc
|
370
|
-
|
371
|
-
def call_with_block(*args, &b)
|
372
|
-
call(*args + [b])
|
373
|
-
end
|
374
|
-
|
375
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Hobo::EmailAddress < String
|
2
|
-
|
3
|
-
COLUMN_TYPE = :string
|
4
|
-
|
5
|
-
def validate
|
6
|
-
"is not a valid email address" unless
|
7
|
-
self.blank? || self =~ /^\s*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*$/i
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
Hobo.field_types[:email_address] = Hobo::EmailAddress
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Hobo
|
2
|
-
|
3
|
-
class EnumString < String
|
4
|
-
|
5
|
-
module Helper
|
6
|
-
|
7
|
-
def enum_string(*values)
|
8
|
-
EnumString.for(*values)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
class << self
|
14
|
-
|
15
|
-
def with_values(*values)
|
16
|
-
@values = values.every(:to_s)
|
17
|
-
end
|
18
|
-
|
19
|
-
attr_accessor :values
|
20
|
-
|
21
|
-
def for(*values)
|
22
|
-
values = values.every(:to_s)
|
23
|
-
c = Class.new(EnumString) do
|
24
|
-
values.each do |v|
|
25
|
-
define_method("#{v.underscore}?") { self == v }
|
26
|
-
meta_def("#{v.underscore}") { v }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
c.with_values(*values)
|
30
|
-
c
|
31
|
-
end
|
32
|
-
|
33
|
-
def inspect
|
34
|
-
name.blank? ? "#<EnumString #{(values || []) * ' '}>" : name
|
35
|
-
end
|
36
|
-
alias_method :to_s, :inspect
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
COLUMN_TYPE = :string
|
41
|
-
|
42
|
-
def validate
|
43
|
-
"must be one of #{self.class.values * ', '}" unless self.in?(self.class.values)
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
Hobo::FieldDeclarationsDsl.send(:include, Hobo::EnumString::Helper)
|