redis_snippets 0.0.9 → 0.0.10

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: 828a9af08bdf93a90cd07c222c0f5e28ec271a0f
4
- data.tar.gz: a59a833e4b6a24c88070d84038f3b359e483966f
3
+ metadata.gz: d57ab380b6653a5a2bbadfd96bcb3f5c2b1033b0
4
+ data.tar.gz: c6ef4474551730d558e675fa49fde37e5f20219a
5
5
  SHA512:
6
- metadata.gz: bcc378d2a2f4368cf32908e18ac95bdad834da51b64953dfb962169ec5dfb8a3b936ac5403cb12e39c73c9f03f6b874ce2e556d5d5824e561f284b6f2a34a316
7
- data.tar.gz: e3bc7fa38fefd99317cd82ba167015bc70087bb9e9bc0cfef53ab099ad1bed077b3c0923a2c3ab8973b7d8d72fbce0b48ee914a04b94f079a56e05b4340a66a3
6
+ metadata.gz: c81fa957b20f7e9d1b7cdf0164bae965e85cea2a51f6ad1c65d3ba6f17d24a4e0119cd8f5bd9889dbc9e54c12df67735cd43eac6ab2f84897837925bf90a000a
7
+ data.tar.gz: f5ed406436c21e5969129f901fcdea444f89f68b1dd10a17576a60798c7bab9790f542692e7b47823ff4487c49e272bd3614acb02ef5dae6da82a84832b385c0
data/README.md CHANGED
@@ -6,7 +6,7 @@ Easily store snippets of content in Redis.
6
6
 
7
7
  ## How
8
8
 
9
- It's a Rails 3 engine so add redis-snippets to your Gemfile and put this in an initializer:
9
+ It's a Rails engine so add redis-snippets to your Gemfile and put this in an initializer:
10
10
 
11
11
  ``` ruby
12
12
  App::Application.config.redis_snippets = {
@@ -23,6 +23,16 @@ In your views use helper snippet().
23
23
  <%= snippet(:key1) %>
24
24
  ```
25
25
 
26
+ ### Random snippets
27
+
28
+ One snippet area can include multiple snippets if you separate them with a
29
+
30
+ ```
31
+ [snippet]
32
+ ```
33
+
34
+ The snippet helper will randomly select the snippet. This is convenient for ad delivery for example.
35
+
26
36
  ## Multi Site
27
37
 
28
38
  If you're using one app to serve multiple sites a little more configuration is necessary.
@@ -5,17 +5,18 @@ module RedisSnippets
5
5
  def snippet_content(snippet_name)
6
6
  RedisSnippets::Snippets.send(snippet_key(snippet_name))
7
7
  end
8
-
8
+
9
9
  # Return true if snippet has content.
10
10
  def snippet_has_content?(snippet_name)
11
11
  !snippet_content(snippet_name).blank?
12
12
  end
13
-
13
+
14
14
  def snippet(snippet_name, classes=nil)
15
15
  return '' if controller.status == 404
16
- content = snippet_content(snippet_name)
17
- return '' if content.blank?
18
- build_snippet(content, snippet_class_list(snippet_name, classes))
16
+ snippet = snippet_content(snippet_name)
17
+ return '' if snippet.blank?
18
+ snippets = snippet.split("[section]")
19
+ build_snippet(snippets[rand(snippets.length)], snippet_class_list(snippet_name, classes))
19
20
  end
20
21
 
21
22
  def snippet_class_list(snippet_name, classes)
@@ -1,3 +1,3 @@
1
1
  module RedisSnippets
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_snippets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Moen Wulffeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-18 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.2.2
110
+ rubygems_version: 2.4.8
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Storing snippets of whatever in Redis.