content_pack_rails 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01e54acea70e4117e3b4aa0eeb0abdd77e6dda0d66f3aba6adb03a7eeb10436b
4
- data.tar.gz: 233bce3890613f9fd10988d2a3698d598fbba98cc973498a5d60098af2cac111
3
+ metadata.gz: 90c33ee64e4e7ea2421576a6823caea245440f67463e81dc48659623b7750b44
4
+ data.tar.gz: 0dc6cc0eb064a649dd7202126d84e4bef39e15205846d85d146cf172d266d372
5
5
  SHA512:
6
- metadata.gz: 779ecc0ac8004761f8fee1022081521d2739be5c59c6c718c2d312d9ec3c86b2665a159b3ec7eff67f23a78a160d2574fa174138fa9ae436394f7cd4220374de
7
- data.tar.gz: 4ba805bbcd91730f6df4061f1555043db1c4afae8a007063774608bfbea324337936fd2982bb5e914f9eb9ccd203d602a037c8fc67a953f56fd482ee903b2b17
6
+ metadata.gz: 41e944509a627bc355d91b88e2051171103a5e28cf762397041c513586595a1cd891d9d683e7a23b65b7f9a8822bd146b65d6ba33779dec869e0c1b39bfb55a2
7
+ data.tar.gz: cf9b69b15b88bd77824141ebd481545008e53c44997f8061d7818b347572a992670d5f93c9800e8e7e3fcd4b68e192b89de1c23cb1db0febd11a515659854bc1
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2021-12-03)
4
+
5
+ ### Features
6
+
7
+ * ability to get content entry from pack
data/README.md CHANGED
@@ -23,7 +23,7 @@ module ApplicationHelper
23
23
  end
24
24
  ```
25
25
 
26
- By default, this will add two view helpers `content_pack` and `provide_content_pack`.
26
+ By default, this will add three view helpers `content_pack`, `provide_content_pack` and `content_pack_get`.
27
27
  To avoid collisions with a helper of the same name you might already have in your app, provide a different name:
28
28
 
29
29
  ```ruby
@@ -73,6 +73,11 @@ So later on, you can render the whole pack somewhere in your view, like this:
73
73
  <%= provide_content_pack %>
74
74
  ```
75
75
 
76
+ To access a single content entry from the pack, use `content_pack_get`:
77
+ ```erb
78
+ <%= content_pack_get('content-id') %>
79
+ ```
80
+
76
81
  Should you want to have multiple packs, for example, to group content, you can set up those by including this module as many times as needed with different names:
77
82
  ```ruby
78
83
  module ApplicationHelper
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.license = "MIT"
11
11
 
12
12
  spec.metadata["source_code_uri"] = spec.homepage
13
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
14
-
13
+ spec.metadata["changelog_uri"] = "https://github.com/a-bohush/content_pack_rails/blob/main/README.md"
14
+ spec.extra_rdoc_files = ['README.md']
15
15
  # Specify which files should be added to the gem when it is released.
16
16
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
17
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
@@ -1,3 +1,3 @@
1
1
  module ContentPackRails
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,9 +4,10 @@ module ContentPackRails
4
4
  def self.init(configs = { pack_name: 'content_pack' })
5
5
  Module.new do
6
6
  silent = proc { |&block| v = $VERBOSE; $VERBOSE = nil; res = block.call; $VERBOSE = v; res }
7
+ to_content_id = -> (id) { "_id_#{configs[:pack_name]}_#{id}".to_sym }
7
8
 
8
9
  define_method configs[:pack_name] do |id, content=nil, options={}, &block|
9
- _id = "_id_#{configs[:pack_name]}_#{id}".to_sym
10
+ _id = to_content_id.call(id)
10
11
  _block = proc { block.call(id) } if block
11
12
  options[:append] || options[:flush] || content_for?(_id) && return
12
13
  content_for(_id, content, options.slice(:flush), &_block)
@@ -15,11 +16,13 @@ module ContentPackRails
15
16
  end
16
17
 
17
18
  define_method "provide_#{configs[:pack_name]}" do
18
- content_for(configs[:pack_name], nil, flush: true)
19
- instance_variable_get(:"@_#{configs[:pack_name]}_ids").each do |id|
20
- content_for(configs[:pack_name]) { content_for(id) }
19
+ instance_variable_get(:"@_#{configs[:pack_name]}_ids").inject("") do |acc, id|
20
+ acc.concat(content_for(id))
21
21
  end
22
- content_for(configs[:pack_name])
22
+ end
23
+
24
+ define_method "#{configs[:pack_name]}_get" do |id|
25
+ content_for(to_content_id.call(id))
23
26
  end
24
27
  end
25
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_pack_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bohush
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-02 00:00:00.000000000 Z
11
+ date: 2021-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -49,9 +49,11 @@ email:
49
49
  - a.bohush01@gmail.com
50
50
  executables: []
51
51
  extensions: []
52
- extra_rdoc_files: []
52
+ extra_rdoc_files:
53
+ - README.md
53
54
  files:
54
55
  - ".gitignore"
56
+ - CHANGELOG.md
55
57
  - Gemfile
56
58
  - MIT-LICENSE
57
59
  - README.md
@@ -64,6 +66,7 @@ licenses:
64
66
  - MIT
65
67
  metadata:
66
68
  source_code_uri: https://github.com/a-bohush/content_pack_rails.git
69
+ changelog_uri: https://github.com/a-bohush/content_pack_rails/blob/main/README.md
67
70
  post_install_message:
68
71
  rdoc_options: []
69
72
  require_paths: