towsta 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  module Towsta
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -129,11 +129,22 @@ module Towsta
129
129
  return "@#{attr} = value.to_f;" if kind == 'money'
130
130
  return "@#{attr} = value.to_i;" if kind == 'integer'
131
131
  return "@#{attr} = value == '1';" if kind == 'boolean'
132
- return "@#{attr} = Date.strptime(value, '%m/%d/%Y');" if kind == 'date'
133
- return "@#{attr} = DateTime.strptime(value, '%m/%d/%Y %H:%M').to_time;" if kind == 'datetime'
132
+ return "@#{attr} = Vertical.to_dt(value);" if kind == 'datetime'
133
+ return "@#{attr} = Vertical.to_d(value);" if kind == 'date'
134
134
  return "@#{attr} = User.find value.to_i;" if kind == 'user'
135
135
  "@#{attr} = value;"
136
136
  end
137
+
138
+ def self.to_dt value
139
+ begin; DateTime.strptime(value, '%m/%d/%Y %H:%M').to_time;
140
+ rescue; nil; end;
141
+ end
142
+
143
+ def self.to_d value
144
+ begin; DateTime.strptime(value, '%m/%d/%Y %H:%M');
145
+ rescue; nil; end;
146
+ end
147
+
137
148
  end
138
149
 
139
150
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mortaro
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-24 00:00:00 -03:00
17
+ date: 2011-04-25 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,6 @@ files:
48
48
  - lib/towsta/tree.rb
49
49
  - lib/towsta/version.rb
50
50
  - lib/towsta/vertical.rb
51
- - test.json
52
51
  - towsta.gemspec
53
52
  has_rdoc: true
54
53
  homepage: http://rubygems.org/gems/towsta
data/test.json DELETED
@@ -1 +0,0 @@
1
- {"name":"test","structures":[{"name":"Book","slices":{"name":"main","author":"user","review":"formated","id":"integer"}},{"name":"Movie","slices":{"name":"main","author":"user","review":"formated","id":"integer","data_de_lancamento":"date","book":"vertical"}}],"verticals":[{"horizontals":[{"name":"Kama Sutra","author":6,"review":"Sex positions book","id":6},{"name":"Shit my dad says","author":6,"review":"lot of shits my dad said","id":7}]},{"horizontals":[{"name":"Porn dance","author":6,"review":"aoshdoashd","id":12,"data_de_lancamento":"03/24/2011","book":"6"}]}],"revision":30,"users":[{"nick":"Admin","id":6,"email":"admin@test.com"}]}