populate-me 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ # Extends standard classes
4
+
5
+ Integer.class_eval do
6
+ def to_price_string
7
+ ("%.2f" % (self/100.0)).sub(/\.00/, '')
8
+ end
9
+ end
10
+
11
+ String.class_eval do
12
+ def to_price_integer
13
+ ("%.2f" % self.gsub(/[^\d\.\-]/, '')).gsub(/\./,'').to_i
14
+ end
15
+ end
16
+
@@ -33,11 +33,8 @@ module PopulateMe
33
33
  crushyform_types[:string].call(m,c,o)
34
34
  end,
35
35
  :price => proc do |m,c,o|
36
- crushid = m.field_id_for(c)
37
- price_main, price_cents = o[:input_value].to_i.divmod(100)
38
- out = "<input type='text' name='%s[]' id='%s-main' class='%s price-main' value='%s' size='10' />&nbsp;&bull;&nbsp;"
39
- out << "<input type='text' name='%s[]' id='%s-cents' class='%s price-cents' value='%s' size='2' maxlength='2' />"
40
- out % [o[:input_name], crushid, o[:input_class], price_main, o[:input_name], crushid, o[:input_class], "%02d" % price_cents]
36
+ value = o[:input_value].to_price_string if o[:input_value].respond_to?(:to_price_string)
37
+ "<input type='%s' name='%s' value=\"%s\" id='%s' class='%s' %s />%s\n" % [o[:input_type]||'text', o[:input_name], value, m.field_id_for(c), o[:input_class], o[:required]&&'required', o[:required]]
41
38
  end,
42
39
  :boolean => proc do |m,c,o|
43
40
  crushid = m.field_id_for(c)
@@ -213,7 +213,7 @@ module PopulateMe
213
213
  def after_validation; end
214
214
  def fix_type_integer(k,v); @doc[k] = v.to_i; end
215
215
  def fix_type_price(k,v)
216
- v.kind_of?(Array) ? @doc[k] = (v[0].to_i*100)+v[1].to_i : @doc[k] = v.to_i
216
+ @doc[k] = v.respond_to?(:to_price_integer) ? v.to_price_integer : v
217
217
  end
218
218
  def fix_type_boolean(k,v); @doc[k] = (v=='true'||v==true) ? true : false; end
219
219
  def fix_type_slug(k,v); @doc[k] = self.auto_slug if v.to_s==''; end
@@ -1,2 +1,3 @@
1
1
  # encoding: utf-8
2
+ require "populate_me/ext"
2
3
  require 'populate_me/mongo/plug'
data/populate-me.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'populate-me'
3
- s.version = "0.0.13"
3
+ s.version = "0.0.14"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.summary = "ALPHA !!! Populate Me is relatively complete but simple CMS"
6
6
  s.description = "ALPHA !!! Populate Me is relatively complete but simple CMS. It includes a Rack middleware for putting in your Rack stack, and a bespoke MongoDB ODM. But Populate Me is not really finished yet."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: populate-me
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
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-06-27 00:00:00.000000000 Z
12
+ date: 2013-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack-golem
@@ -87,6 +87,7 @@ files:
87
87
  - lib/populate_me/control/_public/js/plugin.quicksearch.js
88
88
  - lib/populate_me/control/_public/js/plugin.underwood.js
89
89
  - lib/populate_me/control/views/populate_me_layout.erb
90
+ - lib/populate_me/ext.rb
90
91
  - lib/populate_me/mongo.rb
91
92
  - lib/populate_me/mongo/backend_api_plug.rb
92
93
  - lib/populate_me/mongo/crushyform.rb
@@ -120,3 +121,4 @@ signing_key:
120
121
  specification_version: 3
121
122
  summary: ALPHA !!! Populate Me is relatively complete but simple CMS
122
123
  test_files: []
124
+ has_rdoc: