rasti-model 1.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d85d0034827688a0aea67f255e2ac0ea95a273da7a38dc66c823f032cf95830
4
- data.tar.gz: 63fed2869a50ba059f73f878c1eace99b00068df719a1d373bcbe627edac7e16
3
+ metadata.gz: cd4831ac82eadc7515e4103a10fe010346ec8719d16db0d30103a713b5cd15ef
4
+ data.tar.gz: b363b3bb323dbb5d1eec404e6adb7c3eef6d6673b0a19474d467a40551f280f8
5
5
  SHA512:
6
- metadata.gz: 8934c038b6dabbf06f6c6405751fe9691a75495089ba3c2c177f82dd5c486dbd14954a39a757232774fe6e36b6a631529286db3a9427d79bc857ddddd8852596
7
- data.tar.gz: 4b967d4b0cfae3cd0b1cf4c405a8422230f01836554108bd4f3e27756d2d50c7bcea46ead161b7066c570296fc3aa2799faafba636d1c8f54ccdc48a7655ebb4
6
+ metadata.gz: 2e0659afca7e7f8a38731ea5901029f4f346895f357430970eba5f251745e2ceaa765ac9731e47c03a7504e2d66d9fccf57e08ea7f58230fabab8c86ca3e2962
7
+ data.tar.gz: aabf1480e4bd1b45c6cde754775714047beff31d89a571fb1b617f4aa4f174a65b922fecd8ddcd90ee3b2acaedf5e3aae70a63d33ddfdcbdde41bbe35fcb8fc9
@@ -0,0 +1,26 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ '**' ]
6
+ pull_request:
7
+ branches: [ '**' ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ name: Tests
13
+ runs-on: ubuntu-22.04
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', 'jruby-9.2.9.0']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true
25
+ - name: Run tests
26
+ run: bundle exec rake
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Rasti::Model
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/rasti-model.svg)](https://rubygems.org/gems/rasti-model)
4
- [![Build Status](https://travis-ci.org/gabynaiman/rasti-model.svg?branch=master)](https://travis-ci.org/gabynaiman/rasti-model)
4
+ [![CI](https://github.com/gabynaiman/rasti-model/actions/workflows/ci.yml/badge.svg)](https://github.com/gabynaiman/rasti-model/actions/workflows/ci.yml)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/gabynaiman/rasti-model/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/rasti-model?branch=master)
6
6
  [![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-model.svg)](https://codeclimate.com/github/gabynaiman/rasti-model)
7
7
 
@@ -18,6 +18,10 @@ module Rasti
18
18
  options.fetch(:default)
19
19
  end
20
20
 
21
+ def option(name)
22
+ options[name]
23
+ end
24
+
21
25
  def to_s
22
26
  "#{self.class}[name: #{name.inspect}, type: #{type.inspect}, options: #{options.inspect}]"
23
27
  end
@@ -1,5 +1,5 @@
1
1
  module Rasti
2
2
  class Model
3
- VERSION = '1.0.1'
3
+ VERSION = '2.0.1'
4
4
  end
5
5
  end
data/lib/rasti/model.rb CHANGED
@@ -148,7 +148,7 @@ module Rasti
148
148
  end
149
149
 
150
150
  def cast_attribute(type, value)
151
- if type.nil? || value.nil?
151
+ if type.nil?
152
152
  value
153
153
  elsif type.is_a?(Symbol)
154
154
  send type, value
data/rasti-model.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'multi_require', '~> 1.0'
22
- spec.add_runtime_dependency 'rasti-types', '~> 1.0'
22
+ spec.add_runtime_dependency 'rasti-types', '~> 2.0'
23
23
 
24
24
  spec.add_development_dependency 'rake', '~> 12.0'
25
25
  spec.add_development_dependency 'minitest', '~> 5.0', '< 5.11'
data/spec/model_spec.rb CHANGED
@@ -170,7 +170,7 @@ describe Rasti::Model do
170
170
  phones: T::Hash[T::Symbol, T::Integer],
171
171
  addresses: T::Array[T::Model[address_class]],
172
172
  labels: T::Array[T::String],
173
- created_at: T::Time['%d/%m/%Y %H:%M:%S %z'],
173
+ created_at: T::Time['%Y-%m-%d %H:%M:%S %z'],
174
174
  updated_at: nil
175
175
  ]
176
176
  end
@@ -193,8 +193,8 @@ describe Rasti::Model do
193
193
  {street: 'Park Avenue', number: 456}
194
194
  ],
195
195
  labels: ['Friend', 'Work'],
196
- created_at: '16/03/2021 09:30:10 -0300',
197
- updated_at: Time.parse('2021-03-16T11:45:20-03:00')
196
+ created_at: Time.parse('16/03/2021 09:30:10 -0200').to_s,
197
+ updated_at: Time.parse('2021-03-16T11:45:20+04:00')
198
198
  }
199
199
  end
200
200
 
@@ -257,6 +257,16 @@ describe Rasti::Model do
257
257
  point_2.y.must_equal 2
258
258
  end
259
259
 
260
+ it 'Custom attribute options' do
261
+ model = Class.new(Rasti::Model) do
262
+ attribute :text, T::String, description: 'Test description'
263
+ end
264
+
265
+ attribute = model.attributes.first
266
+ attribute.option(:description).must_equal 'Test description'
267
+ attribute.option(:undefined).must_be_nil
268
+ end
269
+
260
270
  it 'to_s' do
261
271
  Position.to_s.must_equal 'Position[type, point]'
262
272
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasti-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-16 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_require
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -150,10 +150,10 @@ extensions: []
150
150
  extra_rdoc_files: []
151
151
  files:
152
152
  - ".coveralls.yml"
153
+ - ".github/workflows/ci.yml"
153
154
  - ".gitignore"
154
155
  - ".ruby-gemset"
155
156
  - ".ruby-version"
156
- - ".travis.yml"
157
157
  - Gemfile
158
158
  - LICENSE.txt
159
159
  - README.md
data/.travis.yml DELETED
@@ -1,20 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - 2.0
5
- - 2.1
6
- - 2.2
7
- - 2.3
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
- - 2.7
12
- - jruby-9.2.9.0
13
- - ruby-head
14
- - jruby-head
15
-
16
- matrix:
17
- fast_finish: true
18
- allow_failures:
19
- - rvm: ruby-head
20
- - rvm: jruby-head