rad_core 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/Rakefile +2 -2
  2. data/bin/rad +20 -25
  3. data/lib/components/config.rb +1 -1
  4. data/lib/components/configurators.rb +2 -2
  5. data/lib/components/controller.rb +2 -2
  6. data/lib/components/conveyors.rb +2 -2
  7. data/lib/components/environment.rb +1 -1
  8. data/lib/components/environment.yml +28 -28
  9. data/lib/components/flash.rb +1 -1
  10. data/lib/components/html.rb +1 -1
  11. data/lib/components/http.rb +1 -1
  12. data/lib/components/http.yml +1 -1
  13. data/lib/components/logger.rb +2 -2
  14. data/lib/components/mailer.rb +2 -2
  15. data/lib/components/remote.rb +1 -1
  16. data/lib/components/router.rb +3 -3
  17. data/lib/components/template.rb +2 -2
  18. data/lib/components/web.rb +3 -3
  19. data/lib/rad.rb +1 -1
  20. data/lib/rad/_support/active_support.rb +7 -7
  21. data/lib/rad/_support/active_support/locales/ru/actionview.yml +8 -8
  22. data/lib/rad/_support/active_support/locales/ru/activesupport.yml +4 -4
  23. data/lib/rad/_support/active_support/locales/ru/datetime.yml +5 -5
  24. data/lib/rad/_support/active_support/time.rb +2 -2
  25. data/lib/rad/_support/addressable.rb +6 -6
  26. data/lib/rad/_support/class_loader.rb +1 -1
  27. data/lib/rad/_support/extensions.rb +5 -5
  28. data/lib/rad/_support/filters.rb +13 -13
  29. data/lib/rad/_support/hacks_and_fixes.rb +5 -5
  30. data/lib/rad/_support/mime.rb +4 -4
  31. data/lib/rad/_support/module.rb +11 -11
  32. data/lib/rad/_support/require.rb +5 -5
  33. data/lib/rad/_support/rson.rb +4 -4
  34. data/lib/rad/_support/string.rb +9 -9
  35. data/lib/rad/cli/helper.rb +5 -5
  36. data/lib/rad/configurators/_require.rb +2 -2
  37. data/lib/rad/configurators/abstract.rb +5 -5
  38. data/lib/rad/configurators/web.rb +8 -8
  39. data/lib/rad/controller/_abstract.rb +15 -14
  40. data/lib/rad/controller/_abstract/miscellaneous.rb +5 -5
  41. data/lib/rad/controller/_abstract/render.rb +40 -40
  42. data/lib/rad/controller/_abstract/responder.rb +1 -1
  43. data/lib/rad/controller/_context.rb +1 -1
  44. data/lib/rad/controller/_http.rb +11 -11
  45. data/lib/rad/controller/_require.rb +6 -6
  46. data/lib/rad/controller/processors/controller_caller.rb +3 -3
  47. data/lib/rad/controller/processors/controller_error_handling.rb +14 -14
  48. data/lib/rad/controller/processors/controller_logger.rb +1 -1
  49. data/lib/rad/conveyors/_conveyor.rb +9 -9
  50. data/lib/rad/conveyors/_conveyors.rb +4 -4
  51. data/lib/rad/conveyors/_params.rb +5 -5
  52. data/lib/rad/conveyors/_processor.rb +2 -2
  53. data/lib/rad/conveyors/_workspace.rb +5 -5
  54. data/lib/rad/conveyors/processors/conveyor_logger.rb +3 -3
  55. data/lib/rad/environment/_config.rb +4 -4
  56. data/lib/rad/environment/_environment.rb +10 -10
  57. data/lib/rad/environment/_files_helper.rb +5 -5
  58. data/lib/rad/environment/_logger.rb +9 -9
  59. data/lib/rad/environment/_require.rb +4 -4
  60. data/lib/rad/gems.rb +14 -14
  61. data/lib/rad/html/_flash.rb +5 -5
  62. data/lib/rad/html/_helpers/basic_html_helper.rb +12 -12
  63. data/lib/rad/html/_helpers/form_helper.rb +19 -19
  64. data/lib/rad/html/_helpers/javascript_helper.rb +6 -6
  65. data/lib/rad/html/_helpers/model_helper.rb +17 -17
  66. data/lib/rad/html/_require.rb +1 -1
  67. data/lib/rad/html/processors/prepare_flash.rb +3 -3
  68. data/lib/rad/html/processors/scoped_params.rb +4 -4
  69. data/lib/rad/http/_http.rb +4 -4
  70. data/lib/rad/http/_http_adapter.rb +5 -5
  71. data/lib/rad/http/_request.rb +11 -11
  72. data/lib/rad/http/_require.rb +8 -8
  73. data/lib/rad/http/_response.rb +5 -5
  74. data/lib/rad/http/_support/rack/fixes.rb +3 -3
  75. data/lib/rad/http/_support/rack/rack_adapter.rb +5 -5
  76. data/lib/rad/http/processors/evaluate_format.rb +4 -4
  77. data/lib/rad/http/processors/http_logger.rb +3 -3
  78. data/lib/rad/http/processors/http_writer.rb +7 -7
  79. data/lib/rad/http/processors/prepare_params.rb +5 -5
  80. data/lib/rad/mailer/_letter.rb +1 -1
  81. data/lib/rad/mailer/_mailer.rb +1 -1
  82. data/lib/rad/mailer/_mailer_controller.rb +6 -6
  83. data/lib/rad/mailer/_require.rb +1 -1
  84. data/lib/rad/mailer/processors/letter_builder.rb +6 -6
  85. data/lib/rad/profiles/mailer.rb +2 -2
  86. data/lib/rad/profiles/web.rb +13 -13
  87. data/lib/rad/remote/processors/remote_caller.rb +10 -10
  88. data/lib/rad/remote/processors/remote_logger.rb +1 -1
  89. data/lib/rad/router/_abstract_router.rb +9 -9
  90. data/lib/rad/router/_alias_router.rb +34 -34
  91. data/lib/rad/router/_basic_router.rb +12 -12
  92. data/lib/rad/router/_configurator.rb +6 -6
  93. data/lib/rad/router/_core_routing_helper.rb +4 -4
  94. data/lib/rad/router/_object_router.rb +45 -45
  95. data/lib/rad/router/_require.rb +8 -8
  96. data/lib/rad/router/_restful_router.rb +25 -25
  97. data/lib/rad/router/_router.rb +78 -78
  98. data/lib/rad/router/_simple_router.rb +5 -5
  99. data/lib/rad/router/processors/router.rb +6 -6
  100. data/lib/rad/spec/controller.rb +9 -9
  101. data/lib/rad/spec/environment.rb +7 -7
  102. data/lib/rad/spec/http.rb +2 -2
  103. data/lib/rad/spec/http_controller.rb +22 -22
  104. data/lib/rad/spec/mailer.rb +4 -4
  105. data/lib/rad/spec/remote.rb +1 -1
  106. data/lib/rad/spec/router.rb +4 -4
  107. data/lib/rad/spec/template.rb +2 -2
  108. data/lib/rad/tasks.rb +2 -2
  109. data/lib/rad/template/_context.rb +15 -15
  110. data/lib/rad/template/_relative_path_resolver.rb +1 -1
  111. data/lib/rad/template/_support/tilt.rb +17 -17
  112. data/lib/rad/template/_support/tilt_fixes.rb +3 -3
  113. data/lib/rad/template/_template.rb +47 -47
  114. data/lib/rad/web/_ajax_helper.rb +4 -4
  115. data/lib/rad/web/_controller_miscellaneous_helper.rb +5 -5
  116. data/lib/rad/web/_ensure_no_www.rb +5 -5
  117. data/lib/rad/web/_protect_from_forgery.rb +18 -18
  118. data/lib/rad/web/_require.rb +7 -7
  119. data/lib/rad/web/_router/abstract_routing_helper.rb +4 -4
  120. data/lib/rad/web/_router/controller_routing_helper.rb +15 -15
  121. data/lib/rad/web/_router/view_routing_helper.rb +12 -12
  122. data/readme.md +5 -5
  123. data/spec/controller/abstract_spec.rb +29 -29
  124. data/spec/controller/context_spec.rb +32 -32
  125. data/spec/controller/error_handling_spec.rb +31 -31
  126. data/spec/controller/helper_spec.rb +13 -13
  127. data/spec/controller/http_spec.rb +32 -32
  128. data/spec/controller/render_spec.rb +59 -59
  129. data/spec/conveyors/conveyors_spec.rb +32 -32
  130. data/spec/environment/config_spec.rb +6 -6
  131. data/spec/environment/environment_spec.rb +7 -7
  132. data/spec/environment/minimal_app_spec.rb +4 -4
  133. data/spec/environment/standard_app_spec.rb +10 -10
  134. data/spec/html/basic_html_helper_spec.rb +6 -6
  135. data/spec/html/form_helper_spec.rb +5 -5
  136. data/spec/html/javascript_helper_spec.rb +4 -4
  137. data/spec/html/model_helper_spec.rb +12 -12
  138. data/spec/html/scoped_params_spec.rb +2 -2
  139. data/spec/html/spec_helper.rb +3 -3
  140. data/spec/http/http_spec.rb +9 -9
  141. data/spec/http/miscellaneous_spec.rb +2 -2
  142. data/spec/mailer/mail_controller_spec.rb +23 -23
  143. data/spec/remote/remote_spec.rb +26 -26
  144. data/spec/router/alias_router_spec.rb +22 -22
  145. data/spec/router/basic_router_spec.rb +8 -8
  146. data/spec/router/configurator_spec.rb +4 -4
  147. data/spec/router/integration_spec.rb +17 -17
  148. data/spec/router/object_router_spec.rb +47 -47
  149. data/spec/router/persistent_params_spec.rb +18 -18
  150. data/spec/router/restful_router_spec.rb +39 -39
  151. data/spec/router/router_spec.rb +37 -37
  152. data/spec/router/routing_helper_spec.rb +18 -18
  153. data/spec/support/filters_spec.rb +11 -13
  154. data/spec/template/template_spec.rb +43 -45
  155. data/spec/template/template_spec/views/layout/content_for/content.erb +3 -1
  156. data/spec/template/template_spec/views/layout/content_for/layout.erb +1 -1
  157. data/spec/template/tilt_spec.rb +24 -24
  158. data/spec/web/basic_spec.rb +25 -25
  159. data/spec/web/controller_routing_helper_spec.rb +26 -26
  160. data/spec/web/flash_spec.rb +31 -31
  161. data/spec/web/protect_from_forgery_spec.rb +44 -44
  162. data/spec/web/spec_helper_spec.rb +16 -16
  163. data/spec/web/view_routing_helper_spec.rb +31 -31
  164. metadata +46 -49
  165. data/lib/rad/_support/callbacks.rb +0 -166
  166. data/lib/rad/_support/ruby_ext_with_active_support.rb +0 -4
  167. data/spec/support/callbacks_spec.rb +0 -157
@@ -1,14 +1,14 @@
1
- class Rad::Conveyors
1
+ class Rad::Conveyors
2
2
  def initialize
3
3
  @hash = {}
4
4
  end
5
-
5
+
6
6
  def [] conveyor_name
7
7
  @hash[conveyor_name.to_s] ||= Conveyor.new
8
8
  end
9
-
9
+
10
10
  def size; @hash.size end
11
-
11
+
12
12
  def method_missing m, &block
13
13
  if block
14
14
  block.call self[m]
@@ -1,10 +1,10 @@
1
- class Rad::Conveyors::Params < OpenObject
2
- def initialize h = nil
1
+ class Rad::Conveyors::Params < OpenObject
2
+ def initialize h = nil
3
3
  update h if h
4
4
  end
5
-
6
- def inspect
5
+
6
+ def inspect
7
7
  h = to_h
8
8
  h.inspect
9
- end
9
+ end
10
10
  end
@@ -5,9 +5,9 @@ class Rad::Conveyors::Processor
5
5
 
6
6
  def initialize next_processor
7
7
  @next_processor = next_processor
8
- end
8
+ end
9
9
 
10
10
  def self.inspect
11
11
  self.name.split('::').last
12
- end
12
+ end
13
13
  end
@@ -6,15 +6,15 @@ class Rad::Conveyors::Workspace < OpenObject
6
6
  def params?
7
7
  !!params
8
8
  end
9
-
9
+
10
10
  alias_method :set_without_params, :[]=
11
- def []= k, v
11
+ def []= k, v
12
12
  if k.to_s == 'params'
13
13
  self.params = v
14
14
  else
15
15
  set_without_params k, v
16
16
  end
17
- end
17
+ end
18
18
 
19
19
  def params= v
20
20
  if v.is_a? ::Rad::Conveyors::Params
@@ -23,11 +23,11 @@ class Rad::Conveyors::Workspace < OpenObject
23
23
  set_without_params :params, ::Rad::Conveyors::Params.new(v)
24
24
  end
25
25
  end
26
-
26
+
27
27
  def inspect
28
28
  h = {}
29
29
  each{|k, v| h[k] = v}
30
- h['env'] = "..." if h.include? 'env'
30
+ h['env'] = "..." if h.include? 'env'
31
31
  h['request'] = "..." if h.include? 'request'
32
32
  h.inspect
33
33
  end
@@ -1,11 +1,11 @@
1
1
  rad.conveyors
2
2
 
3
- class ConveyorLogger < Rad::Conveyors::Processor
3
+ class ConveyorLogger < Rad::Conveyors::Processor
4
4
  def call
5
5
  begin
6
6
  start_time = Time.now
