intranet-core 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: ee6b74171f37150ff5b9223147357e1fea80d07c
4
- data.tar.gz: a962d285ddb206b084b5e0d7d531d4a747c9f77d
3
+ metadata.gz: 16bba6e4fbd42e10c7c782d5171b4092f5d116a0
4
+ data.tar.gz: ac817457c107a692555ae55af7bd98337094c778
5
5
  SHA512:
6
- metadata.gz: 88f361d697c2e5e9e2560247ca8ba5cd19960ee5e12129c903fd26c83654b16e4102a41d4ac7b160dc2f108ee05c62d4887ec561390329552e3a59f90299de6f
7
- data.tar.gz: 86370fd5244a3bacb3551a0ede1b0252b1fda8e74bc14aaf285fb2a37856ba695265af288d5888c067aab7de4f3267d5b2dff470db6eb310522705f71de0a11f
6
+ metadata.gz: 4446887c3d60d16dbacea6820f17f4679490ee0bb83b20cbd5c12d2c9c5e5f98d60e21df0126632539d6789f92a9723bec7ff6a8b7c34d32197ed07e73c9cea4
7
+ data.tar.gz: 6708f510f4beeb3dc7bb2d981dd2ce49292f602b23489bf9a6c177829ef04040f5f3fe0dba129c9480723f7131dbee754dafa82d9d76e8c496b345450f1f7304
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'titleize'
4
+
3
5
  module CoreExtensions
4
6
  # @!visibility protected
5
7
  # Extension of Ruby's standard library +String+ class.
@@ -39,5 +41,11 @@ module CoreExtensions
39
41
  def urlized?
40
42
  scan(/[^-_a-z0-9]/).empty?
41
43
  end
44
+
45
+ # Turns underscores into spaces and titleize a string.
46
+ # @return [String]
47
+ def humanize
48
+ tr('_', ' ').titleize
49
+ end
42
50
  end
43
51
  end
@@ -3,6 +3,6 @@
3
3
  module Intranet
4
4
  class Core
5
5
  # The version of the Intranet core, according to semantic versionning.
6
- VERSION = '1.0.1'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
@@ -19,14 +19,14 @@
19
19
  - responders.children_nodes.each do |child_id, child_node|
20
20
  %li
21
21
  - if child_node.children? # Create a dropdown menu entry
22
- %a= I18n.t(child_id + '.menu')
22
+ %a= I18n.t(child_id + '.menu', default: child_id.humanize)
23
23
  %ul
24
24
  - child_node.children_nodes.each do |child_url, node|
25
25
  %li
26
26
  %a{href: '/' + child_id + '/' + child_url + '/index.html'}
27
- = I18n.t(child_id + '.' + child_url + '.menu')
27
+ = I18n.t(child_id + '.' + child_url + '.menu', default: child_url.humanize)
28
28
  - else # Create a regular menu entry
29
- %a{href: '/' + child_id + '/index.html'}= I18n.t(child_id + '.menu')
29
+ %a{href: '/' + child_id + '/index.html'}= I18n.t(child_id + '.menu', default: child_id.humanize)
30
30
 
31
31
  - if is_home
32
32
  %aside
@@ -132,4 +132,21 @@ RSpec.describe CoreExtensions::String do
132
132
  end
133
133
  end
134
134
  end
135
+
136
+ describe '#humanize' do
137
+ context 'given an empty string' do
138
+ it 'should return an empty string' do
139
+ tested_string = ''
140
+ expect(tested_string.humanize).to eql(tested_string)
141
+ end
142
+ end
143
+
144
+ context 'given a snake-case string' do
145
+ it 'should return the corresponding string with spaces and each word capitalized' do
146
+ tested_string = 'this_is_a_sentence_containing_several_words'
147
+ expected_string = 'This Is a Sentence Containing Several Words'
148
+ expect(tested_string.humanize).to eql(expected_string)
149
+ end
150
+ end
151
+ end
135
152
  end
@@ -331,8 +331,8 @@ RSpec.describe Intranet::Core do
331
331
  '/index.html' => [206, 'text/html', { content: 'PARTIAL_CONTENT', title: 'MyTitle' }]
332
332
  )
333
333
  @intranet.register_module(responder, [], responder.resources_dir)
334
- @intranet.register_module(responder, %w[depth1], responder.resources_dir)
335
- @intranet.register_module(responder, %w[depth2 resp1], responder.resources_dir)
334
+ @intranet.register_module(responder, %w[dep_th1], responder.resources_dir)
335
+ @intranet.register_module(responder, %w[depth2 res_p1], responder.resources_dir)
336
336
  @intranet.register_module(responder, %w[depth2 resp2], responder.resources_dir)
337
337
  thread = Thread.new do
338
338
  @intranet.start
@@ -352,12 +352,12 @@ RSpec.describe Intranet::Core do
352
352
  html = socket.readpartial(4096) # read rest of data
353
353
 
354
354
  # Returned HTML document main menu
355
- expect(html).to match(%r{<a href='/depth1/index.html'>.*depth1.*</a>})
355
+ expect(html).to match(%r{<a href='/dep_th1/index.html'>.*Dep Th1.*</a>})
356
356
  expect(html).to match(
357
- %r{<a>.*depth2.*</a>.*<ul>.*<a href='/depth2/resp1/index.html'>.*resp1.*</a>.*</ul>}m
357
+ %r{<a>.*Depth2.*</a>.*<ul>.*<a href='/depth2/res_p1/index.html'>.*Res P1.*</a>.*</ul>}m
358
358
  )
359
359
  expect(html).to match(
360
- %r{<a>.*depth2.*</a>.*<ul>.*<a href='/depth2/resp2/index.html'>.*resp2.*</a>.*</ul>}m
360
+ %r{<a>.*Depth2.*</a>.*<ul>.*<a href='/depth2/resp2/index.html'>.*Resp2.*</a>.*</ul>}m
361
361
  )
362
362
  ensure
363
363
  socket.close
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intranet-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ebling Mis