intranet-pictures 1.0.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 564df3bd8811c29b26f35a7a9a883e5af23d4092e63d616240d76cd73c77c2bd
4
- data.tar.gz: af344718de64f2952b30ed0249cf52bddfafc30eaf45498e02378bbcb1198623
3
+ metadata.gz: e66eb28eaa3e467128bdc27efb08312858b12287802c3a87edce02b1140e07a8
4
+ data.tar.gz: 743fe1ff0f2d48803a49915cdf7228591f05659450edcd4261f0a6bbc8338c35
5
5
  SHA512:
6
- metadata.gz: 6a321298b67ea2822c0bc75b2bdaa5473b0cf38b9fc2dac6badb90f37f9dd1535425101f129b5f8d61c457d3611e28ee2d33e397ce792d8cf380be66c46d831d
7
- data.tar.gz: '098fe4089fd07dd9843dc1ebd023c841be1668113c394cddc7dc0407457d1f19bcc4060342969facebeb9eea7c29c9abb484caf3d0720041971251f68bcbfe6f'
6
+ metadata.gz: 97a43240f2124083e2ebabc109e8b5f7fa10d2d5c91c83f5f3a0f65c8a0671a4ac58cb30de709b57e1f4b527ffe91f883b3f30a25bf82bd3700fefe377f17cae
7
+ data.tar.gz: da6b3cc170771ff37c89a0b2e729463482d513654373e18137a2d8726f28898d4311aafbab6d0a429eae16204552ebb0c7d0021b4c9b75435bbac0ac7a8484a1
@@ -182,15 +182,17 @@ module Intranet
182
182
  def select_groups(type, selector)
183
183
  return @json.fetch('groups').fetch(type) if selector.empty? # optimization
184
184
 
185
- groups_id = @json.fetch('pictures').map do |p|
186
- p.fetch(type) if picture_match?(p, selector)
187
- end.uniq.compact
185
+ groups_id = select_pictures_having(type, selector).map { |p| p.fetch(type) }.uniq.compact
188
186
  @json.fetch('groups').fetch(type).select { |g| groups_id.include?(g.fetch('id')) }
189
187
  end
190
188
 
191
189
  def select_pictures(selector)
192
190
  @json.fetch('pictures').select { |p| picture_match?(p, selector) }
193
191
  end
192
+
193
+ def select_pictures_having(group_type, selector)
194
+ @json.fetch('pictures').select { |p| p.key?(group_type) && picture_match?(p, selector) }
195
+ end
194
196
  end
195
197
  end
196
198
  end
@@ -8,7 +8,7 @@ module Intranet
8
8
  NAME = 'intranet-pictures'
9
9
 
10
10
  # The version of the gem, according to semantic versionning.
11
- VERSION = '1.0.4'
11
+ VERSION = '1.0.5'
12
12
 
13
13
  # The URL of the gem homepage.
14
14
  HOMEPAGE_URL = 'https://rubygems.org/gems/intranet-pictures'
@@ -30,7 +30,7 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
30
30
  end
31
31
 
32
32
  it 'should return the available group types' do
33
- expect(@provider.group_types).to eql(%w[group1 group2])
33
+ expect(@provider.group_types).to eql(%w[group1 group2 group3])
34
34
  end
35
35
  end
36
36
 
@@ -54,6 +54,12 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
54
54
  { 'id' => 'group2_title3', 'title' => 'Group 2, Title 3', 'value' => 'aabb' }
55
55
  ]
56
56
  )
57
+ expect(@provider.list_groups('group3')).to eql(
58
+ [
59
+ { 'id' => 'group3_title1', 'title' => 'Group 3, Title 1' },
60
+ { 'id' => 'group3_title2', 'title' => 'Group 3, Title 2' }
61
+ ]
62
+ )
57
63
  end
58
64
 
59
65
  it 'should return only the groups matching the given +selector+' do
@@ -87,7 +93,14 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
87
93
  ]
88
94
  )
89
95
 
90
- selector = { 'group3' => 'foo_bar_boz' } # referencing undefined fields
96
+ selector = { 'value' => true }
97
+ expect(@provider.list_groups('group3', selector)).to eql(
98
+ [
99
+ { 'id' => 'group3_title2', 'title' => 'Group 3, Title 2' }
100
+ ]
101
+ )
102
+
103
+ selector = { 'group4' => 'foo_bar_boz' } # referencing undefined fields
91
104
  expect(@provider.list_groups('group2', selector)).to eql([])
92
105
  end
93
106
  end
@@ -132,10 +145,10 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
132
145
  it 'should return the list of pictures without the uri key' do
133
146
  expect(@provider.list_pictures).to eql(
134
147
  [
135
- { 'datetime' => '2019:07:22 09:41:31', 'group1' => 'group1_title1', 'group2' => 'group2_title2' },
148
+ { 'datetime' => '2019:07:22 09:41:31', 'group1' => 'group1_title1', 'group2' => 'group2_title2', 'group3' => 'group3_title1' },
136
149
  { 'datetime' => '2020:06:19 07:51:05', 'value' => false, 'group1' => 'group1_title2', 'group2' => 'group2_title2' },
137
150
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
138
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' },
151
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' },
139
152
  { 'datetime' => '2019:07:22 09:45:17', 'group1' => 'group1_title1', 'group2' => 'group2_title3' }
140
153
  ]
141
154
  )
@@ -147,7 +160,7 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
147
160
  [
148
161
  { 'datetime' => '2020:06:19 07:51:05', 'value' => false, 'group1' => 'group1_title2', 'group2' => 'group2_title2' },
149
162
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
150
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' }
163
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' }
151
164
  ]
152
165
  )
153
166
  end
@@ -159,14 +172,14 @@ RSpec.describe Intranet::Pictures::JsonDbProvider do
159
172
  [
160
173
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
161
174
  { 'datetime' => '2020:06:19 07:51:05', 'value' => false, 'group1' => 'group1_title2', 'group2' => 'group2_title2' },
162
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' }
175
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' }
163
176
  ]
164
177
  )
165
178
 
166
179
  expect(@provider.list_pictures(selector, 'datetime', false)).to eql(
167
180
  [
168
181
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
169
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' },
182
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' },
170
183
  { 'datetime' => '2020:06:19 07:51:05', 'value' => false, 'group1' => 'group1_title2', 'group2' => 'group2_title2' }
171
184
  ]
172
185
  )
@@ -71,25 +71,25 @@ RSpec.describe Intranet::Pictures::Responder do
71
71
  describe '#generate_page' do
72
72
  def photoswipe_markup # rubocop:disable Metrics/MethodLength
73
73
  "<div aria-hidden class='pswp' role='dialog' tabindex='-1'>\n" \
74
- "<div class='pswp__bg'></div>\n" \
75
- "<div class='pswp__scroll-wrap'>\n" \
76
- "<div class='pswp__container'>\n" \
77
- "<div class='pswp__item'></div>\n" \
78
- "<div class='pswp__item'></div>\n" \
79
- "<div class='pswp__item'></div>\n" \
80
- "</div>\n" \
81
- "<div class='pswp__ui pswp__ui--hidden'>\n" \
82
- "<div class='pswp__top-bar'>\n" \
83
- "<div class='pswp__counter'></div>\n" \
84
- "<button class='pswp__button pswp__button--close' title='#{I18n.t('pictures.viewer.close')} (Esc)'></button>\n" \
85
- "<button class='pswp__button pswp__button--fs' title='#{I18n.t('pictures.viewer.fullscreen')}'></button>\n" \
86
- "<button class='pswp__button pswp__button--zoom' title='#{I18n.t('pictures.viewer.zoom')}'></button>\n" \
87
- "<div class='pswp__preloader'>\n<div class='pswp__preloader__icn'>\n<div class='pswp__preloader__cut'>\n<div class='pswp__preloader__donut'></div>\n</div>\n</div>\n</div>\n</div>\n" \
88
- "<div class='pswp__share-modal pswp__share-modal--hidden pswp__single-tap'>\n<div class='pswp__share-tooltip'></div>\n</div>\n" \
89
- "<button class='pswp__button pswp__button--arrow--left' title='#{I18n.t('pictures.viewer.previous')}'></button>\n" \
90
- "<button class='pswp__button pswp__button--arrow--right' title='#{I18n.t('pictures.viewer.next')}'></button>\n" \
91
- "<div class='pswp__caption'>\n<div class='pswp__caption__center'></div>\n</div>\n" \
92
- "</div>\n</div>\n</div>\n\n"
74
+ "<div class='pswp__bg'></div>\n" \
75
+ "<div class='pswp__scroll-wrap'>\n" \
76
+ "<div class='pswp__container'>\n" \
77
+ "<div class='pswp__item'></div>\n" \
78
+ "<div class='pswp__item'></div>\n" \
79
+ "<div class='pswp__item'></div>\n" \
80
+ "</div>\n" \
81
+ "<div class='pswp__ui pswp__ui--hidden'>\n" \
82
+ "<div class='pswp__top-bar'>\n" \
83
+ "<div class='pswp__counter'></div>\n" \
84
+ "<button class='pswp__button pswp__button--close' title='#{I18n.t('pictures.viewer.close')} (Esc)'></button>\n" \
85
+ "<button class='pswp__button pswp__button--fs' title='#{I18n.t('pictures.viewer.fullscreen')}'></button>\n" \
86
+ "<button class='pswp__button pswp__button--zoom' title='#{I18n.t('pictures.viewer.zoom')}'></button>\n" \
87
+ "<div class='pswp__preloader'>\n<div class='pswp__preloader__icn'>\n<div class='pswp__preloader__cut'>\n<div class='pswp__preloader__donut'></div>\n</div>\n</div>\n</div>\n</div>\n" \
88
+ "<div class='pswp__share-modal pswp__share-modal--hidden pswp__single-tap'>\n<div class='pswp__share-tooltip'></div>\n</div>\n" \
89
+ "<button class='pswp__button pswp__button--arrow--left' title='#{I18n.t('pictures.viewer.previous')}'></button>\n" \
90
+ "<button class='pswp__button pswp__button--arrow--right' title='#{I18n.t('pictures.viewer.next')}'></button>\n" \
91
+ "<div class='pswp__caption'>\n<div class='pswp__caption__center'></div>\n</div>\n" \
92
+ "</div>\n</div>\n</div>\n\n"
93
93
  end
94
94
 
95
95
  context 'when asked for \'/index.html\'' do
@@ -426,10 +426,10 @@ RSpec.describe Intranet::Pictures::Responder do
426
426
  expect(mime).to eql('application/json')
427
427
  expect(content).to eql(
428
428
  [
429
- { 'datetime' => '2019:07:22 09:41:31', 'group1' => 'group1_title1', 'group2' => 'group2_title2' },
429
+ { 'datetime' => '2019:07:22 09:41:31', 'group1' => 'group1_title1', 'group2' => 'group2_title2', 'group3' => 'group3_title1' },
430
430
  { 'datetime' => '2020:06:19 07:51:05', 'value' => false, 'group1' => 'group1_title2', 'group2' => 'group2_title2' },
431
431
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
432
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' },
432
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' },
433
433
  { 'datetime' => '2019:07:22 09:45:17', 'group1' => 'group1_title1', 'group2' => 'group2_title3' }
434
434
  ].to_json
435
435
  )
@@ -442,7 +442,7 @@ RSpec.describe Intranet::Pictures::Responder do
442
442
  expect(content).to eql(
443
443
  [
444
444
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' },
445
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' }
445
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' }
446
446
  ].to_json
447
447
  )
448
448
 
@@ -453,7 +453,7 @@ RSpec.describe Intranet::Pictures::Responder do
453
453
  expect(mime).to eql('application/json')
454
454
  expect(content).to eql(
455
455
  [
456
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' },
456
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' },
457
457
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' }
458
458
  ].to_json
459
459
  )
@@ -464,7 +464,7 @@ RSpec.describe Intranet::Pictures::Responder do
464
464
  expect(mime).to eql('application/json')
465
465
  expect(content).to eql(
466
466
  [
467
- { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3' },
467
+ { 'datetime' => '2020:06:20 06:09:54', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title3', 'group3' => 'group3_title2' },
468
468
  { 'datetime' => '2020:06:20 18:14:09', 'value' => true, 'group1' => 'group1_title2', 'group2' => 'group2_title1' }
469
469
  ].to_json
470
470
  )
@@ -32,6 +32,16 @@
32
32
  "title": "Group 2, Title 3",
33
33
  "value": "aabb"
34
34
  }
35
+ ],
36
+ "group3": [
37
+ {
38
+ "id": "group3_title1",
39
+ "title": "Group 3, Title 1"
40
+ },
41
+ {
42
+ "id": "group3_title2",
43
+ "title": "Group 3, Title 2"
44
+ }
35
45
  ]
36
46
  },
37
47
  "pictures": [
@@ -39,7 +49,8 @@
39
49
  "uri": "white.jpg",
40
50
  "datetime": "2019:07:22 09:41:31",
41
51
  "group1": "group1_title1",
42
- "group2": "group2_title2"
52
+ "group2": "group2_title2",
53
+ "group3": "group3_title1"
43
54
  },
44
55
  {
45
56
  "uri": "./alpha.png",
@@ -60,7 +71,8 @@
60
71
  "datetime": "2020:06:20 06:09:54",
61
72
  "value": true,
62
73
  "group1": "group1_title2",
63
- "group2": "group2_title3"
74
+ "group2": "group2_title3",
75
+ "group3": "group3_title2"
64
76
  },
65
77
  {
66
78
  "datetime": "2019:07:22 09:45:17",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intranet-pictures
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ebling Mis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-04 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: intranet-core
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.7.6.2
170
+ rubygems_version: 3.2.5
172
171
  signing_key:
173
172
  specification_version: 4
174
173
  summary: Pictures gallery module for the intranet.