auxiliary_addons 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/MIT-LICENSE +20 -20
  2. data/README +27 -27
  3. data/Rakefile +23 -23
  4. data/auxiliary_addons.gemspec +17 -17
  5. data/changelog +31 -28
  6. data/init.rb +2 -2
  7. data/install.rb +1 -1
  8. data/knownbugs +17 -17
  9. data/lib/auxiliary_addons.rb +45 -51
  10. data/lib/auxiliary_addons/html_helper.rb +47 -47
  11. data/lib/auxiliary_addons/jscript_helper.rb +25 -25
  12. data/lib/auxiliary_addons/list_helper.rb +56 -56
  13. data/lib/auxiliary_addons/ruby_addons.rb +41 -41
  14. data/lib/auxiliary_addons/tableless31_model.rb +36 -36
  15. data/lib/auxiliary_addons/tableless_model.rb +16 -16
  16. data/lib/auxiliary_addons/validateable_model.rb +37 -37
  17. data/roadmap +19 -19
  18. data/spec/lib/auxiliary_addons/error_helper_spec.rb +5 -5
  19. data/spec/lib/auxiliary_addons/filter_utils_spec.rb +5 -5
  20. data/spec/lib/auxiliary_addons/form_helper_spec.rb +5 -5
  21. data/spec/lib/auxiliary_addons/html_helper_spec.rb +6 -6
  22. data/spec/lib/auxiliary_addons/jscript_helper_spec.rb +5 -5
  23. data/spec/lib/auxiliary_addons/list_helper_spec.rb +5 -5
  24. data/spec/lib/auxiliary_addons/ruby_addons_spec.rb +6 -6
  25. data/spec/lib/auxiliary_addons/tableless_model_spec.rb +7 -7
  26. data/spec/lib/auxiliary_addons/validateable_model_spec.rb +7 -7
  27. data/spec/lib/auxiliary_addons_spec.rb +7 -7
  28. data/spec/spec.opts +2 -2
  29. data/spec/spec_helper.rb +23 -23
  30. data/tasks/auxiliary_addons_tasks.rake +4 -4
  31. data/uninstall.rb +1 -1
  32. metadata +22 -25
  33. data/lib/auxiliary_addons/error_helper.rb +0 -24
  34. data/lib/auxiliary_addons/filter_utils.rb +0 -43
  35. data/lib/auxiliary_addons/form_helper.rb +0 -139
