redis_snippets 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6e23e82090d87175ad955c952631f69c82c81f8a44bb31425e0d8fd23cd3efb
4
- data.tar.gz: 7a10f98d066f22d13fc396738f5caacf784864f0ecd27bc64768c7b3e5c31592
3
+ metadata.gz: 3405ef95f6f26120727377063f3b52e93cda1b0078263ba3e644a12bb4d5023e
4
+ data.tar.gz: bb5d7a0d7dac1c9321341fcccf43d85197f0ea88805b56c85289fa053be5f68d
5
5
  SHA512:
6
- metadata.gz: e07f026b183cad598364729618af9fe667e3edadbf3797897d2f19adf05738f3e74373c342085230ec28fa549d892d0a54010779ff86e2c8a8861fadc84444d7
7
- data.tar.gz: 90c0e1f7b2245e79afdb0acf63e7937455651177c547805eec6f578bec1c8791958f6f3d61a96ff806798074148c349ee622016285283925a1bb8bdf9eca38b4
6
+ metadata.gz: 1cf9e220895fe0b244711359c5ab36c6bee78a01ceec234acd028aeed65d1ef69242f9fdc29a9db99c7a86157b8099ffd7739db5b8a386dabbc86ca8621b2668
7
+ data.tar.gz: 5bca61d402c6ce30cfa5cfa32717740108b898c9e18ae2f1f703d9f5d8f4c5c56f3158f5d5b9895732f14750509f93b84b49eb3b2ce3a42bb76b58dedf5fa189
@@ -0,0 +1,46 @@
1
+ name: Ruby
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+
9
+ strategy:
10
+ matrix:
11
+ ruby-version: ['2.7', '3.1', '3.2']
12
+
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - name: Set up Ruby ${{ matrix.ruby-version }}
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+ bundler-cache: true
21
+
22
+ - name: Install dependencies
23
+ run: bundle install --no-cache
24
+
25
+ - name: Run tests
26
+ run: bundle exec rspec
27
+
28
+ - uses: joshmfrankel/simplecov-check-action@main
29
+ with:
30
+ minimum_suite_coverage: 85
31
+ minimum_file_coverage: 70
32
+ github_token: ${{ secrets.GITHUB_TOKEN }}
33
+
34
+ - name: Workaround for coverage report to CodeClimate with jq
35
+ if: startsWith(matrix.ruby-version, '3')
36
+ run: |
37
+ jq 'map_values(. | map_values(if type=="object" then map_values(.lines) else . end))' coverage/.resultset.json > coverage/.resultset_workaround.json
38
+ diff -uw coverage/.resultset.json coverage/.resultset_workaround.json || true
39
+ - name: Send coverage report to CodeClimate
40
+ if: startsWith(matrix.ruby-version, '3')
41
+ continue-on-error: true
42
+ uses: paambaati/codeclimate-action@v3.0.0
43
+ with:
44
+ coverageLocations: ${{ github.workspace }}/coverage/.resultset_workaround.json:simplecov
45
+ env:
46
+ CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
data/.gitignore CHANGED
@@ -1,5 +1,4 @@
1
1
  .bundle
2
+ coverage
2
3
  pkg
3
4
  spec/dummy/log
4
- Gemfile.lock
5
- coverage
data/Gemfile.lock ADDED
@@ -0,0 +1,202 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ redis_snippets (1.0.5)
5
+ rails (>= 5)
6
+ redis (>= 2.0.0)
7
+ redis-namespace (>= 1.2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (6.1.7.2)
13
+ actionpack (= 6.1.7.2)
14
+ activesupport (= 6.1.7.2)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (6.1.7.2)
18
+ actionpack (= 6.1.7.2)
19
+ activejob (= 6.1.7.2)
20
+ activerecord (= 6.1.7.2)
21
+ activestorage (= 6.1.7.2)
22
+ activesupport (= 6.1.7.2)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.1.7.2)
25
+ actionpack (= 6.1.7.2)
26
+ actionview (= 6.1.7.2)
27
+ activejob (= 6.1.7.2)
28
+ activesupport (= 6.1.7.2)
29
+ mail (~> 2.5, >= 2.5.4)
30
+ rails-dom-testing (~> 2.0)
31
+ actionpack (6.1.7.2)
32
+ actionview (= 6.1.7.2)
33
+ activesupport (= 6.1.7.2)
34
+ rack (~> 2.0, >= 2.0.9)
35
+ rack-test (>= 0.6.3)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
+ actiontext (6.1.7.2)
39
+ actionpack (= 6.1.7.2)
40
+ activerecord (= 6.1.7.2)
41
+ activestorage (= 6.1.7.2)
42
+ activesupport (= 6.1.7.2)
43
+ nokogiri (>= 1.8.5)
44
+ actionview (6.1.7.2)
45
+ activesupport (= 6.1.7.2)
46
+ builder (~> 3.1)
47
+ erubi (~> 1.4)
48
+ rails-dom-testing (~> 2.0)
49
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
50
+ activejob (6.1.7.2)
51
+ activesupport (= 6.1.7.2)
52
+ globalid (>= 0.3.6)
53
+ activemodel (6.1.7.2)
54
+ activesupport (= 6.1.7.2)
55
+ activerecord (6.1.7.2)
56
+ activemodel (= 6.1.7.2)
57
+ activesupport (= 6.1.7.2)
58
+ activestorage (6.1.7.2)
59
+ actionpack (= 6.1.7.2)
60
+ activejob (= 6.1.7.2)
61
+ activerecord (= 6.1.7.2)
62
+ activesupport (= 6.1.7.2)
63
+ marcel (~> 1.0)
64
+ mini_mime (>= 1.1.0)
65
+ activesupport (6.1.7.2)
66
+ concurrent-ruby (~> 1.0, >= 1.0.2)
67
+ i18n (>= 1.6, < 2)
68
+ minitest (>= 5.1)
69
+ tzinfo (~> 2.0)
70
+ zeitwerk (~> 2.3)
71
+ builder (3.2.4)
72
+ concurrent-ruby (1.2.2)
73
+ connection_pool (2.3.0)
74
+ crass (1.0.6)
75
+ date (3.3.3)
76
+ diff-lcs (1.5.0)
77
+ docile (1.4.0)
78
+ erubi (1.12.0)
79
+ globalid (1.1.0)
80
+ activesupport (>= 5.0)
81
+ i18n (1.12.0)
82
+ concurrent-ruby (~> 1.0)
83
+ loofah (2.19.1)
84
+ crass (~> 1.0.2)
85
+ nokogiri (>= 1.5.9)
86
+ mail (2.8.1)
87
+ mini_mime (>= 0.1.1)
88
+ net-imap
89
+ net-pop
90
+ net-smtp
91
+ marcel (1.0.2)
92
+ method_source (1.0.0)
93
+ mini_mime (1.1.2)
94
+ minitest (5.18.0)
95
+ mock_redis (0.36.0)
96
+ ruby2_keywords
97
+ net-imap (0.3.4)
98
+ date
99
+ net-protocol
100
+ net-pop (0.1.2)
101
+ net-protocol
102
+ net-protocol (0.2.1)
103
+ timeout
104
+ net-smtp (0.3.3)
105
+ net-protocol
106
+ nio4r (2.5.8)
107
+ nokogiri (1.14.2-arm64-darwin)
108
+ racc (~> 1.4)
109
+ nokogiri (1.14.2-x86_64-linux)
110
+ racc (~> 1.4)
111
+ racc (1.6.2)
112
+ rack (2.2.6.3)
113
+ rack-test (2.0.2)
114
+ rack (>= 1.3)
115
+ rails (6.1.7.2)
116
+ actioncable (= 6.1.7.2)
117
+ actionmailbox (= 6.1.7.2)
118
+ actionmailer (= 6.1.7.2)
119
+ actionpack (= 6.1.7.2)
120
+ actiontext (= 6.1.7.2)
121
+ actionview (= 6.1.7.2)
122
+ activejob (= 6.1.7.2)
123
+ activemodel (= 6.1.7.2)
124
+ activerecord (= 6.1.7.2)
125
+ activestorage (= 6.1.7.2)
126
+ activesupport (= 6.1.7.2)
127
+ bundler (>= 1.15.0)
128
+ railties (= 6.1.7.2)
129
+ sprockets-rails (>= 2.0.0)
130
+ rails-dom-testing (2.0.3)
131
+ activesupport (>= 4.2.0)
132
+ nokogiri (>= 1.6)
133
+ rails-html-sanitizer (1.5.0)
134
+ loofah (~> 2.19, >= 2.19.1)
135
+ railties (6.1.7.2)
136
+ actionpack (= 6.1.7.2)
137
+ activesupport (= 6.1.7.2)
138
+ method_source
139
+ rake (>= 12.2)
140
+ thor (~> 1.0)
141
+ rake (13.0.6)
142
+ redis (5.0.6)
143
+ redis-client (>= 0.9.0)
144
+ redis-client (0.14.0)
145
+ connection_pool
146
+ redis-namespace (1.10.0)
147
+ redis (>= 4)
148
+ rspec-core (3.12.1)
149
+ rspec-support (~> 3.12.0)
150
+ rspec-expectations (3.12.2)
151
+ diff-lcs (>= 1.2.0, < 2.0)
152
+ rspec-support (~> 3.12.0)
153
+ rspec-mocks (3.12.3)
154
+ diff-lcs (>= 1.2.0, < 2.0)
155
+ rspec-support (~> 3.12.0)
156
+ rspec-rails (6.0.1)
157
+ actionpack (>= 6.1)
158
+ activesupport (>= 6.1)
159
+ railties (>= 6.1)
160
+ rspec-core (~> 3.11)
161
+ rspec-expectations (~> 3.11)
162
+ rspec-mocks (~> 3.11)
163
+ rspec-support (~> 3.11)
164
+ rspec-support (3.12.0)
165
+ ruby2_keywords (0.0.5)
166
+ simplecov (0.22.0)
167
+ docile (~> 1.1)
168
+ simplecov-html (~> 0.11)
169
+ simplecov_json_formatter (~> 0.1)
170
+ simplecov-html (0.12.3)
171
+ simplecov_json_formatter (0.1.4)
172
+ sprockets (4.2.0)
173
+ concurrent-ruby (~> 1.0)
174
+ rack (>= 2.2.4, < 4)
175
+ sprockets-rails (3.4.2)
176
+ actionpack (>= 5.2)
177
+ activesupport (>= 5.2)
178
+ sprockets (>= 3.0.0)
179
+ thor (1.2.1)
180
+ timeout (0.3.2)
181
+ tzinfo (2.0.6)
182
+ concurrent-ruby (~> 1.0)
183
+ websocket-driver (0.7.5)
184
+ websocket-extensions (>= 0.1.0)
185
+ websocket-extensions (0.1.5)
186
+ zeitwerk (2.6.7)
187
+
188
+ PLATFORMS
189
+ arm64-darwin-21
190
+ x86_64-linux
191
+
192
+ DEPENDENCIES
193
+ bundler (>= 1.3.2)
194
+ mock_redis
195
+ rails (~> 6)
196
+ rake
197
+ redis_snippets!
198
+ rspec-rails (>= 3.9.0)
199
+ simplecov
200
+
201
+ BUNDLED WITH
202
+ 2.3.7
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Redis Snippets
2
2
 
3
3
  [![Version](https://img.shields.io/gem/v/redis_snippets.svg?style=flat-square)](https://rubygems.org/gems/redis_snippets)
4
- [![Build](https://img.shields.io/travis/wulffeld/redis_snippets.svg?style=flat-square)](https://travis-ci.org/wulffeld/redis_snippets)
4
+ [![Ruby](https://github.com/wulffeld/redis_snippets/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/wulffeld/redis_snippets/actions/workflows/ci.yml)
5
5
  [![Maintainability](https://img.shields.io/codeclimate/maintainability/wulffeld/redis_snippets?style=flat-square)](https://codeclimate.com/github/wulffeld/redis_snippets)
6
6
  [![Coverage](https://img.shields.io/codeclimate/coverage/wulffeld/redis_snippets?style=flat-square)](https://codeclimate.com/github/wulffeld/redis_snippets)
7
7
 
@@ -15,6 +15,8 @@ class SnippetFinderService
15
15
 
16
16
  class << self
17
17
  def random_snippet(content)
18
+ return "" if content.blank?
19
+
18
20
  snippets = content.split("#{SECTION_DELIMITER}").map { |section| section.gsub(/^\n/, "") }
19
21
  snippets[rand(snippets.length)]
20
22
  end
@@ -1,3 +1,3 @@
1
1
  module RedisSnippets
2
- VERSION = '1.0.4'
2
+ VERSION = "1.0.5"
3
3
  end
@@ -23,13 +23,20 @@ HEREDOC
23
23
  end
24
24
 
25
25
  describe ".random_snippet" do
26
- before do
27
- SnippetStoreService.update(snippet_key(:advert_header), multiple_adverts)
26
+ context "with multiple sections" do
27
+ before do
28
+ SnippetStoreService.update(snippet_key(:advert_header), multiple_adverts)
29
+ end
30
+
31
+ it "returns one of the sections" do
32
+ expect(described_class).to receive(:rand).and_return(0)
33
+ expect(described_class.random_snippet(multiple_adverts)).to eq("<p>Buy this from Amazon.</p>\n")
34
+ end
28
35
  end
29
36
 
30
- it "returns one of the sections" do
31
- expect(described_class).to receive(:rand).and_return(0)
32
- expect(described_class.random_snippet(multiple_adverts)).to eq("<p>Buy this from Amazon.</p>\n")
37
+ it "returns a blank string" do
38
+ expect(described_class).to_not receive(:rand)
39
+ expect(described_class.random_snippet(nil)).to eq("")
33
40
  end
34
41
  end
35
42
  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: 1.0.4
4
+ version: 1.0.5
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: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -88,10 +88,11 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - ".github/workflows/ci.yml"
91
92
  - ".gitignore"
92
93
  - ".rspec"
93
- - ".travis.yml"
94
94
  - Gemfile
95
+ - Gemfile.lock
95
96
  - README.md
96
97
  - Rakefile
97
98
  - app/controllers/redis_snippets/snippets_controller.rb
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- env:
5
- global:
6
- - CC_TEST_REPORTER_ID=aa59e066b7cd7b5477aecc5c17004d78d35012420e791d23b17c0ea705ef9cd7
7
- before_script:
8
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
9
- - chmod +x ./cc-test-reporter
10
- - ./cc-test-reporter before-build
11
- before_install:
12
- - gem update --system
13
- - gem install bundler --version 2.0.2
14
- rvm:
15
- - 2.6.5
16
- script:
17
- - bundle exec rake
18
- after_script:
19
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT