shoden-contrib 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/shoden/datatypes.rb +4 -0
- data/lib/shoden/default.rb +1 -1
- data/shoden-contrib.gemspec +2 -2
- data/test/default_test.rb +16 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea04ef7ab11006de7ea0fa197ecaa6f174ea07c3
|
4
|
+
data.tar.gz: 2f83bc5902bb5a6a52ad05cd88715f13412ca711
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47c19916ba996e135ece1fc7378f516edb5181830975dc64abb5c0544e558644af91914e7ae47e40f1cfab23c20c9537e05a69aeacb262421872e0aa98007694
|
7
|
+
data.tar.gz: 4599bc0b3904cf8eb67d8cd0bba6ae9711031e0e7d97af72c40daf9d712317cc369186fed0a6d3fe1f0970d074443dc8f9f1562e3e3c7b007feec7c6a73cc8bc
|
data/README.md
CHANGED
data/lib/shoden/datatypes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'bigdecimal'
|
2
2
|
require 'json'
|
3
|
+
require 'date'
|
4
|
+
require 'time'
|
5
|
+
require 'set'
|
3
6
|
|
4
7
|
module Shoden
|
5
8
|
module DataTypes
|
@@ -9,6 +12,7 @@ module Shoden
|
|
9
12
|
Integer = ->(x) { x.to_i }
|
10
13
|
Decimal = ->(x) { BigDecimal(x.to_s) }
|
11
14
|
Float = ->(x) { x.to_f }
|
15
|
+
Boolean = ->(x) { !!x }
|
12
16
|
Symbol = ->(x) { x && x.to_sym }
|
13
17
|
Time = ->(t) { t && (t.kind_of?(::Time) ? t : ::Time.parse(t)) }
|
14
18
|
Date = ->(d) { d && (d.kind_of?(::Date) ? d : ::Date.parse(d)) }
|
data/lib/shoden/default.rb
CHANGED
data/shoden-contrib.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "shoden-contrib"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.1"
|
4
4
|
s.summary = "Contrib helpers for shoden"
|
5
5
|
s.description = "Makes your life easier"
|
6
6
|
s.authors = ["elcuervo"]
|
@@ -10,6 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.files = `git ls-files`.split("\n")
|
11
11
|
s.test_files = `git ls-files test`.split("\n")
|
12
12
|
|
13
|
-
s.add_dependency("shoden", "
|
13
|
+
s.add_dependency("shoden", ">= 0.2.0")
|
14
14
|
s.add_development_dependency("cutest", "~> 1.2.1")
|
15
15
|
end
|
data/test/default_test.rb
CHANGED
@@ -2,12 +2,26 @@ require_relative 'helper'
|
|
2
2
|
|
3
3
|
class Country < Shoden::Model
|
4
4
|
include Shoden::Default
|
5
|
+
include Shoden::DataTypes
|
5
6
|
|
6
7
|
attribute :name
|
8
|
+
attribute :free, Type::Boolean
|
9
|
+
|
7
10
|
default :name, 'Uruguay'
|
11
|
+
default :free, true
|
8
12
|
end
|
9
13
|
|
10
14
|
test 'default values' do
|
11
|
-
country = Country.new
|
12
|
-
|
15
|
+
country = Country.new(name: 'Argentina', free: false)
|
16
|
+
|
17
|
+
assert_equal country.name, 'Argentina'
|
18
|
+
assert_equal Country.new.name, 'Uruguay'
|
19
|
+
|
20
|
+
c1 = country.save
|
21
|
+
c2 = Country.new.save
|
22
|
+
|
23
|
+
assert_equal c1.name, 'Argentina'
|
24
|
+
assert_equal c2.name, 'Uruguay'
|
25
|
+
|
26
|
+
assert Country[c1.id].name == 'Argentina'
|
13
27
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoden-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- elcuervo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoden
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|