@@ -1,5 +1,5 @@
1
- describe AuxiliaryAddons::ErrorHelper do
2
- it "should define error helper" do
3
- AuxiliaryAddons::ErrorHelper.should be
4
- end
5
- end
1
+ describe AuxiliaryAddons::ErrorHelper do
2
+ it "should define error helper" do
3
+ AuxiliaryAddons::ErrorHelper.should be
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
- describe AuxiliaryAddons::FilterUtils do
2
- it "should define filter utils" do
3
- AuxiliaryAddons::ErrorHelper.should be
4
- end
5
- end
1
+ describe AuxiliaryAddons::FilterUtils do
2
+ it "should define filter utils" do
3
+ AuxiliaryAddons::ErrorHelper.should be
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
- describe AuxiliaryAddons::FormHelper do
2
- it "should define form helper" do
3
- AuxiliaryAddons::ErrorHelper.should be
4
- end
5
- end
1
+ describe AuxiliaryAddons::FormHelper do
2
+ it "should define form helper" do
3
+ AuxiliaryAddons::ErrorHelper.should be
4
+ end
5
+ end
@@ -1,6 +1,6 @@
1
- describe AuxiliaryAddons::HtmlHelper do
2
- it "should define html helper" do
3
- AuxiliaryAddons::HtmlHelper.should be
4
- end
5
- end
6
-
1
+ describe AuxiliaryAddons::HtmlHelper do
2
+ it "should define html helper" do
3
+ AuxiliaryAddons::HtmlHelper.should be
4
+ end
5
+ end
6
+
@@ -1,5 +1,5 @@
1
- describe AuxiliaryAddons::JscriptHelper do
2
- it "should define jscript helper" do
3
- AuxiliaryAddons::JscriptHelper.should be
4
- end
5
- end
1
+ describe AuxiliaryAddons::JscriptHelper do
2
+ it "should define jscript helper" do
3
+ AuxiliaryAddons::JscriptHelper.should be
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
- describe AuxiliaryAddons::ListHelper do
2
- it "should define list helper" do
3
- AuxiliaryAddons::ListHelper.should be
4
- end
5
- end
1
+ describe AuxiliaryAddons::ListHelper do
2
+ it "should define list helper" do
3
+ AuxiliaryAddons::ListHelper.should be
4
+ end
5
+ end
@@ -1,6 +1,6 @@
1
- describe AuxiliaryAddons::RubyAddons do
2
- it "should define ruby addons" do
3
- AuxiliaryAddons::RubyAddons.should be
4
- end
5
- end
6
-
1
+ describe AuxiliaryAddons::RubyAddons do
2
+ it "should define ruby addons" do
3
+ AuxiliaryAddons::RubyAddons.should be
4
+ end
5
+ end
6
+
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe TablelessModel do
4
- it "should define tableless model" do
5
- TablelessModel.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe TablelessModel do
4
+ it "should define tableless model" do
5
+ TablelessModel.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe ValidateableModel do
4
- it "should define validateable model" do
5
- ValidateableModel.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe ValidateableModel do
4
+ it "should define validateable model" do
5
+ ValidateableModel.should be
6
+ end
7
+ end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
2
-
3
- describe AuxiliaryAddons do
4
- it "should define rails" do
5
- ::Rails::VERSION::MAJOR.should be
6
- end
7
- end
1
+ require 'spec_helper'
2
+
3
+ describe AuxiliaryAddons do
4
+ it "should define rails" do
5
+ ::Rails::VERSION::MAJOR.should be
6
+ end
7
+ end
@@ -1,2 +1,2 @@
1
- --color
2
- --backtrace
1
+ --color
2
+ --backtrace
@@ -1,23 +1,23 @@
1
- $:.unshift File.dirname(__FILE__)
2
- $:.unshift File.join(File.dirname(__FILE__), '../lib')
3
-
4
- ENV["RAILS_ENV"] = "test"
5
- require 'rubygems'
6
- require 'rspec'
7
- require 'action_controller'
8
- require 'auxiliary_addons'
9
-
10
- module Rails
11
- module VERSION
12
- MAJOR = 3
13
- end
14
- end unless defined? Rails
15
-
16
- # AuxiliaryAddons.root = './'
17
- RAILS_ROOT = './' unless defined?(RAILS_ROOT)
18
- RAILS_ENV = 'test' unless defined?(RAILS_ENV)
19
-
20
- RSpec.configure do |config|
21
- config.mock_with :rspec
22
- end
23
-
1
+ $:.unshift File.dirname(__FILE__)
2
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
3
+
4
+ ENV["RAILS_ENV"] = "test"
5
+ require 'rubygems'
6
+ require 'rspec'
7
+ require 'action_controller'
8
+ require 'auxiliary_addons'
9
+
10
+ module Rails
11
+ module VERSION
12
+ MAJOR = 3
13
+ end
14
+ end unless defined? Rails
15
+
16
+ # AuxiliaryAddons.root = './'
17
+ RAILS_ROOT = './' unless defined?(RAILS_ROOT)
18
+ RAILS_ENV = 'test' unless defined?(RAILS_ENV)
19
+
20
+ RSpec.configure do |config|
21
+ config.mock_with :rspec
22
+ end
23
+
@@ -1,4 +1,4 @@
1
- # desc "Explaining what the task does"
2
- # task :captcha_validateable do
3
- # # Task goes here
4
- # end
1
+ # desc "Explaining what the task does"
2
+ # task :captcha_validateable do
3
+ # # Task goes here
4
+ # end
@@ -1 +1 @@
1
- # Uninstall hook code here
1
+ # Uninstall hook code here
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auxiliary_addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-04 00:00:00.000000000 Z
12
+ date: 2013-04-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: AuxiliaryAddons is a gem that contains basic helpers.
15
15
  email: developers@majoron.com
@@ -17,40 +17,37 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - auxiliary_addons.gemspec
21
- - changelog
22
- - init.rb
23
- - install.rb
24
- - knownbugs
25
- - lib/auxiliary_addons/error_helper.rb
26
- - lib/auxiliary_addons/filter_utils.rb
27
- - lib/auxiliary_addons/form_helper.rb
28
- - lib/auxiliary_addons/html_helper.rb
29
- - lib/auxiliary_addons/jscript_helper.rb
30
20
  - lib/auxiliary_addons/list_helper.rb
31
- - lib/auxiliary_addons/ruby_addons.rb
32
21
  - lib/auxiliary_addons/tableless31_model.rb
33
- - lib/auxiliary_addons/tableless_model.rb
22
+ - lib/auxiliary_addons/jscript_helper.rb
34
23
  - lib/auxiliary_addons/validateable_model.rb
24
+ - lib/auxiliary_addons/ruby_addons.rb
25
+ - lib/auxiliary_addons/tableless_model.rb
26
+ - lib/auxiliary_addons/html_helper.rb
35
27
  - lib/auxiliary_addons.rb
36
- - MIT-LICENSE
37
- - Rakefile
38
28
  - README
29
+ - Rakefile
30
+ - init.rb
31
+ - install.rb
32
+ - uninstall.rb
39
33
  - roadmap
40
- - spec/lib/auxiliary_addons/error_helper_spec.rb
34
+ - knownbugs
35
+ - tasks/auxiliary_addons_tasks.rake
36
+ - auxiliary_addons.gemspec
37
+ - changelog
38
+ - MIT-LICENSE
39
+ - spec/lib/auxiliary_addons_spec.rb
40
+ - spec/lib/auxiliary_addons/ruby_addons_spec.rb
41
+ - spec/lib/auxiliary_addons/validateable_model_spec.rb
42
+ - spec/lib/auxiliary_addons/tableless_model_spec.rb
43
+ - spec/lib/auxiliary_addons/list_helper_spec.rb
44
+ - spec/lib/auxiliary_addons/html_helper_spec.rb
41
45
  - spec/lib/auxiliary_addons/filter_utils_spec.rb
46
+ - spec/lib/auxiliary_addons/error_helper_spec.rb
42
47
  - spec/lib/auxiliary_addons/form_helper_spec.rb
43
- - spec/lib/auxiliary_addons/html_helper_spec.rb
44
48
  - spec/lib/auxiliary_addons/jscript_helper_spec.rb
45
- - spec/lib/auxiliary_addons/list_helper_spec.rb
46
- - spec/lib/auxiliary_addons/ruby_addons_spec.rb
47
- - spec/lib/auxiliary_addons/tableless_model_spec.rb
48
- - spec/lib/auxiliary_addons/validateable_model_spec.rb
49
- - spec/lib/auxiliary_addons_spec.rb
50
49
  - spec/spec.opts
51
50
  - spec/spec_helper.rb
52
- - tasks/auxiliary_addons_tasks.rake
53
- - uninstall.rb
54
51
  homepage: http://www.majoron.com/project/rbundle/auxiliary_addons
55
52
  licenses: []
56
53
  post_install_message:
@@ -1,24 +0,0 @@
1
- module AuxiliaryAddons
2
- module ErrorHelper
3
- # ::Rails.logger.error("...")
4
-
5
- #
6
- # Common helpers to error processing
7
- #
8
- # Check is error or not for fields
9
- def is_error_message_on(object, method)
10
- object = instance_variable_get("@#{object}")
11
- if object.nil? || !object.errors.on(method)
12
- return true
13
- end
14
- return false
15
- end
16
-
17
- # Show hint on the fields if error not exists
18
- def hint_message_on(object, method, hint, css_class = "formHint")
19
- return if !is_error_message_on(object, method)
20
- content_tag("div", hint, :class => css_class)
21
- end
22
-
23
- end
24
- end
@@ -1,43 +0,0 @@
1
- module AuxiliaryAddons
2
- # contains auxiliary functions to build conditions
3
- module FilterUtils
4
- # ::Rails.logger.error("...")
5
-
6
- def self.like
7
- lambda do |col_name, field_name, field_value|
8
- field_value.size()==0 ? nil : "(#{col_name} like :#{field_name})"
9
- end
10
- end
11
-
12
- def self.less_than
13
- lambda do |col_name, field_name, field_value|
14
- field_value.size()==0 ? nil : "(#{col_name} < :#{field_name})"
15
- end
16
- end
17
-
18
- def self.more_than
19
- lambda do |col_name, field_name, field_value|
20
- field_value.size()==0 ? nil : "(#{col_name} > :#{field_name})"
21
- end
22
- end
23
-
24
- # the first parameter is a hash containing the values for each key
25
- # the second parameter is a hash containing filter specs for each key
26
- # the return value is the condition string to pass to the find method
27
- def self.get_conditions(filter,filter_spec)
28
- conditions = ""
29
- filter_spec.each do |k,spec|
30
- if spec.class == Array
31
- r = spec[1].call(spec[0].to_s,k.to_s,filter[k])
32
- else
33
- r = spec.call(k.to_s,k.to_s,filter[k])
34
- end
35
- if r
36
- conditions = conditions + (conditions.size()>0? " and "+r : r)
37
- end
38
- end
39
- return conditions
40
- end
41
-
42
- end
43
- end
@@ -1,139 +0,0 @@
1
- module AuxiliaryAddons
2
- module FormHelper
3
- # ::Rails.logger.error("...")
4
-
5
- include ActionView::Helpers::FormHelper
6
- #
7
- # Common helpers to customize form elements
8
- #
9
- # Checks if there is an error for a field of given object defined by given method
10
-
11
- def is_error_message_on(object, method)
12
- # DEPRECATION WARNING: Errors#on have been deprecated, use Errors#[] instead.
13
- # if object.nil? || !object.errors.on(method)
14
- if object.nil? || !object.errors[method] || (object.errors[method].size() == 0)
15
- return false
16
- end
17
- true
18
- end
19
-
20
- #
21
- # Outputs div block with a hint message related to the field of object defined by method
22
- # The hint message is printed if there's no error on the field. The message's text is either given
23
- # by the 'hint' parameter or defined by 'activerecord.hints.models.#{object_name}.attributes.#{method}'
24
- # key in localization files.
25
- #
26
- # Besides usuals options the following one is defined:
27
- # :hint_class - CSS class for the hint div
28
- #
29
- # Example:
30
- # ..
31
- # hint_message_on @user, :post, '(use only characters and digits)'
32
- # # If there's no error on :post will output: <div class="form-hint">(use only characters and digits)</div>
33
- #
34
- def hint_message_on(object, method, hint = '', options = {})
35
- return if is_error_message_on(object, method)
36
- if hint.nil? || hint.blank?
37
- # Here is patcha for rails 3.0.x
38
- # object_name = ActionController::RecordIdentifier.singular_class_name(object)
39
- object_name = ActiveModel::Naming.singular(object)
40
- hint = I18n.t("activerecord.hints.models.#{object_name}.attributes.#{method.to_s}")
41
- end
42
- hint_class = options.delete(:hint_class) || 'form-hint'
43
- content_tag("div", hint, :class => hint_class)
44
- end
45
-
46
- #
47
- # Outputs label that appends mandatory symbol (e.g. '*') to the label's text
48
- # Possible options are the same as for label method plus the following:
49
- # :mandatory_symbol - symbol to applend, default is '*'
50
- # :symbol_class = CSS class of the span element which surrounds this symbol, default is 'mandatory-field' class
51
- #
52
- # mandatory_label(@user, :post) # Outputs: <label for="user_post">Post<span class="mandatory-field">*</span></label>
53
- # ..
54
- # mandatory_label(@user, :name, 'User Name', {:mandatory_symbol => '^', :symbol_class => 'red'})
55
- # # Outputs: <label for="user_name">User Name<span class="red">^</span></label>
56
- #
57
- # TODO: patch
58
- # Instead of
59
- # def mandatory_label(object, method, text = nil, options = {})
60
- # text = (text.blank? ? nil : text.to_s) || object.class.human_attribute_name(method)
61
- # use
62
- # def mandatory_label(object_name, method, text = nil, options = {})
63
- # if text.nil? or text.blank?
64
- # text = Kernel::const_get(object_name.to_s.camelcase).human_attribute_name(method)
65
- # end
66
- def mandatory_label(object, method, text = nil, options = {})
67
- # Here is patcha for rails 3.0.x
68
- # object_name = ActionController::RecordIdentifier.singular_class_name(object)
69
- object_name = ActiveModel::Naming.singular(object)
70
- text = (text.blank? ? nil : text.to_s) || object.class.human_attribute_name(method)
71
- mandatory_symbol = options.delete(:mandatory_symbol) || '*'
72
- symbol_class = options.delete(:symbol_class) || 'mandatory-sign'
73
- label_name = raw( text + "<span class=#{symbol_class}>#{mandatory_symbol}</span>")
74
- label(object_name, method, label_name, options)
75
- end
76
-
77
- class CustomizedFormBuilder < ActionView::Helpers::FormBuilder
78
-
79
- # Checks if there is an error for a field defined by given method
80
- def is_error_message_on(method)
81
- # DEPRECATION WARNING: Errors#on have been deprecated, use Errors#[] instead.
82
- # if @object.nil? || !@object.errors.on(method)
83
- if @object.nil? || !@object.errors[method] || (@object.errors[method].size == 0)
84
- return false
85
- end
86
- true
87
- end
88
-
89
- #
90
- # Outputs div block with a hint message related to the field of object defined by method
91
- # The hint message is printed if there's no error on the field. The message's text is either given
92
- # by the 'hint' parameter or defined by 'activerecord.hints.models.#{object_name}.attributes.#{method}'
93
- # key in localization files.
94
- #
95
- # Besides usuals options the following one defined:
96
- # :hint_class - CSS class for the hint div
97
- #
98
- # Example:
99
- # form_for :user do |f|
100
- # ..
101
- # f.hint_message_on :post, '(use only characters and digits)'
102
- # # If there's no error on :post will output: <div class="form-hint">(use only characters and digits)</div>
103
- #
104
- def hint_message_on(method, hint = '', options = {})
105
- @template.hint_message_on(@object, method, hint, options)
106
- end
107
-
108
- #
109
- # Outputs label that appends mandatory symbol (e.g. '*') to the label's text
110
- # Possible options are the same as for label method plus the following:
111
- # :mandatory_symbol - symbol to applend, default is '*'
112
- # :symbol_class - CSS class of the span element which surrounds this symbol, default is 'mandatory-field' class
113
- #
114
- # Example:
115
- # form_for :user do |f|
116
- # ..
117
- # f.mandatory_label(:post) # Outputs: <label for="user_post">Post<span class="mandatory-field">*</span></label>
118
- # ..
119
- # f.mandatory_label(:name, 'User Name', {:mandatory_symbol => '^', :symbol_class => 'red'})
120
- # # Outputs: <label for="user_name">User Name<span class="red">^</span></label>
121
- #
122
- def mandatory_label(method, text = nil, options = {})
123
- @template.mandatory_label(@object, method, text, options)
124
- end
125
- end
126
-
127
- # Customized version of form_for for our application
128
- def form_for(record_or_name_or_array, *args, &proc)
129
- options = args.extract_options!
130
- super(record_or_name_or_array, *(args << options.merge(:builder => CustomizedFormBuilder)), &proc)
131
- end
132
-
133
- # Customized version of form_for for our application
134
- def fields_for(record_or_name_or_array, *args, &proc)
135
- options = args.extract_options!
136
- super(record_or_name_or_array, *(args << options.merge(:builder => CustomizedFormBuilder)), &proc)
137
- end
138
- end
139
- end