noodall-form-builder 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -16,10 +16,10 @@ gem 'faker', '~> 0.3.1'
16
16
  gem 'defensio'
17
17
  gem 'email_spec'
18
18
  gem 'fastercsv'
19
- gem 'system_timer'
20
19
  gem 'bson_ext'
21
20
 
22
21
  if RUBY_VERSION < '1.9'
22
+ gem 'system_timer'
23
23
  gem "ruby-debug", ">= 0.10.3"
24
24
  end
25
25
 
File without changes
@@ -3,8 +3,6 @@ class ContactForm < Noodall::Component
3
3
 
4
4
  has_one :form, :class => Noodall::Form
5
5
 
6
- allowed_positions :wide
7
-
8
6
  module ClassMethods
9
7
  def form_options
10
8
  lists = Noodall::Form.all(:fields => [:id, :title], :order => 'title ASC')
@@ -11,7 +11,8 @@ module Noodall
11
11
  key :defensio_signature, String
12
12
  key :spaminess, Float, :default => 0
13
13
 
14
- before_save :check_for_spam
14
+ before_save :check_for_spam, :if => :defensio_configuired?
15
+
15
16
  attr_protected :approved
16
17
 
17
18
  timestamps!
@@ -21,7 +22,7 @@ module Noodall
21
22
  def required_fields
22
23
  self.form.fields.select{ |f| f.required? }
23
24
  end
24
-
25
+
25
26
  def correct_fields?
26
27
  self.form.fields.each do |f|
27
28
  return false unless self.respond_to?(f.name.downcase.parameterize("_").to_sym)
@@ -57,6 +58,10 @@ module Noodall
57
58
  end
58
59
 
59
60
  protected
61
+ def defensio_configuired?
62
+ defined?(Defensio) && !self.class.defensio_config.blank?
63
+ end
64
+
60
65
  def check_for_spam
61
66
  if self.defensio_signature.blank?
62
67
  status, response = self.class.defensio.post_document(self.defensio_attributes)
@@ -66,7 +71,7 @@ module Noodall
66
71
  self.spaminess = response['spaminess']
67
72
  self.approved = response['allow']
68
73
  end
69
- return true
74
+ return true
70
75
  end
71
76
 
72
77
  def self.defensio
@@ -78,8 +83,12 @@ module Noodall
78
83
  end
79
84
 
80
85
  def self.defensio_config
81
- logger.info "No Defensio config found" unless FileTest.exists?(File.join(Rails.root, 'config', 'defensio.yml'))
82
- @defensio_config ||= YAML::load(File.open(File.join(Rails.root, 'config', 'defensio.yml')))
86
+ begin
87
+ @defensio_config ||= YAML::load(File.open(File.join(Rails.root, 'config', 'defensio.yml')))
88
+ rescue Exception => e
89
+ puts "Failed to load Defensio config: #{e}"
90
+ @defensio_config = {}
91
+ end
83
92
  end
84
93
 
85
94
  def defensio_attributes
@@ -103,17 +112,17 @@ module Noodall
103
112
  required_fields.each do |field|
104
113
  self.errors.add(field.underscored_name.to_sym, "can't be empty") if self.send(field.underscored_name).blank?
105
114
  end
106
- return true if self.errors.empty?
115
+ return true if self.errors.empty?
107
116
  end
108
-
117
+
109
118
  def method_missing(method)
110
- # If the form doesn't have a field that matches this method, act normally. Otherwise, return nil to show the field is empty.
111
- if form.fields.select{|f| f.underscored_name.to_sym == method}.empty?
119
+ # If the form doesn't have a field that matches this method, act normally. Otherwise, return nil to show the field is empty.
120
+ if form.fields.select{|f| f.underscored_name.to_sym == method}.empty?
112
121
  super
113
122
  else
114
123
  return nil
115
124
  end
116
125
  end
117
-
126
+
118
127
  end
119
128
  end
@@ -11,9 +11,16 @@ module Noodall
11
11
  Noodall::UI.menu_items['Forms'] = :noodall_admin_forms_path
12
12
  end
13
13
 
14
- initializer "static assets" do |app|
15
- app.middleware.use ::ActionDispatch::Static, "#{root}/public"
14
+ if Rails::VERSION::MINOR == 0 # if rails 3.0.x
15
+ initializer "static assets" do |app|
16
+ app.middleware.use ::ActionDispatch::Static, "#{root}/app/assets"
17
+ end
18
+ else
19
+ initializer "Add noodall assets to precomiler" do |app|
20
+ app.config.assets.precompile += %w( admin/formbuilder.js )
21
+ end
16
22
  end
23
+
17
24
  end
18
25
  end
19
26
  end
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module FormBuilder
3
- VERSION = "0.3.3"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -1,16 +1,2 @@
1
- defaults: &defaults
2
- api_key: 6cd604f9b2765b05c5ac729b3594fc49
3
- spam_threshold: 0.75
4
-
5
- development:
6
- <<: *defaults
7
-
8
- test:
9
- <<: *defaults
10
-
11
- production:
12
- <<: *defaults
13
-
14
- staging:
15
- <<: *defaults
1
+ api_key: 6cd604f9b2765b05c5ac729b3594fc49
16
2
 
metadata CHANGED
@@ -1,70 +1,53 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: noodall-form-builder
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 3
10
- version: 0.3.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Steve England
14
9
  - Daniel Craig
15
10
  - Alex Heaton
16
11
  autorequire:
17
12
  bindir: bin
18
13
  cert_chain: []
19
-
20
- date: 2011-07-19 00:00:00 +01:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
14
+ date: 2011-11-29 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
24
17
  name: bundler
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
18
+ requirement: &13067740 !ruby/object:Gem::Requirement
26
19
  none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 23
31
- segments:
32
- - 1
33
- - 0
34
- - 0
20
+ requirements:
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
35
23
  version: 1.0.0
36
24
  type: :development
37
25
  prerelease: false
38
- requirement: *id001
39
- - !ruby/object:Gem::Dependency
26
+ version_requirements: *13067740
27
+ - !ruby/object:Gem::Dependency
40
28
  name: fastercsv
41
- version_requirements: &id002 !ruby/object:Gem::Requirement
29
+ requirement: &13067280 !ruby/object:Gem::Requirement
42
30
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- hash: 3
47
- segments:
48
- - 0
49
- version: "0"
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
50
35
  type: :runtime
51
36
  prerelease: false
52
- requirement: *id002
37
+ version_requirements: *13067280
53
38
  description: Functionality for building custom forms
54
39
  email: []
55
-
56
40
  executables: []
57
-
58
41
  extensions: []
59
-
60
42
  extra_rdoc_files: []
61
-
62
- files:
43
+ files:
63
44
  - .gitignore
64
45
  - Gemfile
65
46
  - MIT-LICENSE
66
47
  - README.rdoc
67
48
  - Rakefile
49
+ - app/assets/images/admin/spam-flag.png
50
+ - app/assets/javascripts/admin/formbuilder.js
68
51
  - app/controllers/noodall/admin/fields_controller.rb
69
52
  - app/controllers/noodall/admin/form_responses_controller.rb
70
53
  - app/controllers/noodall/admin/forms_controller.rb
@@ -127,8 +110,6 @@ files:
127
110
  - lib/noodall/form_builder/routes.rb
128
111
  - lib/noodall/form_builder/version.rb
129
112
  - noodall-form-builder.gemspec
130
- - public/images/admin/spam-flag.png
131
- - public/javascripts/admin/formbuilder.js
132
113
  - spec/dummy/Rakefile
133
114
  - spec/dummy/app/controllers/application_controller.rb
134
115
  - spec/dummy/app/helpers/application_helper.rb
@@ -174,41 +155,31 @@ files:
174
155
  - spec/integration/navigation_spec.rb
175
156
  - spec/noodall_form_builder_spec.rb
176
157
  - spec/spec_helper.rb
177
- has_rdoc: true
178
158
  homepage: http://rubygems.org/gems/noodall-form-builder
179
159
  licenses: []
180
-
181
160
  post_install_message:
182
161
  rdoc_options: []
183
-
184
- require_paths:
162
+ require_paths:
185
163
  - lib
186
- required_ruby_version: !ruby/object:Gem::Requirement
164
+ required_ruby_version: !ruby/object:Gem::Requirement
187
165
  none: false
188
- requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- hash: 3
192
- segments:
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ segments:
193
171
  - 0
194
- version: "0"
195
- required_rubygems_version: !ruby/object:Gem::Requirement
172
+ hash: 2077469177402188089
173
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
174
  none: false
197
- requirements:
198
- - - ">="
199
- - !ruby/object:Gem::Version
200
- hash: 23
201
- segments:
202
- - 1
203
- - 3
204
- - 6
175
+ requirements:
176
+ - - ! '>='
177
+ - !ruby/object:Gem::Version
205
178
  version: 1.3.6
206
179
  requirements: []
207
-
208
180
  rubyforge_project:
209
- rubygems_version: 1.4.1
181
+ rubygems_version: 1.8.6
210
182
  signing_key:
211
183
  specification_version: 3
212
184
  summary: Noodall Form Builder
213
185
  test_files: []
214
-