7
7
  next_processor.call
8
-
8
+
9
9
  # if workspace.trace?
10
10
  # total_time = workspace.trace.inject(0){|memo, pair| memo += pair.last}
11
11
  # max_pair = workspace.trace.max_by{|pair| pair.last}
@@ -15,7 +15,7 @@ class ConveyorLogger < Rad::Conveyors::Processor
15
15
  # end
16
16
  rescue StandardError => e
17
17
  raise e if rad.test?
18
-
18
+
19
19
  logger.error e
20
20
  logger.info "\n"
21
21
  end
@@ -1,12 +1,12 @@
1
- class Rad::Config
1
+ class Rad::Config
2
2
  def subset; raise "you probably mistuped, it's config, not hash" end
3
-
3
+
4
4
  def initialize hash = {}
5
5
  hash.each do |k, v|
6
6
  instance_variable_set :"@#{k}", v
7
7
  end
8
8
  end
9
-
9
+
10
10
  def deep_clone
11
11
  clone = Rad::Config.new
12
12
  instance_variable_names.each do |k|
@@ -15,7 +15,7 @@ class Rad::Config
15
15
  clone
16
16
  end
17
17
  alias_method :clone, :deep_clone
18
-
18
+
19
19
  protected
20
20
  def method_missing m, *args
21
21
  if m =~ /=$/
@@ -1,21 +1,21 @@
1
- #
1
+ #
2
2
  # Environment
3
- #
3
+ #
4
4
  class Rad::Environment
5
5
  inherit Rad::Environment::FilesHelper
6
-
6
+
7
7
  inject logger: :logger
8
-
8
+
9
9
  attr_writer :available_languages
10
10
  def available_languages; @available_languages ||= [] end
11
-
11
+
12
12
  attr_accessor :language
13
-
13
+
14
14
  attr_writer :backtrace_filters
15
15
  def backtrace_filters; @backtrace_filters ||= [] end
16
-
17
-
18
- class << self
16
+
17
+
18
+ class << self
19
19
  inject logger: :logger
20
- end
20
+ end
21
21
  end
@@ -1,4 +1,4 @@
1
- module Rad::Environment::FilesHelper
1
+ module Rad::Environment::FilesHelper
2
2
  def directories
3
3
  $LOAD_PATH
4
4
  end
@@ -22,14 +22,14 @@ module Rad::Environment::FilesHelper
22
22
  raise "Found multiple files for '#{fname}'" if files.size > 1
23
23
  files.first
24
24
  end
25
-
25
+
26
26
  def find_file! fname, directories = nil
27
27
  find_file(fname, directories) || raise("File '#{fname}' not found!")
28
28
  end
29
29
 
30
30
  def find_files_by_pattern_without_cache pattern, directories = nil
31
31
  directories ||= self.directories
32
- patterns = directories.to_a.collect{|d| "#{d}#{pattern}"}
32
+ patterns = directories.to_a.collect{|d| "#{d}#{pattern}"}
33
33
  Dir.glob patterns
34
34
  end
35
35
  alias_method :find_files_by_pattern, :find_files_by_pattern_without_cache
@@ -42,8 +42,8 @@ module Rad::Environment::FilesHelper
42
42
  end
43
43
 
44
44
  class << self
45
- # don't move this class method to module, because there will be then
46
- # multiple cache for every object that includes it.
45
+ # don't move this class method to module, because there will be then
46
+ # multiple cache for every object that includes it.
47
47
  def find_files fname, directories
48
48
  fname.must =~ /\//
49
49
  directories.must_be.present # || raise('directories ')= self.directories
@@ -1,17 +1,17 @@
1
- class Rad::Logger
1
+ class Rad::Logger
2
2
  def initialize stream = nil
3
3
  @stream = stream
4
4
  end
5
-
5
+
6
6
  def silence &b
7
7
  begin
8
8
  @silence = true
9
9
  b.call
10
10
  ensure
11
11
  @silence = false
12
- end
12
+ end
13
13
  end
14
-
14
+
15
15
  def info obj
16
16
  write obj_to_string(obj)
17
17
  end
@@ -23,7 +23,7 @@ class Rad::Logger
23
23
  def error obj
24
24
  write "ERROR: " + obj_to_string(obj)
25
25
  end
26
-
26
+
27
27
  def debug obj
28
28
  write obj_to_string(obj).gsub(/BSON::ObjectId\(([a-z0-9'"]+)\)/, "\\1")
29
29
  end
@@ -35,21 +35,21 @@ class Rad::Logger
35
35
  stream ? stream.write(str) : puts(str)
36
36
  end
37
37
  end
38
-
38
+
39
39
  IDENTATION = " "
40
40
  attr_reader :stream
41
-
41
+
42
42
  def indent string
43
43
  IDENTATION + string.gsub("\n", "\n" + IDENTATION)
44
44
  end
45
-
45
+
46
46
  def obj_to_string obj
47
47
  if obj.is_a? Exception
48
48
  backtrace = obj.backtrace || []
49
49
  %{\
50
50
  #{obj.message}
51
51
  #{backtrace.join("\n ")}
52
- }
52
+ }
53
53
  else
54
54
  obj.to_s
55
55
  end
@@ -9,14 +9,14 @@ end
9
9
  ).each{|f| require "rad/environment/#{f}"}
10
10
 
11
11
 
12
- #
13
- # Handy mehtods
14
- #
12
+ #
13
+ # Handy mehtods
14
+ #
15
15
  class Micon::Core
16
16
 
17
17
  def development?; mode == :development end
18
18
  def production?; mode == :production end
19
- def test?; mode == :test end
19
+ def test?; mode == :test end
20
20
 
21
21
  def development &block; block.call if development? end
22
22
  def production &block; block.call if production? end
@@ -1,12 +1,12 @@
1
- gem 'activesupport', '3.0.7'
2
- gem 'haml', '3.0.25'
3
- gem 'tilt', '1.2.1'
4
- gem 'json', '1.4.6'
5
- gem 'addressable', '2.2.2'
6
- gem 'rack', '1.3.2'
7
- gem 'thin', '1.2.7'
8
- gem 'mail', '2.2.14'
9
- gem 'builder', '2.1.2' # need for :xml response
1
+ gem 'activesupport', '~> 3.0'
2
+ gem 'haml', '~> 3.1'
3
+ gem 'tilt', '~> 1.2'
4
+ gem 'json', '~> 1.4'
5
+ gem 'addressable', '~> 2.2'
6
+ gem 'rack', '~> 1.3'
7
+ gem 'thin', '~> 1.2'
8
+ gem 'mail', '~> 2.2'
9
+ gem 'builder', '~> 3.0' # need for :xml response
10
10
 
11
11
  # TODO2 remove this dependencies
12
12
  # gem 'mime-types', '1.16'
@@ -19,18 +19,18 @@ if respond_to? :fake_gem
19
19
  fake_gem 'class_loader'
20
20
  end
21
21
 
22
- #
22
+ #
23
23
  # Gems for specs
24
- #
24
+ #
25
25
  # gem 'nokogiri', '1.4.4'
26
26
 
27
27
 
28
- #
28
+ #
29
29
  # Old stuff
30
- #
30
+ #
31
31
  # core gems dependencies
32
32
  # gem 'i18n', '0.5.0'
33
33
  # gem 'polyglot', '0.3.1'
34
34
  # gem 'treetop', '1.4.9'
35
35
  # gem 'mime-types', '1.16'
36
- #
36
+ #
@@ -1,6 +1,6 @@
1
1
  class Rad::Html::Flash < OpenObject
2
2
  attr_accessor :previous_messages, :current_messages
3
-
3
+
4
4
  def initialize format, previous_messages = {}
5
5
  self.current_messages, self.previous_messages = {}, previous_messages
6
6
  @keep = false
@@ -8,9 +8,9 @@ class Rad::Html::Flash < OpenObject
8
8
 
9
9
  def [] key
10
10
  key = key.to_s
11
-
11
+
12
12
  if keep?
13
- previous_messages[key]
13
+ previous_messages[key]
14
14
  else
15
15
  current_messages[key] || previous_messages[key]
16
16
  end
@@ -32,9 +32,9 @@ class Rad::Html::Flash < OpenObject
32
32
  def messages_for_next_request
33
33
  if keep?
34
34
  current_messages
35
- else
35
+ else
36
36
  {}
37
37
  end
38
38
  end
39
-
39
+
40
40
  end
@@ -6,9 +6,9 @@ module Rad::Html::BasicHtmlHelper
6
6
  BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attr| attr.to_sym })
7
7
 
8
8
 
9
- #
9
+ #
10
10
  # JavaScript & StyleSheets
11
- #
11
+ #
12
12
  def stylesheet_link_tag *stylesheets
13
13
  stylesheets.collect{|ssheet|
14
14
  tag :link, '', href: "#{ssheet}", media: "screen", rel: "stylesheet", type: "text/css"
@@ -16,27 +16,27 @@ module Rad::Html::BasicHtmlHelper
16
16
  end
17
17
 
18
18
 
19
- #
19
+ #
20
20
  # Assets
21
- #
21
+ #
22
22
  def image_tag src, opt = {}
23
23
  opt[:src] = src
24
24
  tag :img, '', opt
25
25
  end
26
-
27
26
 
28
- #
27
+
28
+ #
29
29
  # Common HTML tags
30
- #
30
+ #
31
31
  def label_tag name, text, options = {}
32
32
  tag :label, text, options.merge(for: name)
33
33
  end
34
34
 
35
35
 
36
- #
36
+ #
37
37
  # Special
38
- #
39
- def tag name, content_or_options_with_block = nil, options = nil, escape = true, &block
38
+ #
39
+ def tag name, content_or_options_with_block = nil, options = nil, escape = true, &block
40
40
  if block_given?
41
41
  options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
42
42
  content = capture(&block)
@@ -44,11 +44,11 @@ module Rad::Html::BasicHtmlHelper
44
44
  else
45
45
  content = content_or_options_with_block
46
46
  "<#{name}#{tag_options(options)}>#{content}</#{name}>"
47
- end
47
+ end
48
48
  end
49
49
 
50
50
  # Escape
51
- def h obj; obj.to_s.html_escape end
51
+ def h obj; obj.to_s.html_escape end
52
52
 
53
53
  protected
54
54
 
@@ -1,31 +1,31 @@
1
1
  module Rad::Html::FormHelper
2
- #
2
+ #
3
3
  # Form
4
- #
4
+ #
5
5
  def form_for *args, &block
6
6
  model_helper, options = build_form_model_helper_and_form_options *args
7
-
7
+
8
8
  form_tag options do
9
9
  block.call model_helper if block
10
10
  end
11
11
  end
12
12
 
13
- def build_form_model_helper_and_form_options model_name, model, options = {}
13
+ def build_form_model_helper_and_form_options model_name, model, options = {}
14
14
  model_name.must_be.a String, Symbol
15
15
  return Rad::Html::ModelHelper.new(self, self, model_name, model, options), options
16
16
  end
17
17
 
18
- def form_tag options = {}, &block
18
+ def form_tag options = {}, &block
19
19
  options['method'] ||= options[:method] || 'post'
20
20
  tag :form, options, &block
21
21
  end
22
22
 
23
23
 
24
- #
24
+ #
25
25
  # Errors
26
- #
26
+ #
27
27
  # delegate :error_messages, :field_with_errors, to: :form_builder
28
- def error_messages *errors
28
+ def error_messages *errors
29
29
  errors = errors.first if errors.size == 1 and errors.first.is_a? Array
30
30
  html = errors.join("<br/>")
31
31
  tag :div, html, class: :error_messages
@@ -38,15 +38,15 @@ module Rad::Html::FormHelper
38
38
  end
39
39
 
40
40
 
41
- #
41
+ #
42
42
  # Form fields
43
- #
44
- def check_box_tag name, checked = false, options = {}
43
+ #
44
+ def check_box_tag name, checked = false, options = {}
45
45
  options = {type: "checkbox", name: name, value: '1'}.update(options)
46
46
  options[:checked] = "checked" if checked
47
47
  tag_with_style :input, '', options
48
48
  end
49
-
49
+
50
50
  def field_set_tag legend = nil, options = {}, &block
51
51
  content = ""
52
52
  content << tag(:legend, legend) unless legend.blank?
@@ -73,16 +73,16 @@ module Rad::Html::FormHelper
73
73
  tag_with_style :input, '', options
74
74
  end
75
75
 
76
- def select_tag name, selected, values, options = {}
76
+ def select_tag name, selected, values, options = {}
77
77
  buff = "\n"
78
- values.each do |n, v|
78
+ values.each do |n, v|
79
79
  o = {}
80
80
  o[:value] = v if v
81
- o[:selected] = 'selected' if (v || n) == selected
81
+ o[:selected] = 'selected' if (v || n) == selected
82
82
  buff << tag(:option, n, o)
83
83
  buff << "\n"
84
84
  end
85
-
85
+
86
86
  tag_with_style :select, buff, {name: name}.update(options)
87
87
  end
88
88
 
@@ -95,9 +95,9 @@ module Rad::Html::FormHelper
95
95
  end
96
96
 
97
97
 
98
- #
98
+ #
99
99
  # Other
100
- #
100
+ #
101
101
  def submit_tag value, options = {}
102
102
  tag_with_style :input, '', {type: "submit", value: value}.update(options)
103
103
  end
@@ -108,7 +108,7 @@ module Rad::Html::FormHelper
108
108
  klass = options.delete(:class) || options.delete('class') || ""
109
109
  klass << " #{options[:type] || options['type'] || name}_input"
110
110
  options['class'] = klass
111
-
111
+
112
112
  tag name, value, options, &block
113
113
  end
114
114
  end