actionpack 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +66 -0
- data/README +94 -64
- data/install.rb +1 -20
- data/lib/action_controller.rb +15 -7
- data/lib/action_controller/assertions/action_pack_assertions.rb +56 -3
- data/lib/action_controller/base.rb +137 -64
- data/lib/action_controller/caching.rb +11 -11
- data/lib/action_controller/cgi_ext/cgi_ext.rb +2 -2
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +4 -4
- data/lib/action_controller/cgi_process.rb +9 -1
- data/lib/action_controller/components.rb +73 -0
- data/lib/action_controller/cookies.rb +1 -1
- data/lib/action_controller/dependencies.rb +6 -1
- data/lib/action_controller/filters.rb +1 -1
- data/lib/action_controller/flash.rb +3 -3
- data/lib/action_controller/helpers.rb +17 -21
- data/lib/action_controller/layout.rb +2 -2
- data/lib/action_controller/request.rb +16 -6
- data/lib/action_controller/rescue.rb +15 -3
- data/lib/action_controller/routing.rb +304 -0
- data/lib/action_controller/scaffolding.rb +10 -12
- data/lib/action_controller/session/active_record_store.rb +4 -7
- data/lib/action_controller/session/mem_cache_store.rb +2 -2
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +9 -1
- data/lib/action_controller/templates/rescues/diagnostics.rhtml +1 -1
- data/lib/action_controller/templates/rescues/routing_error.rhtml +8 -0
- data/lib/action_controller/test_process.rb +29 -7
- data/lib/action_controller/url_rewriter.rb +28 -112
- data/lib/action_view.rb +1 -1
- data/lib/action_view/base.rb +44 -17
- data/lib/action_view/helpers/active_record_helper.rb +1 -1
- data/lib/action_view/helpers/asset_tag_helper.rb +59 -0
- data/lib/action_view/helpers/date_helper.rb +24 -13
- data/lib/action_view/helpers/form_helper.rb +6 -1
- data/lib/action_view/helpers/form_options_helper.rb +87 -9
- data/lib/action_view/helpers/form_tag_helper.rb +80 -0
- data/lib/action_view/helpers/tag_helper.rb +0 -23
- data/lib/action_view/helpers/text_helper.rb +26 -1
- data/lib/action_view/helpers/url_helper.rb +29 -35
- data/lib/action_view/partials.rb +2 -2
- data/lib/action_view/vendor/builder/xmlbase.rb +3 -3
- data/rakefile +5 -2
- data/test/abstract_unit.rb +3 -1
- data/test/controller/action_pack_assertions_test.rb +29 -1
- data/test/controller/active_record_assertions_test.rb +109 -101
- data/test/controller/base_tests.rb +72 -0
- data/test/controller/components_test.rb +74 -0
- data/test/controller/cookie_test.rb +0 -9
- data/test/controller/custom_handler_test.rb +33 -0
- data/test/controller/filters_test.rb +36 -0
- data/test/controller/helper_test.rb +27 -10
- data/test/controller/redirect_test.rb +23 -31
- data/test/controller/render_test.rb +81 -66
- data/test/controller/request_test.rb +22 -0
- data/test/controller/routing_tests.rb +490 -0
- data/test/controller/{url_test.rb → url_obsolete.rb} +24 -14
- data/test/controller/url_obsolete.rb.rej +747 -0
- data/test/fixtures/fun/games/hello_world.rhtml +1 -0
- data/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/test/template/asset_tag_helper_test.rb +45 -0
- data/test/template/form_options_helper_test.rb +161 -1
- data/test/template/form_tag_helper_test.rb +22 -0
- data/test/template/text_helper_test.rb +7 -0
- data/test/template/url_helper_test.rb +5 -2
- data/test/template/url_helper_test.rb.rej +105 -0
- metadata +32 -27
- data/lib/action_controller/support/binding_of_caller.rb +0 -83
- data/lib/action_controller/support/breakpoint.rb +0 -518
- data/lib/action_controller/support/class_attribute_accessors.rb +0 -57
- data/lib/action_controller/support/class_inheritable_attributes.rb +0 -117
- data/lib/action_controller/support/clean_logger.rb +0 -10
- data/lib/action_controller/support/core_ext.rb +0 -1
- data/lib/action_controller/support/core_ext/hash.rb +0 -5
- data/lib/action_controller/support/core_ext/hash/keys.rb +0 -35
- data/lib/action_controller/support/core_ext/numeric.rb +0 -7
- data/lib/action_controller/support/core_ext/numeric/bytes.rb +0 -33
- data/lib/action_controller/support/core_ext/numeric/time.rb +0 -59
- data/lib/action_controller/support/core_ext/object_and_class.rb +0 -24
- data/lib/action_controller/support/core_ext/string.rb +0 -5
- data/lib/action_controller/support/core_ext/string/inflections.rb +0 -45
- data/lib/action_controller/support/dependencies.rb +0 -63
- data/lib/action_controller/support/inflector.rb +0 -84
- data/lib/action_controller/support/misc.rb +0 -8
- data/lib/action_controller/support/module_attribute_accessors.rb +0 -57
@@ -1,84 +0,0 @@
|
|
1
|
-
# The Inflector transforms words from singular to plural, class names to table names, modulized class names to ones without,
|
2
|
-
# and class names to foreign keys.
|
3
|
-
module Inflector
|
4
|
-
extend self
|
5
|
-
|
6
|
-
def pluralize(word)
|
7
|
-
result = word.to_s.dup
|
8
|
-
plural_rules.each do |(rule, replacement)|
|
9
|
-
break if result.gsub!(rule, replacement)
|
10
|
-
end
|
11
|
-
return result
|
12
|
-
end
|
13
|
-
|
14
|
-
def singularize(word)
|
15
|
-
result = word.to_s.dup
|
16
|
-
singular_rules.each do |(rule, replacement)|
|
17
|
-
break if result.gsub!(rule, replacement)
|
18
|
-
end
|
19
|
-
return result
|
20
|
-
end
|
21
|
-
|
22
|
-
def camelize(lower_case_and_underscored_word)
|
23
|
-
lower_case_and_underscored_word.to_s.gsub(/(^|_)(.)/){$2.upcase}
|
24
|
-
end
|
25
|
-
|
26
|
-
def underscore(camel_cased_word)
|
27
|
-
camel_cased_word.to_s.gsub(/([A-Z]+)([A-Z])/,'\1_\2').gsub(/([a-z])([A-Z])/,'\1_\2').downcase
|
28
|
-
end
|
29
|
-
|
30
|
-
def humanize(lower_case_and_underscored_word)
|
31
|
-
lower_case_and_underscored_word.to_s.gsub(/_/, " ").capitalize
|
32
|
-
end
|
33
|
-
|
34
|
-
def demodulize(class_name_in_module)
|
35
|
-
class_name_in_module.to_s.gsub(/^.*::/, '')
|
36
|
-
end
|
37
|
-
|
38
|
-
def tableize(class_name)
|
39
|
-
pluralize(underscore(class_name))
|
40
|
-
end
|
41
|
-
|
42
|
-
def classify(table_name)
|
43
|
-
camelize(singularize(table_name))
|
44
|
-
end
|
45
|
-
|
46
|
-
def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)
|
47
|
-
Inflector.underscore(Inflector.demodulize(class_name)) +
|
48
|
-
(separate_class_name_and_id_with_underscore ? "_id" : "id")
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
def plural_rules #:doc:
|
53
|
-
[
|
54
|
-
[/(x|ch|ss|sh)$/, '\1es'], # search, switch, fix, box, process, address
|
55
|
-
[/([^aeiouy]|qu)ies$/, '\1y'],
|
56
|
-
[/([^aeiouy]|qu)y$/, '\1ies'], # query, ability, agency
|
57
|
-
[/(?:([^f])fe|([lr])f)$/, '\1\2ves'], # half, safe, wife
|
58
|
-
[/sis$/, 'ses'], # basis, diagnosis
|
59
|
-
[/([ti])um$/, '\1a'], # datum, medium
|
60
|
-
[/person$/, 'people'], # person, salesperson
|
61
|
-
[/man$/, 'men'], # man, woman, spokesman
|
62
|
-
[/child$/, 'children'], # child
|
63
|
-
[/s$/, 's'], # no change (compatibility)
|
64
|
-
[/$/, 's']
|
65
|
-
]
|
66
|
-
end
|
67
|
-
|
68
|
-
def singular_rules #:doc:
|
69
|
-
[
|
70
|
-
[/(x|ch|ss)es$/, '\1'],
|
71
|
-
[/movies$/, 'movie'],
|
72
|
-
[/([^aeiouy]|qu)ies$/, '\1y'],
|
73
|
-
[/([lr])ves$/, '\1f'],
|
74
|
-
[/([^f])ves$/, '\1fe'],
|
75
|
-
[/(analy|ba|diagno|parenthe|progno|synop|the)ses$/, '\1sis'],
|
76
|
-
[/([ti])a$/, '\1um'],
|
77
|
-
[/people$/, 'person'],
|
78
|
-
[/men$/, 'man'],
|
79
|
-
[/status$/, 'status'],
|
80
|
-
[/children$/, 'child'],
|
81
|
-
[/s$/, '']
|
82
|
-
]
|
83
|
-
end
|
84
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Extends the module object with module and instance accessors for class attributes,
|
2
|
-
# just like the native attr* accessors for instance attributes.
|
3
|
-
class Module # :nodoc:
|
4
|
-
def mattr_reader(*syms)
|
5
|
-
syms.each do |sym|
|
6
|
-
class_eval <<-EOS
|
7
|
-
if ! defined? @@#{sym.id2name}
|
8
|
-
@@#{sym.id2name} = nil
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.#{sym.id2name}
|
12
|
-
@@#{sym}
|
13
|
-
end
|
14
|
-
|
15
|
-
def #{sym.id2name}
|
16
|
-
@@#{sym}
|
17
|
-
end
|
18
|
-
|
19
|
-
def call_#{sym.id2name}
|
20
|
-
case @@#{sym.id2name}
|
21
|
-
when Symbol then send(@@#{sym})
|
22
|
-
when Proc then @@#{sym}.call(self)
|
23
|
-
when String then @@#{sym}
|
24
|
-
else nil
|
25
|
-
end
|
26
|
-
end
|
27
|
-
EOS
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def mattr_writer(*syms)
|
32
|
-
syms.each do |sym|
|
33
|
-
class_eval <<-EOS
|
34
|
-
if ! defined? @@#{sym.id2name}
|
35
|
-
@@#{sym.id2name} = nil
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.#{sym.id2name}=(obj)
|
39
|
-
@@#{sym.id2name} = obj
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.set_#{sym.id2name}(obj)
|
43
|
-
@@#{sym.id2name} = obj
|
44
|
-
end
|
45
|
-
|
46
|
-
def #{sym.id2name}=(obj)
|
47
|
-
@@#{sym} = obj
|
48
|
-
end
|
49
|
-
EOS
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def mattr_accessor(*syms)
|
54
|
-
mattr_reader(*syms)
|
55
|
-
mattr_writer(*syms)
|
56
|
-
end
|
57
|
-
end
|