algoliasearch-jekyll 0.9.1 → 1.0.0.beta.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -4
  3. data/CONTRIBUTING.md +8 -1
  4. data/Gemfile +4 -5
  5. data/README.md +318 -11
  6. data/Rakefile +7 -12
  7. data/algoliasearch-jekyll.gemspec +66 -62
  8. data/gemfiles/jekyll_v2.gemfile +3 -3
  9. data/gemfiles/jekyll_v3.gemfile +4 -4
  10. data/gemfiles/jekyll_v3_1_3.gemfile +24 -0
  11. data/gemfiles/jekyll_v3_1_6.gemfile +24 -0
  12. data/lib/algoliasearch-jekyll.rb +1 -3
  13. data/lib/credential_checker.rb +2 -1
  14. data/lib/error_handler.rb +6 -0
  15. data/lib/push.rb +81 -19
  16. data/lib/record_extractor.rb +120 -140
  17. data/lib/utils.rb +13 -0
  18. data/lib/version.rb +1 -1
  19. data/scripts/release +13 -12
  20. data/scripts/test_v3 +1 -1
  21. data/scripts/watch +4 -0
  22. data/spec/error_handler_spec.rb +17 -0
  23. data/spec/fixtures/jekyll_version_2/404.html +8 -0
  24. data/spec/fixtures/jekyll_version_2/404.md +9 -0
  25. data/spec/fixtures/jekyll_version_2/_my-collection/collection-item.md +3 -0
  26. data/spec/fixtures/jekyll_version_2/_posts/2015-07-02-test-post.md +1 -1
  27. data/spec/fixtures/jekyll_version_2/about.md +3 -0
  28. data/spec/fixtures/jekyll_version_2/front_matter.md +15 -0
  29. data/spec/fixtures/jekyll_version_2/index.html +3 -1
  30. data/spec/fixtures/jekyll_version_2/only-divs.md +15 -0
  31. data/spec/fixtures/jekyll_version_2/only-paragraphs.md +15 -0
  32. data/spec/fixtures/jekyll_version_3/404.html +8 -0
  33. data/spec/fixtures/jekyll_version_3/404.md +9 -0
  34. data/spec/fixtures/jekyll_version_3/_config.yml +1 -1
  35. data/spec/fixtures/jekyll_version_3/_my-collection/collection-item.md +3 -0
  36. data/spec/fixtures/jekyll_version_3/_posts/2015-07-02-test-post.md +1 -1
  37. data/spec/fixtures/jekyll_version_3/about.md +3 -0
  38. data/spec/fixtures/jekyll_version_3/front_matter.md +15 -0
  39. data/spec/fixtures/jekyll_version_3/index.html +4 -1
  40. data/spec/fixtures/jekyll_version_3/only-divs.md +15 -0
  41. data/spec/fixtures/jekyll_version_3/only-paragraphs.md +15 -0
  42. data/spec/push_spec.rb +211 -8
  43. data/spec/record_extractor_spec.rb +296 -358
  44. data/spec/spec_helper.rb +32 -11
  45. data/txt/record_too_big +19 -0
  46. metadata +40 -51
  47. data/scripts/watch +0 -1
@@ -7,6 +7,7 @@ require 'awesome_print'
7
7
  require 'jekyll'
8
8
  require_relative './spec_helper_simplecov.rb'
9
9
  require './lib/push.rb'
10
+ require './lib/utils.rb'
10
11
 
11
12
  RSpec.configure do |config|
12
13
  config.filter_run(focus: true)
@@ -14,9 +15,6 @@ RSpec.configure do |config|
14
15
  config.run_all_when_everything_filtered = true
15
16
  end
16
17
 
17
- # Disabling the logs
18
- Jekyll.logger.log_level = :error
19
-
20
18
  # Create a Jekyll::Site instance, patched with a `file_by_name` method
21
19
  def get_site(config = {}, options = {})
22
20
  default_options = {
@@ -34,9 +32,24 @@ def get_site(config = {}, options = {})
34
32
  .jekyll_new(config)
35
33
 
36
34
  def site.file_by_name(file_name)
35
+ files = {}
36
+
37
+ # We get the list of all classic files
37
38
  each_site_file do |file|
38
- return file if file.path =~ /#{file_name}$/
39
+ files[file.path] = file
40
+ end
41
+
42
+ # If we have an exact match, we use that one:
43
+ return files[file_name] if files.key?(file_name)
44
+
45
+ # Otherwise we try to find a key that is loosely matching
46
+ keys = files.keys
47
+ values = files.values
48
+
49
+ keys.each_with_index do |key, index|
50
+ return values[index] if key =~ /#{file_name}$/
39
51
  end
52
+
40
53
  nil
41
54
  end
42
55
 
@@ -46,6 +59,17 @@ def get_site(config = {}, options = {})
46
59
  site
47
60
  end
48
61
 
62
+ def mock_logger
63
+ # Spying on default logging method while still calling them
64
+ allow(Jekyll.logger).to receive(:info).and_wrap_original do |method, *args|
65
+ # Hiding the basic "Configuration file" display
66
+ next if args[0] == 'Configuration file:'
67
+ method.call(*args)
68
+ end
69
+ allow(Jekyll.logger).to receive(:warn).and_call_original
70
+ allow(Jekyll.logger).to receive(:error).and_call_original
71
+ end
72
+
49
73
  # Return the fixture path, according to the current Jekyll version being tested
50
74
  def fixture_path
51
75
  jekyll_version = Jekyll::VERSION[0]
@@ -55,11 +79,8 @@ end
55
79
 
56
80
  # Check the current Jekyll version
57
81
  def restrict_jekyll_version(more_than: nil, less_than: nil)
58
- jekyll_version = Gem::Version.new(Jekyll::VERSION)
59
- minimum_version = Gem::Version.new(more_than)
60
- maximum_version = Gem::Version.new(less_than)
61
-
62
- return false if !more_than.nil? && jekyll_version < minimum_version
63
- return false if !less_than.nil? && jekyll_version > maximum_version
64
- true
82
+ AlgoliaSearchUtils.restrict_jekyll_version(
83
+ more_than: more_than,
84
+ less_than: less_than
85
+ )
65
86
  end
@@ -0,0 +1,19 @@
1
+ Algolia Error: Record too big
2
+ Records pushed to Algolia have a max possible size of 10KB. Records above this
3
+ limit will be rejected.
4
+
5
+ You see this error because at least one of the records the plugin is trying to
6
+ push is above this limit.
7
+
8
+ The plugin creates a record for each `<p>` paragraph of text found in your
9
+ pages. If one of them contains a huge chunk of text it may trigger this error.
10
+
11
+ You can configure the CSS selector used to create records through the
12
+ `record_css_selector` option. The default is `p` (meaning all `<p>`
13
+ paragraphs). You can update this value to use a negation selector to exclude
14
+ some parts.
15
+
16
+ For example `p:not(.do-not-index)` will only index paragraphs that do not have
17
+ the class `do-not-index`.
18
+
19
+ See https://github.com/algolia/algoliasearch-jekyll for more information
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 1.0.0.beta.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Carry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: algoliasearch
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,64 +56,58 @@ dependencies:
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.8.6
61
+ version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.6
68
+ version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 1.7.2
76
73
  - - "~>"
77
74
  - !ruby/object:Gem::Version
78
- version: '1.7'
75
+ version: '1.6'
79
76
  type: :runtime
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: 1.7.2
86
80
  - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '1.7'
82
+ version: '1.6'
89
83
  - !ruby/object:Gem::Dependency
90
- name: verbal_expressions
84
+ name: html-hierarchy-extractor
91
85
  requirement: !ruby/object:Gem::Requirement
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: 0.1.5
89
+ version: '1.0'
96
90
  type: :runtime
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: 0.1.5
96
+ version: '1.0'
103
97
  - !ruby/object:Gem::Dependency
104
- name: rake
98
+ name: verbal_expressions
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - "<"
101
+ - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: '11.0'
110
- type: :development
103
+ version: 0.1.5
104
+ type: :runtime
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
- - - "<"
108
+ - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: '11.0'
110
+ version: 0.1.5
117
111
  - !ruby/object:Gem::Dependency
118
112
  name: coveralls
119
113
  requirement: !ruby/object:Gem::Requirement
@@ -226,21 +220,8 @@ dependencies:
226
220
  - - "~>"
227
221
  - !ruby/object:Gem::Version
228
222
  version: '0.10'
229
- - !ruby/object:Gem::Dependency
230
- name: rack
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - "<"
234
- - !ruby/object:Gem::Version
235
- version: '2'
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - "<"
241
- - !ruby/object:Gem::Version
242
- version: '2'
243
- description: "[⚠ DEPRECATED ⚠]: Use jekyll-algolia instead"
223
+ description: Index all your pages and posts to an Algolia index with `jekyll algolia
224
+ push`
244
225
  email: tim@pixelastic.com
245
226
  executables: []
246
227
  extensions: []
@@ -264,11 +245,14 @@ files:
264
245
  - docs/travis-settings.png
265
246
  - gemfiles/jekyll_v2.gemfile
266
247
  - gemfiles/jekyll_v3.gemfile
248
+ - gemfiles/jekyll_v3_1_3.gemfile
249
+ - gemfiles/jekyll_v3_1_6.gemfile
267
250
  - lib/algoliasearch-jekyll.rb
268
251
  - lib/credential_checker.rb
269
252
  - lib/error_handler.rb
270
253
  - lib/push.rb
271
254
  - lib/record_extractor.rb
255
+ - lib/utils.rb
272
256
  - lib/version.rb
273
257
  - scripts/bump_version
274
258
  - scripts/check_flay
@@ -287,6 +271,8 @@ files:
287
271
  - scripts/watch_v3
288
272
  - spec/credential_checker_spec.rb
289
273
  - spec/error_handler_spec.rb
274
+ - spec/fixtures/jekyll_version_2/404.html
275
+ - spec/fixtures/jekyll_version_2/404.md
290
276
  - spec/fixtures/jekyll_version_2/_config.yml
291
277
  - spec/fixtures/jekyll_version_2/_layouts/default.html
292
278
  - spec/fixtures/jekyll_version_2/_my-collection/collection-item.html
@@ -298,10 +284,15 @@ files:
298
284
  - spec/fixtures/jekyll_version_2/assets/ring.png
299
285
  - spec/fixtures/jekyll_version_2/authors.html
300
286
  - spec/fixtures/jekyll_version_2/excluded.html
287
+ - spec/fixtures/jekyll_version_2/front_matter.md
301
288
  - spec/fixtures/jekyll_version_2/hierarchy.md
302
289
  - spec/fixtures/jekyll_version_2/index.html
290
+ - spec/fixtures/jekyll_version_2/only-divs.md
291
+ - spec/fixtures/jekyll_version_2/only-paragraphs.md
303
292
  - spec/fixtures/jekyll_version_2/page2/index.html
304
293
  - spec/fixtures/jekyll_version_2/weight.md
294
+ - spec/fixtures/jekyll_version_3/404.html
295
+ - spec/fixtures/jekyll_version_3/404.md
305
296
  - spec/fixtures/jekyll_version_3/_config.yml
306
297
  - spec/fixtures/jekyll_version_3/_layouts/default.html
307
298
  - spec/fixtures/jekyll_version_3/_my-collection/collection-item.html
@@ -313,8 +304,11 @@ files:
313
304
  - spec/fixtures/jekyll_version_3/assets/ring.png
314
305
  - spec/fixtures/jekyll_version_3/authors.html
315
306
  - spec/fixtures/jekyll_version_3/excluded.html
307
+ - spec/fixtures/jekyll_version_3/front_matter.md
316
308
  - spec/fixtures/jekyll_version_3/hierarchy.md
317
309
  - spec/fixtures/jekyll_version_3/index.html
310
+ - spec/fixtures/jekyll_version_3/only-divs.md
311
+ - spec/fixtures/jekyll_version_3/only-paragraphs.md
318
312
  - spec/fixtures/jekyll_version_3/page2/index.html
319
313
  - spec/fixtures/jekyll_version_3/weight.md
320
314
  - spec/push_spec.rb
@@ -325,18 +319,13 @@ files:
325
319
  - txt/application_id_missing
326
320
  - txt/check_key_acl_to_tmp_index
327
321
  - txt/index_name_missing
322
+ - txt/record_too_big
328
323
  - txt/sample
329
324
  homepage: https://github.com/algolia/algoliasearch-jekyll
330
325
  licenses:
331
326
  - MIT
332
327
  metadata: {}
333
- post_install_message: |2
334
- ! The 'algolisearch-jekyll' gem has been deprecated and has been replaced with 'jekyll-algolia'.
335
- ! See: https://rubygems.org/gems/jekyll-algolia
336
- ! And: https://github.com/algolia/jekyll-algolia
337
- !
338
- ! You can get quickly started on the new plugin using this documentation:
339
- ! https://community.algolia.com/jekyll-algolia/getting-started.html
328
+ post_install_message:
340
329
  rdoc_options: []
341
330
  require_paths:
342
331
  - lib
@@ -347,13 +336,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
347
336
  version: '0'
348
337
  required_rubygems_version: !ruby/object:Gem::Requirement
349
338
  requirements:
350
- - - ">="
339
+ - - ">"
351
340
  - !ruby/object:Gem::Version
352
- version: '0'
341
+ version: 1.3.1
353
342
  requirements: []
354
343
  rubyforge_project:
355
- rubygems_version: 2.6.13
344
+ rubygems_version: 2.4.8
356
345
  signing_key:
357
346
  specification_version: 4
358
- summary: "[⚠ DEPRECATED ⚠]: Use jekyll-algolia instead"
347
+ summary: AlgoliaSearch for Jekyll
359
348
  test_files: []
@@ -1 +0,0 @@
1
- scripts/./watch_v2