simplify_api 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: 3d5c993f71e29fbaa2e17f68e43de75d08c4a13b42bb05e0b7b52f3a076de633
4
- data.tar.gz: a6e03c193ac868b30165c4319c2c1a587531baf45c39b970c7b0011a4b1d0978
3
+ metadata.gz: aa46f1c19a2fc27848b6ca7996a2236f41be75f03c564aaa6379d9e91155d584
4
+ data.tar.gz: f4e4bb806bba725c1e0b18e1a2f9a05bd090a10a863c458187d346e405570975
5
5
  SHA512:
6
- metadata.gz: 513ca3a6d2e76ec876a0ed9983476d6f8c04cefa11f640c5e5ec6699ba1dc58f9a09c4b5e328689c6f6d049948d34d3d28abb022fd96284c854a94530e808775
7
- data.tar.gz: 7891192f811ad08bc06619e5e27d8eb0ad9ea65aac4dc7bf0d623e33d0fedbdaa9984631f2239a27aaab885959da2ad6d03c8c860bb4511f98b665d1ffe7286b
6
+ metadata.gz: a2f320fb58f8271982cf26ec991817a8d69112ae9d172e3c20f67db9f24dca95fd66f2d2a9776ac07108aae6db08ae1a1d6c57d74de23c0a490d774c106c5df2
7
+ data.tar.gz: 70a2af56feb3166118be45922f4ed66ccd7d4c42d73eb22df2cca141b0936fc623cd41dacc7a62061f3271ee8c0c296f96dbf59af7405fbebf099e1c95882905
@@ -125,6 +125,7 @@ module SimplifyApi
125
125
  end
126
126
 
127
127
  def valid_value?(name, value)
128
+ return true if value.nil?
128
129
  return true unless klass_attr[name.to_sym][:params].key?(:values)
129
130
 
130
131
  valid_values = klass_attr[name.to_sym][:params][:values]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimplifyApi
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
data/simplify_api.gemspec CHANGED
@@ -11,16 +11,15 @@ Gem::Specification.new do |spec|
11
11
  spec.authors = ['Rodrigo Garcia Couto']
12
12
  spec.email = ['r@rodg.co']
13
13
  spec.summary = 'A simple set of tools to help the use of APIs'
14
- spec.description = 'Fairly usable. A simple set of tools to simplify '\
15
- 'the use of APIs in Ruby'
14
+ spec.description = 'A simple set of tools to simplify the use of APIs in Ruby'
16
15
  spec.homepage = 'https://github.com/rodgco/simplify_api'
17
16
  spec.license = 'MIT'
18
17
  spec.files = `git ls-files -z`.split("\x0")
19
18
  spec.require_paths = ['lib']
20
19
 
21
- spec.add_development_dependency 'bundler'
22
- spec.add_development_dependency 'rspec'
23
- spec.add_development_dependency 'rspec-collection_matchers'
24
- spec.add_development_dependency 'rubocop'
25
- spec.add_development_dependency 'rubocop-performance'
20
+ spec.add_development_dependency 'bundler', '~> 2.0'
21
+ spec.add_development_dependency 'rspec', '~> 3.8'
22
+ spec.add_development_dependency 'rspec-collection_matchers', '~> 1.1'
23
+ spec.add_development_dependency 'rubocop', '~> 0'
24
+ spec.add_development_dependency 'rubocop-performance', '~> 1.4'
26
25
  end
@@ -3,7 +3,7 @@
3
3
  require 'simplify_api'
4
4
 
5
5
  describe SimplifyApi do
6
- describe "without attributes" do
6
+ describe 'without attributes' do
7
7
  before(:all) do
8
8
  class Test
9
9
  include SimplifyApi
@@ -12,96 +12,96 @@ describe SimplifyApi do
12
12
 
13
13
  subject { Test.new }
14
14
 
15
- it "should work with no attributes" do
15
+ it 'should work with no attributes' do
16
16
  expect(subject.class).to eq Test
17
17
  end
18
18
 
19
- it "should accept adhoc parameters" do
20
- subject.name = "João da Silva"
19
+ it 'should accept adhoc parameters' do
20
+ subject.name = 'João da Silva'
21
21
 
22
- expect(subject.name).to eq "João da Silva"
22
+ expect(subject.name).to eq 'João da Silva'
23
23
  expect(subject).to respond_to :name
24
24
  expect(Test.attributes).to include(:name)
25
25
  end
26
26
  end
27
27
 
28
- describe "with attributes" do
28
+ describe 'with attributes' do
29
29
  before(:all) do
30
30
  class Test
31
31
  include SimplifyApi
32
32
  attribute :name, String, mandatory: true
33
33
  attribute :surname, String
34
- attribute :country, String, default: "Brazil"
34
+ attribute :country, String, default: 'Brazil'
35
35
  attribute :is_admin, values: [true, false], default: false
36
36
  attribute :groups, [String]
37
37
  end
38
38
  end
39
39
 
40
- it "should fullfil class description" do
41
- subject = Test.new(name: "João da Silva")
40
+ it 'should fullfil class description' do
41
+ subject = Test.new(name: 'João da Silva')
42
42
 
43
43
  expect{ Test.new }.to raise_error ArgumentError
44
44
  expect(subject).to respond_to :name
45
45
  expect(subject).to respond_to :surname
46
46
  expect(subject).to respond_to :country
47
- expect(subject.name).to eq "João da Silva"
47
+ expect(subject.name).to eq 'João da Silva'
48
48
  expect(subject.surname).to eq nil
