stationed 0.1.0 → 0.2.0
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/README.md +21 -0
- data/app/helpers/placeholder_helper.rb +45 -0
- data/lib/stationed/generators/plugins/devise.rb +2 -2
- data/lib/stationed/generators/plugins/i18n_spec.rb +2 -0
- data/lib/stationed/generators/plugins/strong_parameters.rb +2 -2
- data/lib/stationed/generators/plugins/yard.rb +1 -0
- data/lib/stationed/generators/templates/yard.rake +7 -0
- data/lib/stationed/version.rb +1 -1
- data/spec/dummy/log/test.log +106 -0
- data/spec/helpers/placeholder_helper_spec.rb +36 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8a940b7b782fd708f9dbdb1b3e10d3507fb44d8
|
4
|
+
data.tar.gz: 7e1aea4eec20e7d767922eda2ba8f637b59367dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 023db417672a5477980cf5b8c1f2049a09d7a4356d4ce086cb6d74eff4064d6e85dd0c0e23819c07440ca44ae5629ad1eec133027ab295eec48c693e33c0234b
|
7
|
+
data.tar.gz: 0ef4a07defd85264ff48e1195db0c74a79f46ed166cb1565e75880e31ca141916941f5ee89677bf3d2e5ad5b573b185894f14117045703b0e00a49fa5c92f26d
|
data/README.md
CHANGED
@@ -99,6 +99,27 @@ methods for `new`, `edit`, `show`, `destroy` and `index`, in the variants
|
|
99
99
|
`link_to`, `button_to` and `button_link_to` (for links with a `button` class
|
100
100
|
name).
|
101
101
|
|
102
|
+
### Placeholders
|
103
|
+
|
104
|
+
Display a placeholder message using standardized markup and a message defined
|
105
|
+
through I18n.
|
106
|
+
|
107
|
+
When in a controller PostsController and action index, this will try to look up
|
108
|
+
the following placeholder keys:
|
109
|
+
|
110
|
+
* placeholders.posts.index
|
111
|
+
* placeholders.posts.default
|
112
|
+
* placeholders.defaults.index
|
113
|
+
|
114
|
+
You can also provide an argument to set the placeholder message. When given a
|
115
|
+
string, it will be used directly as the placeholder message. When given a
|
116
|
+
symbol, that key will be looked up in the `placeholders.defaults` namespace
|
117
|
+
using I18n.
|
118
|
+
|
119
|
+
For example:
|
120
|
+
|
121
|
+
placeholder('Nothing found') # => '<p class="placeholder">Nothing found</p>'
|
122
|
+
|
102
123
|
### Templates
|
103
124
|
|
104
125
|
Stationed includes customized scaffold templates for Haml, Rspec and
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Provides the `placeholder` helper method for showing standard markup
|
2
|
+
# for when thing are missing or not present yet.
|
3
|
+
module PlaceholderHelper
|
4
|
+
# Display a placeholder message using standardized markup and a message
|
5
|
+
# defined through I18n.
|
6
|
+
#
|
7
|
+
# When in a controller PostsController and action index, this will try
|
8
|
+
# to look up the following placeholder keys:
|
9
|
+
#
|
10
|
+
# * placeholders.posts.index
|
11
|
+
# * placeholders.posts.default
|
12
|
+
# * placeholders.defaults.index
|
13
|
+
#
|
14
|
+
# You can also provide an argument to set the placeholder message. When given
|
15
|
+
# a string, it will be used directly as the placeholder message. When given a
|
16
|
+
# symbol, that key will be looked up in the `placeholders.defaults` namespace
|
17
|
+
# using I18n.
|
18
|
+
#
|
19
|
+
# @return [String] e.g. '<p class="placeholder">Nothing to show</p>'
|
20
|
+
def placeholder(label = nil, tag: :p)
|
21
|
+
content_tag(tag, placeholder_text(label), class: 'placeholder')
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def placeholder_text(label)
|
27
|
+
case label
|
28
|
+
when Symbol
|
29
|
+
defaults = [
|
30
|
+
:"placeholders.defaults.#{label}",
|
31
|
+
:'placeholders.defaults.default'
|
32
|
+
]
|
33
|
+
translate(defaults.shift, default: defaults)
|
34
|
+
when nil
|
35
|
+
defaults = [
|
36
|
+
:"placeholders.#{controller_name}.#{action_name}",
|
37
|
+
:"placeholders.#{controller_name}.default",
|
38
|
+
:"placeholders.defaults.#{action_name}"
|
39
|
+
]
|
40
|
+
translate defaults.shift, default: defaults
|
41
|
+
else
|
42
|
+
label.to_s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -15,10 +15,10 @@ module Stationed
|
|
15
15
|
copy_file 'devise.rb', 'spec/support/devise.rb' if options[:rspec]
|
16
16
|
route "devise_scope :user do\n root to: 'devise/sessions#new'\n end\n"
|
17
17
|
environment nil, env: :test do
|
18
|
-
"config.action_mailer.default_url_options = { host: 'example.com' }"
|
18
|
+
"# Set default url options for Devise mailers\n config.action_mailer.default_url_options = { host: 'example.com' }\n"
|
19
19
|
end
|
20
20
|
environment nil, env: :development do
|
21
|
-
"config.action_mailer.default_url_options = { host: 'localhost:3000' }"
|
21
|
+
"# Set default url options for Devise mailers\n config.action_mailer.default_url_options = { host: 'localhost:3000' }\n"
|
22
22
|
end
|
23
23
|
super
|
24
24
|
end
|
@@ -13,6 +13,8 @@ module Stationed
|
|
13
13
|
return super unless options[:i18n_spec]
|
14
14
|
gem 'i18n-spec', group: :test
|
15
15
|
copy_file 'i18n_spec.rb', 'spec/locales/i18n_spec.rb'
|
16
|
+
uncomment_lines 'config/environments/development.rb', /raise_on_missing_translations/
|
17
|
+
uncomment_lines 'config/environments/test.rb', /raise_on_missing_translations/
|
16
18
|
super
|
17
19
|
end
|
18
20
|
end
|
@@ -14,8 +14,8 @@ module Stationed
|
|
14
14
|
environment nil, env: :development do
|
15
15
|
<<-RUBY
|
16
16
|
# Raise an ActionController::UnpermittedParameters exception when
|
17
|
-
# a parameter is not explcitly permitted but is passed anyway.
|
18
|
-
config.action_controller.action_on_unpermitted_parameters = :raise
|
17
|
+
# a parameter is not explcitly permitted but is passed anyway.
|
18
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
19
19
|
RUBY
|
20
20
|
end
|
21
21
|
super
|
data/lib/stationed/version.rb
CHANGED
data/spec/dummy/log/test.log
CHANGED
@@ -1472,3 +1472,109 @@
|
|
1472
1472
|
[1m[35m (0.0ms)[0m rollback transaction
|
1473
1473
|
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1474
1474
|
[1m[35m (0.0ms)[0m rollback transaction
|
1475
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
1476
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1477
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1478
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1479
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1480
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1481
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1482
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1483
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1484
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1485
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1486
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1487
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1488
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1489
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1490
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1491
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1492
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1493
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1494
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1495
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1496
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1497
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1498
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1499
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1500
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1501
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1502
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1503
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1504
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1505
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1506
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1507
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1508
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1509
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1510
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1511
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1512
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1513
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1514
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1515
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1516
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1517
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1518
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1519
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1520
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1521
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1522
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1523
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1524
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1525
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1526
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1527
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1528
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1529
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1530
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1531
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1532
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1533
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1534
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1535
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1536
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1537
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1538
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1539
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1540
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1541
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1542
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1543
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1544
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1545
|
+
[1m[36m (0.3ms)[0m [1mbegin transaction[0m
|
1546
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1547
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1548
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1549
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1550
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1551
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1552
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1553
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1554
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1555
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1556
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1557
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1558
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1559
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1560
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1561
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1562
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1563
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1564
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1565
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1566
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1567
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1568
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1569
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1570
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1571
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1572
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1573
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1574
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1575
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1576
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1577
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1578
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1579
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
1580
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PlaceholderHelper do
|
4
|
+
before do
|
5
|
+
allow(helper).to receive(:controller_name).and_return('products')
|
6
|
+
allow(helper).to receive(:action_name).and_return('index')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'fetches default key by controller action first' do
|
10
|
+
I18n.backend.store_translations :en, placeholders: { products: { index: 'Nothing found' } }
|
11
|
+
expect(helper.placeholder).to eql('<p class="placeholder">Nothing found</p>')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'fetches default key by controller second' do
|
15
|
+
I18n.backend.store_translations :en, placeholders: { products: { default: 'Nothing found' } }
|
16
|
+
expect(helper.placeholder).to eql('<p class="placeholder">Nothing found</p>')
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'fetches default key by action third' do
|
20
|
+
I18n.backend.store_translations :en, placeholders: { defaults: { index: 'Nothing found' } }
|
21
|
+
expect(helper.placeholder).to eql('<p class="placeholder">Nothing found</p>')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'fetches custom default key' do
|
25
|
+
I18n.backend.store_translations :en, placeholders: { defaults: { foo: 'Nothing found' } }
|
26
|
+
expect(helper.placeholder(:foo)).to eql('<p class="placeholder">Nothing found</p>')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'uses plain string' do
|
30
|
+
expect(helper.placeholder('Nothing found')).to eql('<p class="placeholder">Nothing found</p>')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'allows using a custom tag' do
|
34
|
+
expect(helper.placeholder('Nothing found', tag: :span)).to eql('<span class="placeholder">Nothing found</span>')
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stationed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arjan van der Gaag
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- Rakefile
|
71
71
|
- app/helpers/crud_link_helper.rb
|
72
72
|
- app/helpers/page_title_helper.rb
|
73
|
+
- app/helpers/placeholder_helper.rb
|
73
74
|
- lib/generators/stationed/templates_generator.rb
|
74
75
|
- lib/stationed.rb
|
75
76
|
- lib/stationed/app_builder.rb
|
@@ -143,6 +144,7 @@ files:
|
|
143
144
|
- lib/stationed/generators/templates/spring.rb
|
144
145
|
- lib/stationed/generators/templates/static_input.rb
|
145
146
|
- lib/stationed/generators/templates/webmock.rb
|
147
|
+
- lib/stationed/generators/templates/yard.rake
|
146
148
|
- lib/stationed/generators/templates/yardopts
|
147
149
|
- lib/stationed/version.rb
|
148
150
|
- lib/tasks/stationed_tasks.rake
|
@@ -196,6 +198,7 @@ files:
|
|
196
198
|
- spec/dummy/public/favicon.ico
|
197
199
|
- spec/helpers/crud_link_helper_spec.rb
|
198
200
|
- spec/helpers/page_title_helper_spec.rb
|
201
|
+
- spec/helpers/placeholder_helper_spec.rb
|
199
202
|
- spec/spec_helper.rb
|
200
203
|
homepage: http://avdgaag.github.io/stationed
|
201
204
|
licenses: []
|
@@ -257,4 +260,5 @@ test_files:
|
|
257
260
|
- spec/dummy/README.rdoc
|
258
261
|
- spec/helpers/crud_link_helper_spec.rb
|
259
262
|
- spec/helpers/page_title_helper_spec.rb
|
263
|
+
- spec/helpers/placeholder_helper_spec.rb
|
260
264
|
- spec/spec_helper.rb
|