algoliasearch-jekyll 0.5.3 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -0
  3. data/Appraisals +8 -0
  4. data/CONTRIBUTING.md +15 -7
  5. data/Gemfile +1 -1
  6. data/Guardfile +14 -4
  7. data/README.md +1 -1
  8. data/algoliasearch-jekyll.gemspec +46 -33
  9. data/gemfiles/jekyll_v2.gemfile +21 -0
  10. data/gemfiles/jekyll_v3.gemfile +22 -0
  11. data/lib/record_extractor.rb +30 -12
  12. data/lib/version.rb +1 -1
  13. data/scripts/git_hooks/pre-push +1 -1
  14. data/scripts/test +4 -0
  15. data/scripts/test_ci +7 -0
  16. data/scripts/test_v2 +5 -0
  17. data/scripts/test_v3 +6 -0
  18. data/scripts/watch +4 -0
  19. data/scripts/watch_v2 +4 -0
  20. data/scripts/watch_v3 +4 -0
  21. data/spec/credential_checker_spec.rb +1 -1
  22. data/spec/fixtures/{_config.yml → jekyll_version_2/_config.yml} +4 -0
  23. data/spec/fixtures/{_layouts → jekyll_version_2/_layouts}/default.html +0 -0
  24. data/spec/fixtures/{_my-collection → jekyll_version_2/_my-collection}/collection-item.html +0 -0
  25. data/spec/fixtures/{_my-collection → jekyll_version_2/_my-collection}/collection-item.md +0 -0
  26. data/spec/fixtures/{_posts → jekyll_version_2/_posts}/2015-07-02-test-post.md +0 -0
  27. data/spec/fixtures/{_posts → jekyll_version_2/_posts}/2015-07-03-test-post-again.md +0 -0
  28. data/spec/fixtures/{about.md → jekyll_version_2/about.md} +0 -0
  29. data/spec/fixtures/{api_key_dir → jekyll_version_2/api_key_dir}/_algolia_api_key +0 -0
  30. data/spec/fixtures/{_site → jekyll_version_2}/assets/ring.png +0 -0
  31. data/spec/fixtures/{authors.html → jekyll_version_2/authors.html} +0 -0
  32. data/spec/fixtures/{excluded.html → jekyll_version_2/excluded.html} +0 -0
  33. data/spec/fixtures/{hierarchy.md → jekyll_version_2/hierarchy.md} +0 -0
  34. data/spec/fixtures/{index.html → jekyll_version_2/index.html} +0 -0
  35. data/spec/fixtures/{page2 → jekyll_version_2/page2}/index.html +0 -0
  36. data/spec/fixtures/{weight.md → jekyll_version_2/weight.md} +0 -0
  37. data/spec/fixtures/jekyll_version_3/_config.yml +17 -0
  38. data/spec/fixtures/jekyll_version_3/_layouts/default.html +6 -0
  39. data/spec/fixtures/{_site/my-collection → jekyll_version_3/_my-collection}/collection-item.html +5 -1
  40. data/spec/fixtures/jekyll_version_3/_my-collection/collection-item.md +7 -0
  41. data/spec/fixtures/jekyll_version_3/_posts/2015-07-02-test-post.md +32 -0
  42. data/spec/fixtures/jekyll_version_3/_posts/2015-07-03-test-post-again.md +7 -0
  43. data/spec/fixtures/jekyll_version_3/about.md +34 -0
  44. data/spec/fixtures/jekyll_version_3/api_key_dir/_algolia_api_key +1 -0
  45. data/spec/fixtures/{assets → jekyll_version_3/assets}/ring.png +0 -0
  46. data/spec/fixtures/{_site → jekyll_version_3}/authors.html +4 -0
  47. data/spec/fixtures/{_site → jekyll_version_3}/excluded.html +4 -0
  48. data/spec/fixtures/jekyll_version_3/hierarchy.md +35 -0
  49. data/spec/fixtures/jekyll_version_3/index.html +13 -0
  50. data/spec/fixtures/jekyll_version_3/page2/index.html +6 -0
  51. data/spec/fixtures/jekyll_version_3/weight.md +19 -0
  52. data/spec/record_extractor_spec.rb +131 -5
  53. data/spec/spec_helper.rb +47 -26
  54. metadata +56 -43
  55. data/spec/fixtures/_site/2015/07/02/test-post.html +0 -26
  56. data/spec/fixtures/_site/2015/07/03/test-post-again.html +0 -3
  57. data/spec/fixtures/_site/about.html +0 -31
  58. data/spec/fixtures/_site/hierarchy.html +0 -31
  59. data/spec/fixtures/_site/index.html +0 -17
  60. data/spec/fixtures/_site/page2/index.html +0 -40
  61. data/spec/fixtures/_site/weight.html +0 -15
  62. data/spec/spec_helper_jekyll.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e42531ea19baa4e742f31040364713c0aa846d68
4
- data.tar.gz: 4afb02ff41d0b841005c85d7adaaa2a6e168d58e
3
+ metadata.gz: 5fc07f49e01332879569776774bc13b38b1fa601
4
+ data.tar.gz: 05bde1d8646bb06eb04049e5fb322d35c86744c2
5
5
  SHA512:
6
- metadata.gz: f9e186d2ea14962ea6b23294dd6df6da375082d139838b48f6ac91a3e7acee11e4641d54f9d095661f3fea3577cac811408b2049a0778947cf7679081c6eae66
7
- data.tar.gz: f310963a860ddb76e6f0cb166fab53ec10724e9a362c57cd9aed8b0a9e174650396caff04225eddae56fd0dda101caf95d339a3cff1b77479f90aa065d758c5d
6
+ metadata.gz: 27a25e5b66d6fbd44450897024bc837de069ae78d1142ad8d12e70def6334f593700299126875ae7bdea4dd8819d5dfee80c5832a7a31332b0d27fde5a611eb9
7
+ data.tar.gz: cf69b239d17b80fac3af079474b046b929bd5d7582b4e321ad2568b83184ea7f5b24971d62bc895f8206caaa6d2a54c292898e10ac84d8ae7b02763b337c223b
data/.travis.yml CHANGED
@@ -1,6 +1,10 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ gemfile:
4
+ - gemfiles/jekyll_v2.gemfile
5
+ - gemfiles/jekyll_v3.gemfile
3
6
  before_script: bundle update
7
+ script: ./scripts/test_ci
4
8
  rvm:
5
9
  - 2.2
6
10
  - 2.1
data/Appraisals ADDED
@@ -0,0 +1,8 @@
1
+ appraise 'jekyll-v2' do
2
+ gem 'jekyll', '~> 2.5'
3
+ end
4
+
5
+ appraise 'jekyll-v3' do
6
+ gem 'jekyll', '~> 3.0'
7
+ gem 'jekyll-paginate', '~> 1.1.0'
8
+ end
data/CONTRIBUTING.md CHANGED
@@ -7,18 +7,26 @@ already referenced. If not, feel free to open one.
7
7
  We use [pull requests](https://github.com/algolia/algoliasearch-jekyll/pulls)
8
8
  for collaboration. The workflow is as follow:
9
9
 
10
- - Create a local branch, starting from `master`
11
- - Submit the PR on `master`
10
+ - Create a local branch, starting from `develop`
11
+ - Submit the PR on `develop`
12
12
  - Wait for review
13
13
  - Do the changes requested (if any)
14
- - We may ask you to rebase the branch to latest master if it gets out of sync
15
- with `master`
14
+ - We may ask you to rebase the branch to latest `develop` if it gets out of sync
16
15
  - Receive the thanks of the Algolia team :)
17
16
 
18
17
  # Development workflow
19
18
 
20
- After the necessary `bundle install`, you can simply launch `guard` to start the
21
- test suite in watch mode (perfect for TDD).
19
+ After the necessary `bundle install`, you'll also need to run `appraisal
20
+ install`. This will configure the repository so that tests can be run both from
21
+ Jekyll 2.5 and Jekyll 3.
22
+
23
+ You can then launch:
24
+ - `./scripts/test_v2` to launch tests on Jekyll v2
25
+ - `./scripts/test_v3` to launch tests on Jekyll v3
26
+ - `./scripts/test` to launch tests on both
27
+ - `./scripts/watch` to start a test watcher (for TDD) for Jekyll v2
28
+ - `./scripts/watch_v3` to start a test watcher (for TDD) for Jekyll v3 (you
29
+ cannot run both at the same time)
22
30
 
23
31
  If you want to test the plugin on an existing Jekyll website while developping,
24
32
  I suggest updating the website `Gemfile` to point to the correct local directory
@@ -42,7 +50,7 @@ This part is for main contributors:
42
50
  # Update master and release
43
51
  ./scripts/release
44
52
 
45
- # Install the gem locally
53
+ # Install the gem locally (optional)
46
54
  rake install
47
55
  ```
48
56
 
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'algoliasearch', '~> 1.4'
4
+ gem 'appraisal', '~> 2.1.0'
4
5
  gem 'awesome_print', '~> 1.6'
5
6
  gem 'json', '~> 1.8'
6
7
  gem 'nokogiri', '~> 1.6'
@@ -10,7 +11,6 @@ group :development do
10
11
  gem 'flay', '~> 2.6'
11
12
  gem 'flog', '~> 4.3'
12
13
  gem 'guard-rspec', '~> 4.6'
13
- gem 'jekyll', '~> 2.5' # Jekyll custom commands only available from 2.5
14
14
  gem 'jeweler', '~> 2.0'
15
15
  gem 'rspec', '~> 3.0'
16
16
  gem 'rubocop', '~> 0.31'
data/Guardfile CHANGED
@@ -1,7 +1,17 @@
1
- guard :rspec, cmd: 'bundle exec rspec --color --format documentation' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { 'spec' }
1
+ group :jekyll_v3 do
2
+ guard :rspec, cmd: 'appraisal jekyll-v3 bundle exec rspec --color --format documentation' do
3
+ watch(%r{^spec/.+_spec\.rb$})
4
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
+ watch('spec/spec_helper.rb') { 'spec' }
6
+ end
7
+ end
8
+
9
+ group :jekyll_v2 do
10
+ guard :rspec, cmd: 'appraisal jekyll-v2 bundle exec rspec --color --format documentation' do
11
+ watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { 'spec' }
14
+ end
5
15
  end
6
16
 
7
17
  notification :off
data/README.md CHANGED
@@ -31,7 +31,7 @@ source 'https://rubygems.org'
31
31
  gem 'jekyll', '~> 2.5.3'
32
32
 
33
33
  group :jekyll_plugins do
34
- gem 'algoliasearch-jekyll', '~> 0.4.3'
34
+ gem 'algoliasearch-jekyll', '~> 0.5.3'
35
35
  end