49
- expect(subject.country).to eq "Brazil"
49
+ expect(subject.country).to eq 'Brazil'
50
50
  end
51
51
 
52
- it "should not accept value out of list" do
53
- subject = Test.new(name: "João da Silva")
52
+ it 'should not accept value out of list' do
53
+ subject = Test.new(name: 'João da Silva')
54
54
 
55
- expect{ Test.new(name: "João da Silva", is_admin: 1) }.to raise_error ArgumentError
55
+ expect{ Test.new(name: 'João da Silva', is_admin: 1) }.to raise_error ArgumentError
56
56
  expect{ subject.is_admin = 1 }.to raise_error ArgumentError
57
57
  end
58
58
 
59
- it "should accept adhoc parameters" do
60
- subject = Test.new(name: "João da Silva")
61
- subject.email = "joao@mailinator.com"
59
+ it 'should accept adhoc parameters' do
60
+ subject = Test.new(name: 'João da Silva')
61
+ subject.email = 'joao@mailinator.com'
62
62
 
63
63
  expect(subject).to respond_to :email
64
- expect(subject.email).to eq "joao@mailinator.com"
64
+ expect(subject.email).to eq 'joao@mailinator.com'
65
65
  expect(Test.attributes).to include(:email)
66
66
  end
67
67
 
68
68
 
69
- it "should accept array of parameters" do
70
- subject = Test.new(name: "João da Silva", groups: ["Leadership", "Apprentice"])
71
- subject.languages = ["Portuguese", "English", "Spanish"]
69
+ it 'should accept array of parameters' do
70
+ subject = Test.new(name: 'João da Silva', groups: ['Leadership', 'Apprentice'])
71
+ subject.languages = ['Portuguese', 'English', 'Spanish']
72
72
 
73
73
  expect(subject.groups).to have(2).groups
74
74
  expect(subject.languages).to have(3).languages
75
75
  end
76
76
 
77
- it "should be instatiated with json" do
78
- json_value = JSON.parse(%q({ "name": "John Doe", "country": "USA", "email": "joedoe@mailinator.com" }))
77
+ it 'should be instatiated with json' do
78
+ json_value = JSON.parse('{ "name": "John Doe", "country": "USA", "email": "joedoe@mailinator.com" }')
79
79
  subject = Test.new(json_value)
80
80
 
81
- expect(subject.name).to eq "John Doe"
82
- expect(subject.country).to eq "USA"
83
- expect(subject.email).to eq "joedoe@mailinator.com"
81
+ expect(subject.name).to eq 'John Doe'
82
+ expect(subject.country).to eq 'USA'
83
+ expect(subject.email).to eq 'joedoe@mailinator.com'
84
84
  end
85
85
 
86
- it "should be instatiated with json (even complex ones)" do
87
- json_value = JSON.parse(%q({
88
- "name": "John Doe",
89
- "country": "USA",
86
+ it 'should be instatiated with json (even complex ones)' do
87
+ json_value = JSON.parse('{
88
+ "name": "John Doe",
89
+ "country": "USA",
90
90
  "email": "joedoe@mailinator.com",
91
91
  "languages": [
92
92
  "English",
93
93
  "German" ]
94
- }))
94
+ }')
95
95
  subject = Test.new(json_value)
96
96
 
97
- expect(subject.name).to eq "John Doe"
98
- expect(subject.country).to eq "USA"
99
- expect(subject.email).to eq "joedoe@mailinator.com"
97
+ expect(subject.name).to eq 'John Doe'
98
+ expect(subject.country).to eq 'USA'
99
+ expect(subject.email).to eq 'joedoe@mailinator.com'
100
100
  expect(subject.languages).to have(2).languages
101
101
  end
102
102
  end
103
103
 
104
- describe "with nested classes" do
104
+ describe 'with nested classes' do
105
105
  before(:all) do
106
106
  class Location
107
107
  include SimplifyApi
@@ -117,21 +117,21 @@ describe SimplifyApi do
117
117
  end
118
118
  end
119
119
 
120
- it "should instatiate nested classes from JSON" do
121
- json_value = JSON.parse(%q({
122
- "name": "John Doe",
120
+ it 'should instatiate nested classes from JSON' do
121
+ json_value = JSON.parse('{
122
+ "name": "John Doe",
123
123
  "locations": [
124
124
  { "title": "Home", "address": "Elm Street", "city": "New York" },
125
- { "title": "Office", "address": "White House Street", "city": "Washington DC" }
125
+ { "title": "Office", "address": "House Street", "city": "Washington DC" }
126
126
  ]
127
- }))
127
+ }')
128
128
  subject = User.new(json_value)
129
129
 
130
- expect(subject.name).to eq "John Doe"
130
+ expect(subject.name).to eq 'John Doe'
131
131
  expect(subject.locations).to have(2).locations
132
132
  expect(subject.locations[0].class).to be Location
133
- expect(subject.locations[0].title).to eq "Home"
134
- expect(subject.locations[1].title).to eq "Office"
133
+ expect(subject.locations[0].title).to eq 'Home'
134
+ expect(subject.locations[1].title).to eq 'Office'
135
135
  end
136
136
  end
137
137
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Garcia Couto
@@ -14,73 +14,73 @@ dependencies:
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '3.8'
34
34
  type: :development
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: '0'
40
+ version: '3.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec-collection_matchers
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubocop-performance
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
83
- description: Fairly usable. A simple set of tools to simplify the use of APIs in Ruby
82
+ version: '1.4'
83
+ description: A simple set of tools to simplify the use of APIs in Ruby
84
84
  email:
85
85
  - r@rodg.co
86
86
  executables: []