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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e37b49868c536a8d8503d2a5683954c7516484a
4
- data.tar.gz: ef5ee94200206d675fd9e5811e5fa8e7def1ba1b
3
+ metadata.gz: ea04ef7ab11006de7ea0fa197ecaa6f174ea07c3
4
+ data.tar.gz: 2f83bc5902bb5a6a52ad05cd88715f13412ca711
5
5
  SHA512:
6
- metadata.gz: c3f007ac63cb9f092a340151f21c6909168fb5682e26a30f098cf4e64e0ebcf62fda4f6049f3a6b3df1c0d136c8ec62d5110aad74b840584398b039a7c309807
7
- data.tar.gz: 63e5c473c65b9cff8abda6d92955ad51bb3c539990d8ca22cb3d910dd6db6e151648f1f32d7541799a9a038a8dc48e2ee20422bc31b7d909fadbd48cd1edaf83
6
+ metadata.gz: 47c19916ba996e135ece1fc7378f516edb5181830975dc64abb5c0544e558644af91914e7ae47e40f1cfab23c20c9537e05a69aeacb262421872e0aa98007694
7
+ data.tar.gz: 4599bc0b3904cf8eb67d8cd0bba6ae9711031e0e7d97af72c40daf9d712317cc369186fed0a6d3fe1f0970d074443dc8f9f1562e3e3c7b007feec7c6a73cc8bc
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Shoden Contrib
1
+ # Shoden Contrib - [![Gem Version](https://badge.fury.io/rb/shoden-contrib.svg)](http://badge.fury.io/rb/shoden-contrib)
2
2
 
3
3
  ![](http://www.lashwallpapers.com/wp-content/uploads/2014/05/elephant-wallpaper-in-hd-free-download.jpg)
4
4
 
@@ -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)) }
@@ -18,7 +18,7 @@ module Shoden
18
18
  super
19
19
 
20
20
  self.class.default_attributes.each do |k,v|
21
- self.send("#{k}=", v) if !self.send(k)
21
+ self.send(:"#{k}=", v) if !@attributes.keys.include?(k)
22
22
  end
23
23
  end
24
24
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "shoden-contrib"
3
- s.version = "0.1.0"
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", "~> 0.2.0")
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
- assert_equal country.name, 'Uruguay'
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.0
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-28 00:00:00.000000000 Z
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