36
36
  ```
37
37
 
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: algoliasearch-jekyll 0.5.3 ruby lib
5
+ # stub: algoliasearch-jekyll 0.6.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-jekyll"
9
- s.version = "0.5.3"
9
+ s.version = "0.6.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Tim Carry"]
14
- s.date = "2015-11-03"
14
+ s.date = "2016-01-11"
15
15
  s.description = "Index all your pages and posts to an Algolia index with `jekyll algolia push`"
16
16
  s.email = "tim@pixelastic.com"
17
17
  s.extra_rdoc_files = [
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  ".rspec",
24
24
  ".rubocop.yml",
25
25
  ".travis.yml",
26
+ "Appraisals",
26
27
  "CONTRIBUTING.md",
27
28
  "Gemfile",
28
29
  "Guardfile",
@@ -31,6 +32,8 @@ Gem::Specification.new do |s|
31
32
  "Rakefile",
32
33
  "algoliasearch-jekyll.gemspec",
33
34
  "docs/travis-settings.png",
35
+ "gemfiles/jekyll_v2.gemfile",
36
+ "gemfiles/jekyll_v3.gemfile",
34
37
  "lib/algoliasearch-jekyll.rb",
35
38
  "lib/credential_checker.rb",
36
39
  "lib/push.rb",
@@ -42,37 +45,47 @@ Gem::Specification.new do |s|
42
45
  "scripts/git_hooks/pre-commit",
43
46
  "scripts/git_hooks/pre-push",
44
47
  "scripts/release",
48
+ "scripts/test",
49
+ "scripts/test_ci",
50
+ "scripts/test_v2",
51
+ "scripts/test_v3",
52
+ "scripts/watch",
53
+ "scripts/watch_v2",
54
+ "scripts/watch_v3",
45
55
  "spec/credential_checker_spec.rb",
46
- "spec/fixtures/_config.yml",
47
- "spec/fixtures/_layouts/default.html",
48
- "spec/fixtures/_my-collection/collection-item.html",
49
- "spec/fixtures/_my-collection/collection-item.md",
50
- "spec/fixtures/_posts/2015-07-02-test-post.md",
51
- "spec/fixtures/_posts/2015-07-03-test-post-again.md",
52
- "spec/fixtures/_site/2015/07/02/test-post.html",
53
- "spec/fixtures/_site/2015/07/03/test-post-again.html",
54
- "spec/fixtures/_site/about.html",
55
- "spec/fixtures/_site/assets/ring.png",
56
- "spec/fixtures/_site/authors.html",
57
- "spec/fixtures/_site/excluded.html",
58
- "spec/fixtures/_site/hierarchy.html",
59
- "spec/fixtures/_site/index.html",
60
- "spec/fixtures/_site/my-collection/collection-item.html",
61
- "spec/fixtures/_site/page2/index.html",
62
- "spec/fixtures/_site/weight.html",
63
- "spec/fixtures/about.md",
64
- "spec/fixtures/api_key_dir/_algolia_api_key",
65
- "spec/fixtures/assets/ring.png",
66
- "spec/fixtures/authors.html",
67
- "spec/fixtures/excluded.html",
68
- "spec/fixtures/hierarchy.md",
69
- "spec/fixtures/index.html",
70
- "spec/fixtures/page2/index.html",
71
- "spec/fixtures/weight.md",
56
+ "spec/fixtures/jekyll_version_2/_config.yml",
57
+ "spec/fixtures/jekyll_version_2/_layouts/default.html",
58
+ "spec/fixtures/jekyll_version_2/_my-collection/collection-item.html",
59
+ "spec/fixtures/jekyll_version_2/_my-collection/collection-item.md",
60
+ "spec/fixtures/jekyll_version_2/_posts/2015-07-02-test-post.md",
61
+ "spec/fixtures/jekyll_version_2/_posts/2015-07-03-test-post-again.md",
62
+ "spec/fixtures/jekyll_version_2/about.md",
63
+ "spec/fixtures/jekyll_version_2/api_key_dir/_algolia_api_key",
64
+ "spec/fixtures/jekyll_version_2/assets/ring.png",
65
+ "spec/fixtures/jekyll_version_2/authors.html",
66
+ "spec/fixtures/jekyll_version_2/excluded.html",
67
+ "spec/fixtures/jekyll_version_2/hierarchy.md",
68
+ "spec/fixtures/jekyll_version_2/index.html",
69
+ "spec/fixtures/jekyll_version_2/page2/index.html",
70
+ "spec/fixtures/jekyll_version_2/weight.md",
71
+ "spec/fixtures/jekyll_version_3/_config.yml",
72
+ "spec/fixtures/jekyll_version_3/_layouts/default.html",
73
+ "spec/fixtures/jekyll_version_3/_my-collection/collection-item.html",
74
+ "spec/fixtures/jekyll_version_3/_my-collection/collection-item.md",
75
+ "spec/fixtures/jekyll_version_3/_posts/2015-07-02-test-post.md",
76
+ "spec/fixtures/jekyll_version_3/_posts/2015-07-03-test-post-again.md",
77
+ "spec/fixtures/jekyll_version_3/about.md",
78
+ "spec/fixtures/jekyll_version_3/api_key_dir/_algolia_api_key",
79
+ "spec/fixtures/jekyll_version_3/assets/ring.png",
80
+ "spec/fixtures/jekyll_version_3/authors.html",
81
+ "spec/fixtures/jekyll_version_3/excluded.html",
82
+ "spec/fixtures/jekyll_version_3/hierarchy.md",
83
+ "spec/fixtures/jekyll_version_3/index.html",
84
+ "spec/fixtures/jekyll_version_3/page2/index.html",
85
+ "spec/fixtures/jekyll_version_3/weight.md",
72
86
  "spec/push_spec.rb",
73
87
  "spec/record_extractor_spec.rb",
74
88
  "spec/spec_helper.rb",
75
- "spec/spec_helper_jekyll.rb",
76
89
  "spec/spec_helper_simplecov.rb",
77
90
  "txt/api_key_missing",
78
91
  "txt/application_id_missing",
@@ -88,6 +101,7 @@ Gem::Specification.new do |s|
88
101
 
89
102
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
90
103
  s.add_runtime_dependency(%q<algoliasearch>, ["~> 1.4"])
104
+ s.add_runtime_dependency(%q<appraisal>, ["~> 2.1.0"])
91
105
  s.add_runtime_dependency(%q<awesome_print>, ["~> 1.6"])
92
106
  s.add_runtime_dependency(%q<json>, ["~> 1.8"])
93
107
  s.add_runtime_dependency(%q<nokogiri>, ["~> 1.6"])
@@ -95,13 +109,13 @@ Gem::Specification.new do |s|
95
109
  s.add_development_dependency(%q<flay>, ["~> 2.6"])
96
110
  s.add_development_dependency(%q<flog>, ["~> 4.3"])
97
111
  s.add_development_dependency(%q<guard-rspec>, ["~> 4.6"])
98
- s.add_development_dependency(%q<jekyll>, ["~> 2.5"])
99
112
  s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
100
113
  s.add_development_dependency(%q<rspec>, ["~> 3.0"])
101
114
  s.add_development_dependency(%q<rubocop>, ["~> 0.31"])
102
115
  s.add_development_dependency(%q<simplecov>, ["~> 0.10"])
103
116
  else
104
117
  s.add_dependency(%q<algoliasearch>, ["~> 1.4"])
118
+ s.add_dependency(%q<appraisal>, ["~> 2.1.0"])
105
119
  s.add_dependency(%q<awesome_print>, ["~> 1.6"])
106
120
  s.add_dependency(%q<json>, ["~> 1.8"])
107
121
  s.add_dependency(%q<nokogiri>, ["~> 1.6"])
@@ -109,7 +123,6 @@ Gem::Specification.new do |s|
109
123
  s.add_dependency(%q<flay>, ["~> 2.6"])
110
124
  s.add_dependency(%q<flog>, ["~> 4.3"])
111
125
  s.add_dependency(%q<guard-rspec>, ["~> 4.6"])
112
- s.add_dependency(%q<jekyll>, ["~> 2.5"])
113
126
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
114
127
  s.add_dependency(%q<rspec>, ["~> 3.0"])
115
128
  s.add_dependency(%q<rubocop>, ["~> 0.31"])
@@ -117,6 +130,7 @@ Gem::Specification.new do |s|
117
130
  end
118
131
  else
119
132
  s.add_dependency(%q<algoliasearch>, ["~> 1.4"])
133
+ s.add_dependency(%q<appraisal>, ["~> 2.1.0"])
120
134
  s.add_dependency(%q<awesome_print>, ["~> 1.6"])
121
135
  s.add_dependency(%q<json>, ["~> 1.8"])
122
136
  s.add_dependency(%q<nokogiri>, ["~> 1.6"])
@@ -124,7 +138,6 @@ Gem::Specification.new do |s|
124
138
  s.add_dependency(%q<flay>, ["~> 2.6"])
125
139
  s.add_dependency(%q<flog>, ["~> 4.3"])
126
140
  s.add_dependency(%q<guard-rspec>, ["~> 4.6"])
127
- s.add_dependency(%q<jekyll>, ["~> 2.5"])
128
141
  s.add_dependency(%q<jeweler>, ["~> 2.0"])
129
142
  s.add_dependency(%q<rspec>, ["~> 3.0"])
130
143
  s.add_dependency(%q<rubocop>, ["~> 0.31"])
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "algoliasearch", "~> 1.4"
6
+ gem "appraisal", "~> 2.1.0"
7
+ gem "awesome_print", "~> 1.6"
8
+ gem "json", "~> 1.8"
9
+ gem "nokogiri", "~> 1.6"
10
+ gem "jekyll", "~> 2.5"
11
+
12
+ group :development do
13
+ gem "coveralls", "~> 0.8"
14
+ gem "flay", "~> 2.6"
15
+ gem "flog", "~> 4.3"
16
+ gem "guard-rspec", "~> 4.6"
17
+ gem "jeweler", "~> 2.0"
18
+ gem "rspec", "~> 3.0"
19
+ gem "rubocop", "~> 0.31"
20
+ gem "simplecov", "~> 0.10"
21
+ end
@@ -0,0 +1,22 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "algoliasearch", "~> 1.4"
6
+ gem "appraisal", "~> 2.1.0"
7
+ gem "awesome_print", "~> 1.6"
8
+ gem "json", "~> 1.8"
9
+ gem "nokogiri", "~> 1.6"
10
+ gem "jekyll", "~> 3.0"
11
+ gem "jekyll-paginate", "~> 1.1.0"
12
+
13
+ group :development do
14
+ gem "coveralls", "~> 0.8"
15
+ gem "flay", "~> 2.6"
16
+ gem "flog", "~> 4.3"
17
+ gem "guard-rspec", "~> 4.6"
18
+ gem "jeweler", "~> 2.0"
19
+ gem "rspec", "~> 3.0"
20
+ gem "rubocop", "~> 0.31"
21
+ gem "simplecov", "~> 0.10"
22
+ end
@@ -4,6 +4,8 @@ require 'json'
4
4
 
5
5
  # Given an HTML file as input, will return an array of records to index
6
6
  class AlgoliaSearchRecordExtractor
7
+ attr_reader :file
8
+
7
9
  def initialize(file)
8
10
  @file = file
9
11
  @config = file.site.config
@@ -31,26 +33,42 @@ class AlgoliaSearchRecordExtractor
31
33
  metadata[:type] = @file.class.name.split('::')[1].downcase
32
34
  metadata[:url] = @file.url
33
35
 
34
- if @file.respond_to? :slug
35
- metadata[:slug] = @file.slug
36
- else
37
- basename = File.basename(@file.path)
38
- extname = File.extname(basename)
39
- metadata[:slug] = File.basename(basename, extname)
40
- end
36
+ metadata[:slug] = slug
41
37
 
42
38
  metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date
43
- metadata[:tags] = tags if @file.respond_to? :tags
39
+ metadata[:tags] = tags
44
40
 
45
41
  metadata
46
42
  end
47
43
 
44
+ # Returns the slug of the document
45
+ def slug
46
+ # Jekyll v3 has it in data
47
+ return @file.data['slug'] if @file.data.key?('slug')
48
+ # Old Jekyll v2 has it at the root
49
+ return @file.slug if @file.respond_to? :slug
50
+ # Otherwise, we guess it from the filename
51
+ basename = File.basename(@file.path)
52
+ extname = File.extname(basename)
53
+ File.basename(basename, extname)
54
+ end
55
+
48
56
  # Extract a list of tags
49
57
  def tags
50
- return nil unless @file.respond_to? :tags
51
- # Some plugins will extend the tags from simple strings to full featured
52
- # objects. We'll simply call .to_s to always have a string
53
- @file.tags.map(&:to_s)
58
+ tags = nil
59
+
60
+ # Jekyll v3 has it in data, while v2 have it at the root
61
+ if @file.data.key?('tags')
62
+ tags = @file.data['tags']
63
+ elsif @file.respond_to? :tags
64
+ tags = @file.tags
65
+ end
66
+
67
+ return tags if tags.nil?
68
+
69
+ # Anyway, we force cast it to string as some plugins will extend the tags to
70
+ # full featured objects
71
+ tags.map(&:to_s)
54
72
  end
55
73
 
56
74
  # Get the list of all HTML nodes to index
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Expose gem version
2
2
  class AlgoliaSearchJekyllVersion
3
3
  def self.to_s
4
- '0.5.3'
4
+ '0.6.0'
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- rake spec || exit 1
3
+ ./scripts/test || exit 1
4
4
 
5
5
  # No over-complex methods
6
6
  ./scripts/check_flog || exit 1
data/scripts/test ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ cd "$(dirname "$BASH_SOURCE")"
3
+
4
+ ./test_v2 && ./test_v3
data/scripts/test_ci ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ # This script will be started by Travis, in the correct context (matrix of Ruby
3
+ # version + Gemfile version), so it only needs to load the tests, without
4
+ # worrying about appraisal
5
+ cd "$(dirname "$BASH_SOURCE")"/..
6
+
7
+ bundle exec rspec
data/scripts/test_v2 ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ cd "$(dirname "$BASH_SOURCE")"/..
3
+
4
+ echo "Testing under Jekyll 2.5"
5
+ appraisal jekyll-v2 bundle exec rspec
data/scripts/test_v3 ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ cd "$(dirname "$BASH_SOURCE")"/..
3
+
4
+ echo "Testing under Jekyll 3.0"
5
+ appraisal jekyll-v3 bundle exec rspec
6
+
data/scripts/watch ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ cd "$(dirname "$BASH_SOURCE")"/..
3
+
4
+ guard -g jekyll_v2