simplify_api 0.1.4 → 0.1.5
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 +4 -4
- data/lib/simplify_api/simplify_api.rb +1 -0
- data/lib/simplify_api/version.rb +1 -1
- data/simplify_api.gemspec +6 -7
- data/spec/simplify_api_spec.rb +43 -43
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa46f1c19a2fc27848b6ca7996a2236f41be75f03c564aaa6379d9e91155d584
|
4
|
+
data.tar.gz: f4e4bb806bba725c1e0b18e1a2f9a05bd090a10a863c458187d346e405570975
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2f320fb58f8271982cf26ec991817a8d69112ae9d172e3c20f67db9f24dca95fd66f2d2a9776ac07108aae6db08ae1a1d6c57d74de23c0a490d774c106c5df2
|
7
|
+
data.tar.gz: 70a2af56feb3166118be45922f4ed66ccd7d4c42d73eb22df2cca141b0936fc623cd41dacc7a62061f3271ee8c0c296f96dbf59af7405fbebf099e1c95882905
|
data/lib/simplify_api/version.rb
CHANGED
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 = '
|
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
|
data/spec/simplify_api_spec.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'simplify_api'
|
4
4
|
|
5
5
|
describe SimplifyApi do
|
6
|
-
describe
|
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
|
15
|
+
it 'should work with no attributes' do
|
16
16
|
expect(subject.class).to eq Test
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
subject.name =
|
19
|
+
it 'should accept adhoc parameters' do
|
20
|
+
subject.name = 'João da Silva'
|
21
21
|
|
22
|
-
expect(subject.name).to eq
|
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
|
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:
|
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
|
41
|
-
subject = Test.new(name:
|
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
|
47
|
+
expect(subject.name).to eq 'João da Silva'
|
48
48
|
expect(subject.surname).to eq nil
|
49
|
-
expect(subject.country).to eq
|
49
|
+
expect(subject.country).to eq 'Brazil'
|
50
50
|
end
|
51
51
|
|
52
|
-
it
|
53
|
-
subject = Test.new(name:
|
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:
|
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
|
60
|
-
subject = Test.new(name:
|
61
|
-
subject.email =
|
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
|
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
|
70
|
-
subject = Test.new(name:
|
71
|
-
subject.languages = [
|
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
|
78
|
-
json_value = JSON.parse(
|
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
|
82
|
-
expect(subject.country).to eq
|
83
|
-
expect(subject.email).to eq
|
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
|
87
|
-
json_value = JSON.parse(
|
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
|
98
|
-
expect(subject.country).to eq
|
99
|
-
expect(subject.email).to eq
|
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
|
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
|
121
|
-
json_value = JSON.parse(
|
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": "
|
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
|
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
|
134
|
-
expect(subject.locations[1].title).to eq
|
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
|
+
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
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: '
|
83
|
-
description:
|
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: []
|