shaf 0.2.0 → 0.2.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: ac593813e29022a180b2109f36148800fd17d60ab86f9bd9e580a22d8a42687c
4
- data.tar.gz: 0b54202b8c00b336ddbb8ec945586dd2bd3b73f1434252ca347a4ebde6764116
3
+ metadata.gz: a160e3aeb1d9b86b59371417e6354d351acfbe9a90efde270b51a1fe2a307a88
4
+ data.tar.gz: d3c9eec43a5b5da8795e1e9396f8916be2458d235a14296c75646be25680b658
5
5
  SHA512:
6
- metadata.gz: f38cd019699f44e951eef30d734577c8ddbde792616ba0f887cf8f8d84544c553efd332679e8cf303b55f8d948ed08d28de960cc57e401e1dd8121c857818edc
7
- data.tar.gz: e0ff681691982c261b114faef75f58cf6e5f18a63183040eb35e1679e6448c071d8499583cb55827cf8c579e1c0104cc71d4f6633c0451f1256a7ddc5e57ccb0
6
+ metadata.gz: '093623e69f3fdf57124cdabd6b01c00129fe77e479ec54aa5d3fdef252ec92fa93895b99708ca7c831421c11c838dbe9e034acec9546c96fc1a5f6197bd39211'
7
+ data.tar.gz: 4305a775fff58412125a1c984d27617c87fdd3d0fa1f20b798f6b47978aeafb34996bcd8f67b97f6ac1e3e1a2f117bf55c33f4e615af10bc0fdf917d61730231
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,7 +8,6 @@ gem 'sinatra', require: 'sinatra/base'
8
8
  gem 'rake'
9
9
  gem 'thin'
10
10
  gem 'sequel'
11
- gem 'sequel'
12
11
  gem 'sinatra-sequel'
13
12
  gem 'bcrypt'
14
13
  gem 'hal_presenter'
@@ -71,7 +71,7 @@ module Shaf
71
71
  file = "api/serializers/root_serializer.rb"
72
72
  unless File.exist? file
73
73
  puts "Warning: file '#{file}' does not exist. "\
74
- "Not adding any link to the #{plural_name} collection"
74
+ "Skip adding link to the #{plural_name} collection"
75
75
  end
76
76
  added = false
77
77
  content = []
@@ -8,6 +8,9 @@ describe <%= model_class_name %>, type: :integration do
8
8
  status.must_equal 200
9
9
  link_rels.must_include(:self)
10
10
  links[:self][:href].must_equal <%= name %>_uri(<%= name %>)
11
+ <% params.each do |param| -%>
12
+ attributes.must_include(:'<%= param[0] %>')
13
+ <% end -%>
11
14
  end
12
15
 
13
16
  it "lists all <%= plural_name %>" do
@@ -18,9 +21,13 @@ describe <%= model_class_name %>, type: :integration do
18
21
  status.must_equal 200
19
22
  link_rels.must_include(:self)
20
23
  links[:self][:href].must_include <%= plural_name %>_uri
21
- embedded :'<%= plural_name %>' do
22
- <%= plural_name %> = last_payload
23
- <%= plural_name %>.size.must_equal 2
24
+ embedded(:'<%= plural_name %>').size.must_equal 2
25
+
26
+ each_embedded :'<%= plural_name %>' do
27
+ link_rels.must_include(:self)
28
+ <% params.each do |param| -%>
29
+ attributes.must_include(:'<%= param[0] %>')
30
+ <% end -%>
24
31
  end
25
32
  end
26
33
 
@@ -21,13 +21,13 @@ module Shaf
21
21
  @assertions = 0
22
22
  end
23
23
 
24
- def call
25
- instance_exec(&@block)
24
+ def call(*args)
25
+ instance_exec(*args, &@block)
26
26
  end
27
27
 
28
28
  def method_missing(method, *args, &block)
29
29
  if @context&.respond_to? method
30
- define_singleton_method(method) { |*a, &b| @context.public_send method, *a, &b }
30
+ define_singleton_method(method) { |*a, &b| @context.public_send(method, *a, &b) }
31
31
  return public_send(method, *args, &block)
32
32
  end
33
33
  super
@@ -37,7 +37,6 @@ module Shaf
37
37
  return true if @context&.respond_to? method
38
38
  super
39
39
  end
40
-
41
40
  end
42
41
 
43
42
  def set_payload(payload)
@@ -73,16 +72,15 @@ module Shaf
73
72
  Embedded.new(last_payload.dig(*keys), self, Proc.new).call
74
73
  end
75
74
 
76
- def embedded_each(name, &block)
75
+ def each_embedded(name, &block)
77
76
  assert_has_embedded name
78
77
  list = last_payload[:_embedded][name]
79
- assert_instance_of(
80
- Array,
81
- list,
78
+
79
+ assert_instance_of Array, list,
82
80
  "Embedded '#{name}' is not an instance of Array. Actual: #{list.class}"
83
- )
84
- list.each do |resource|
85
- Embedded.new(resource, block).call
81
+
82
+ list.each_with_index do |resource, i|
83
+ Embedded.new(resource, self, block).call(i)
86
84
  end
87
85
  end
88
86
 
data/lib/shaf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shaf
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- RK��O(��� D{k⮼_46븘���{}��l�T����:Q���*ab$���Ϸ��R2��T��mnq��Jt�>����ل��ʡ�0#N'u�kUN�,�[ T$ɷ6��5�����]W|��-eexȘp�>� 7q��y������_R�krV�.Y����n7n�;Ws��4Y�.�9ZHT����Y��>�PM��2bRK����r��|í���*�Q] )(6���-�� ��d1� �
1
+ i�.Օ2��r��5VyEd��#LԞ���1�h�^ @�Is�ߚ� ���?�֞����5AC��fb K�����M�e����VV38Yc �DS��?��.��b)�Qv�Dy��cE,r=aRN)�$|��@̻�ܙ�$1Wf��ϩ��dVd�����u�g���B��e��@�\�w�����-��l9�y����s�|�7:<ZH '�#H94vVnCe�۠ K8xXx�/nY����
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sammy Henningsson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  CNZdF8Vavp6xMQbPHZwqjaeZz2WRXYS7jyYSvCunjwa3OtvXtfbIEGEWE6IM+t9k
32
32
  H1g6Q+B6qk9O6g==
33
33
  -----END CERTIFICATE-----
34
- date: 2018-03-08 00:00:00.000000000 Z
34
+ date: 2018-03-14 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
metadata.gz.sig CHANGED
Binary file