middleman-blog-similar 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.rubocop.yml +33 -0
- data/.travis.yml +12 -21
- data/Gemfile +20 -35
- data/Guardfile +9 -9
- data/README.md +57 -82
- data/Rakefile +9 -7
- data/features/default.feature +21 -0
- data/features/support/env.rb +20 -10
- data/fixtures/test-app/source/{2014-05-08-article0.md → 2014-05-08-article0.html.md} +2 -1
- data/fixtures/test-app/source/{2014-05-09-article1.md → 2014-05-09-article1.html.md} +2 -0
- data/fixtures/test-app/source/{2014-05-10-article2.md → 2014-05-10-article2.html.md} +1 -1
- data/fixtures/test-app/source/{2014-05-11-article3.md → 2014-05-11-article3.html.md} +0 -0
- data/fixtures/test-app/source/{2014-05-12-article4.md → 2014-05-12-article4.html.md} +1 -0
- data/fixtures/test-app/source/{2014-05-13-article5.md → 2014-05-13-article5.html.md} +1 -0
- data/fixtures/test-app/source/{2014-05-14-article6.md → 2014-05-14-article6.html.md} +1 -0
- data/fixtures/test-app/source/index.html.slim +1 -0
- data/fixtures/test-app/source/layout.slim +1 -1
- data/fixtures/test-app/source/layouts/article.slim +6 -6
- data/lib/middleman-blog-similar.rb +3 -3
- data/lib/middleman-blog-similar/blog_article_extensions.rb +8 -20
- data/lib/middleman-blog-similar/database.rb +70 -0
- data/lib/middleman-blog-similar/extension.rb +37 -15
- data/lib/middleman-blog-similar/helpers.rb +12 -6
- data/lib/middleman-blog-similar/models/article.rb +33 -0
- data/lib/middleman-blog-similar/models/migration.rb +32 -0
- data/lib/middleman-blog-similar/models/tag.rb +10 -0
- data/lib/middleman-blog-similar/models/tagging.rb +10 -0
- data/lib/middleman-blog-similar/resource_list_manipulator.rb +19 -0
- data/lib/middleman-blog-similar/tagger/entagger.rb +17 -0
- data/lib/middleman-blog-similar/tagger/mecab.rb +19 -0
- data/lib/middleman-blog-similar/tagger/tags.rb +13 -0
- data/lib/middleman-blog-similar/version.rb +1 -1
- data/lib/middleman_extension.rb +0 -1
- data/middleman-blog-similar.gemspec +18 -13
- data/spec/middleman-blog-similar/extension_spec.rb +44 -1
- data/spec/middleman-blog-similar/tagger_spec.rb +24 -0
- data/spec/spec_helper.rb +33 -24
- metadata +77 -72
- data/features/damerau_levenshtein.feature +0 -20
- data/features/levenshtein.feature +0 -20
- data/features/word_frequency.feature +0 -15
- data/lib/middleman-blog-similar/algorithm.rb +0 -19
- data/lib/middleman-blog-similar/algorithm/damerau_levenshtein.rb +0 -7
- data/lib/middleman-blog-similar/algorithm/levenshtein.rb +0 -7
- data/lib/middleman-blog-similar/algorithm/unigrams.csv +0 -21089
- data/lib/middleman-blog-similar/algorithm/word_frequency.rb +0 -69
- data/lib/middleman-blog-similar/algorithm/word_frequency/mecab.rb +0 -22
- data/lib/middleman-blog-similar/algorithm/word_frequency/tree_tagger.rb +0 -20
- data/spec/helper_spec.rb +0 -4
- data/spec/middleman-blog-similar/algorithm/damerau_levenshtein_spec.rb +0 -42
- data/spec/middleman-blog-similar/algorithm/levenshtein_spec.rb +0 -42
- data/spec/middleman-blog-similar/algorithm/word_frequency/mecab_spec.rb +0 -41
- data/spec/middleman-blog-similar/algorithm/word_frequency/tree_tagger_spec.rb +0 -52
- data/spec/middleman-blog-similar/algorithm/word_frequency_spec.rb +0 -73
- data/spec/middleman-blog-similar/algorithm_spec.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4791e37639ec38d3703d84e25feb40184997097
|
4
|
+
data.tar.gz: 11982f6b235436a28ce0addd868d918f90f0f0e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddef1dfc312319c7907069f11af08ee47dd382df4ac727e24009d3be05b4f60e46b6773a01f3de30707abaad7c401c12596146554662818a4aad4235a7a40bfa
|
7
|
+
data.tar.gz: 61b841719e5338f447912fbf0c804a04f29cead34be5013e66f2a0502e53ccf18f282cdcc931725d77707099e4d59013dcfede5f8a7e1b7e66010f21a3eff115
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- .gems/**/*
|
4
|
+
- tmp/**/*
|
5
|
+
Metrics/LineLength:
|
6
|
+
Enabled: false
|
7
|
+
Style/Documentation:
|
8
|
+
Enabled: false
|
9
|
+
Rails/HasAndBelongsToMany:
|
10
|
+
Enabled: false
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Enabled: false
|
13
|
+
MethodLength:
|
14
|
+
Max: 50
|
15
|
+
CyclomaticComplexity:
|
16
|
+
Max: 25
|
17
|
+
PerceivedComplexity:
|
18
|
+
Max: 20
|
19
|
+
Style/RescueModifier:
|
20
|
+
Enabled: false
|
21
|
+
Style/PredicateName:
|
22
|
+
Enabled: false
|
23
|
+
Metrics/ClassLength:
|
24
|
+
Enabled: false
|
25
|
+
GuardClause:
|
26
|
+
MinBodyLength: 3
|
27
|
+
CaseIndentation:
|
28
|
+
IndentOneStep: true
|
29
|
+
NumericLiterals:
|
30
|
+
MinDigits: 7
|
31
|
+
FileName:
|
32
|
+
Exclude:
|
33
|
+
- lib/middleman-blog-similar.rb
|
data/.travis.yml
CHANGED
@@ -1,25 +1,16 @@
|
|
1
1
|
rvm:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
- jruby-19mode
|
6
|
-
|
7
|
-
# Bug in jRuby w/ Rouge: https://github.com/jruby/jruby/issues/1392
|
8
|
-
matrix:
|
9
|
-
allow_failures:
|
10
|
-
- rvm: jruby-19mode
|
2
|
+
- 2.2.6
|
3
|
+
- 2.3.2
|
4
|
+
- 2.4.1
|
11
5
|
env:
|
12
6
|
global:
|
13
|
-
|
14
|
-
- TREETAGGER_COMMAND=$TAGGER_DIR/cmd/tree-tagger-english
|
15
|
-
- TEST=true
|
7
|
+
- TEST=true
|
16
8
|
before_install:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
script: "bundle exec rake test"
|
9
|
+
- curl -L https://git.io/vSUUX | bash
|
10
|
+
script: bundle exec rake test
|
11
|
+
deploy:
|
12
|
+
provider: rubygems
|
13
|
+
api_key:
|
14
|
+
secure: PjIBKKWhCcamn3+X/H2bfDn8m0X6nGTEwZw1LpBbWSiXTxJeUlp1uFjwQ82e8yG6Fk3vLlrCZRks3eM3NIzv9V2l1QHQdivLsha/nBkIpnXB4bIRvJG1bhPVmgOSZQCDJjzgUWSlDljzwFjxJ1NOSYQzbPyvOtu+Ks7/p+BJzHI=
|
15
|
+
on:
|
16
|
+
tags: true
|
data/Gemfile
CHANGED
@@ -1,43 +1,28 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
gem 'middleman-core', '~> 3.2'
|
4
|
-
gem 'middleman-blog', '~> 3.5'
|
5
|
-
|
6
3
|
# Specify your gem's dependencies in middleman-blog-similar.gemspec
|
7
4
|
gemspec
|
8
5
|
|
9
|
-
gem '
|
10
|
-
gem '
|
11
|
-
|
12
|
-
|
13
|
-
gem '
|
14
|
-
gem '
|
15
|
-
gem '
|
16
|
-
gem 'rspec'
|
17
|
-
gem 'spork'
|
18
|
-
gem 'guard-rake'
|
6
|
+
gem 'aruba', '~> 0.7.4', require: false
|
7
|
+
gem 'cane', platforms: [:mri_19, :mri_20], require: false
|
8
|
+
gem 'capybara', '~> 2.5.0', require: false
|
9
|
+
gem 'codeclimate-test-reporter', '~> 1.0', require: false
|
10
|
+
gem 'coveralls', require: false
|
11
|
+
gem 'cucumber', '~> 2.0', require: false
|
12
|
+
gem 'engtagger'
|
19
13
|
gem 'guard-cucumber'
|
14
|
+
gem 'guard-rake'
|
20
15
|
gem 'guard-rspec'
|
21
|
-
gem 'guard-
|
22
|
-
gem '
|
16
|
+
gem 'guard-rubocop', require: false
|
17
|
+
gem 'middleman-cli', '>= 4.0.0'
|
18
|
+
gem 'natto', '~> 1.1'
|
19
|
+
gem 'pry', '~> 0.10', group: :development, require: false
|
20
|
+
gem 'rack', '~> 1.6.5', require: false
|
21
|
+
gem 'rake', '~> 10.1.0', require: false
|
23
22
|
gem 'redcarpet'
|
24
|
-
gem '
|
25
|
-
|
26
|
-
|
27
|
-
gem '
|
28
|
-
|
29
|
-
|
30
|
-
gem 'levenshtein-ffi', :require => 'levenshtein'
|
31
|
-
gem 'levenshtein'
|
32
|
-
gem 'damerau-levenshtein'
|
33
|
-
# gem 'gsl'
|
34
|
-
# gem 'tf-idf-similarity'
|
35
|
-
|
36
|
-
# morphological analyzers
|
37
|
-
gem 'engtagger'
|
38
|
-
gem 'okura'
|
39
|
-
gem 'myaso', '~> 0.4.0.pre2'
|
40
|
-
|
41
|
-
if RUBY_VERSION >= '1.9.3'
|
42
|
-
gem "codeclimate-test-reporter", :group => :test, :require => nil
|
43
|
-
end
|
23
|
+
gem 'rspec', '~> 3.0', require: false
|
24
|
+
gem 'rspec-collection_matchers', require: false
|
25
|
+
gem 'rspec-its', require: false
|
26
|
+
gem 'rubocop', require: false
|
27
|
+
gem 'slim'
|
28
|
+
gem 'yard', '~> 0.8.0', require: false
|
data/Guardfile
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
guard '
|
2
|
-
watch('Gemfile')
|
3
|
-
watch('Gemfile.lock')
|
4
|
-
watch(/.*\.rb$/)
|
5
|
-
end
|
6
|
-
|
7
|
-
guard 'rspec' do
|
1
|
+
guard 'rspec', cmd: 'bundle exec rspec' do
|
8
2
|
watch(%r{^spec/.*\.rb$})
|
9
|
-
watch(%r{^lib/(.+)\.rb$}) {|m| ["spec/#{m[1]}_spec.rb"] + Dir["spec/#{m[1]}/*_spec.rb"] }
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| ["spec/#{m[1]}_spec.rb"] + Dir["spec/#{m[1]}/*_spec.rb"] }
|
4
|
+
watch(%r{^lib/middleman-blog-similar/tagger/(.+)\.rb$}) { ['spec/middleman-blog-similar/tagger_spec.rb'] }
|
10
5
|
end
|
11
6
|
|
12
|
-
guard 'cucumber' do
|
7
|
+
guard 'cucumber', cmd: 'bundle exec cucumber' do
|
13
8
|
watch(%r{^features/.+\.feature$})
|
14
9
|
watch(%r{^features/support/.+$}) { 'features' }
|
15
10
|
watch(%r{^lib/.*\.rb$}) { 'features' }
|
16
11
|
end
|
12
|
+
|
13
|
+
guard :rubocop, cmd: 'bundle exec rake rubocop' do
|
14
|
+
watch(/.+\.rb$/)
|
15
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
16
|
+
end
|
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
|
1
|
+
middleman-blog-similar
|
2
2
|
======================
|
3
3
|
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/middleman-blog-similar.png)][gem]
|
5
|
+
[![Build Status](https://travis-ci.org/ngs/middleman-blog-similar.svg?branch=master)][travis]
|
6
|
+
[![Dependency Status](https://gemnasium.com/ngs/middleman-blog-similar.png?travis)][gemnasium]
|
7
|
+
[![Code Quality](https://codeclimate.com/github/ngs/middleman-blog-similar.png)][codeclimate]
|
8
|
+
[![Coverage Status](https://coveralls.io/repos/github/ngs/middleman-blog-similar/badge.svg)][coveralls]
|
9
|
+
|
4
10
|
`middleman-blog-similar` is an extension for [middleman-blog] that adds method to lookup similar article.
|
5
11
|
|
6
|
-
|
12
|
+
Usage
|
13
|
+
-----
|
7
14
|
|
8
15
|
`Middleman::Blog::BlogArticle#similar_articles` returns an array of `Middleman::Blog::BlogArticle` instances.
|
9
16
|
|
@@ -30,109 +37,78 @@ Configuration
|
|
30
37
|
|
31
38
|
```ruby
|
32
39
|
gem 'middleman-blog-similar'
|
33
|
-
#
|
34
|
-
# if you have preferred other algorithm:
|
35
|
-
#
|
36
|
-
# levenshtein
|
37
|
-
# gem 'levenshtein-ffi', :require => 'levenshtein'
|
38
|
-
#
|
39
|
-
# damerau levenshtein:
|
40
|
-
# gem 'damerau-levenshtein'
|
41
40
|
```
|
42
41
|
|
43
42
|
### `config.rb`
|
44
43
|
|
45
44
|
```ruby
|
46
|
-
|
47
|
-
activate :similar # , :algorithm => :word_frequency by default.
|
48
|
-
|
49
|
-
# Use TreeTagger
|
50
|
-
activate :similar, :algorithm => :'word_frequency/tree_tagger'
|
51
|
-
|
52
|
-
# Use MeCab
|
53
|
-
activate :similar, :algorithm => :'word_frequency/mecab'
|
54
|
-
|
55
|
-
# Levenshtein distance function:
|
56
|
-
activate :similar, :algorithm => :levenshtein
|
57
|
-
|
58
|
-
# Damerau–Levenshtein distance function:
|
59
|
-
activate :similar, :algorithm => :damerau_levenshtein
|
45
|
+
activate :similar
|
60
46
|
```
|
61
47
|
|
62
|
-
This
|
48
|
+
This extension finds similar articles using those are using tags by default.
|
63
49
|
|
64
|
-
|
50
|
+
#### Built-in Tagger
|
65
51
|
|
66
|
-
|
52
|
+
You can set taggers using `tagger:` option. [MeCab] and [EngTagger] adopters are built in this extension.
|
67
53
|
|
68
|
-
|
69
|
-
|
70
|
-
|
54
|
+
```ruby
|
55
|
+
# Find by tags (default)
|
56
|
+
activate :similar, tagger: :tags
|
71
57
|
|
72
|
-
|
73
|
-
|
74
|
-
```
|
58
|
+
# Using MeCab / Need to add `gem 'natto'` in Gemfile
|
59
|
+
activate :similar, tagger: :mecab
|
75
60
|
|
76
|
-
|
77
|
-
|
78
|
-
You need to install [TreeTagger] and export path to the tagger script to `TREETAGGER_COMMAND` environment variable.
|
79
|
-
|
80
|
-
```bash
|
81
|
-
# Mac OS X
|
82
|
-
curl -#o tree-tagger-MacOSX-3.2-intel.tar.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/tree-tagger-MacOSX-3.2-intel.tar.gz
|
83
|
-
# or Linux
|
84
|
-
curl -#o tree-tagger-linux-3.2.tar.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/tree-tagger-linux-3.2.tar.gz
|
85
|
-
# Your language parameter file.
|
86
|
-
curl -#o english-par-linux-3.2.bin.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/english-par-linux-3.2.bin.gz
|
87
|
-
# Tagger scripts
|
88
|
-
curl -#o tagger-scripts.tar.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/tagger-scripts.tar.gz
|
89
|
-
# Install script
|
90
|
-
curl -#o install-tagger.sh http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/install-tagger.sh
|
91
|
-
# Install tagger
|
92
|
-
sh install-tagger.sh
|
93
|
-
# Append export variable
|
94
|
-
echo "export TREETAGGER_COMMAND=\"$(pwd)/cmd/tree-tagger-english\"" >> ~/.bash_profile
|
61
|
+
# Using EngTagger / Need to add `gem 'entagger'` in Gemfile
|
62
|
+
activate :similar, tagger: :entagger
|
95
63
|
```
|
96
64
|
|
97
|
-
|
65
|
+
#### Using Lambda
|
98
66
|
|
99
|
-
You can use
|
67
|
+
You can use lambda as tagger
|
100
68
|
|
101
69
|
```ruby
|
102
|
-
|
103
|
-
|
104
|
-
# Do stuff and return scores
|
105
|
-
end
|
106
|
-
end
|
70
|
+
# Resource is a Middleman::Blog::BlogArticle
|
71
|
+
activate :similar, tagger: ->(resource) { [resource.data.category] }
|
107
72
|
```
|
108
73
|
|
74
|
+
#### Multiple Taggers
|
75
|
+
|
76
|
+
You can configure multiple taggers both built-in and lambda taggers.
|
77
|
+
|
109
78
|
```ruby
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
79
|
+
activate :similar, tagger: {
|
80
|
+
# key = tagger, value = weight
|
81
|
+
mecab: 1,
|
82
|
+
entagger: 1,
|
83
|
+
tags: 3,
|
84
|
+
# key = (ignored), value[0] = weight, value[1] = lambda
|
85
|
+
custom: [5, ->(resource) { resource.data.category ? [resource.data.category] : [] }]
|
86
|
+
}
|
116
87
|
```
|
117
88
|
|
118
|
-
|
89
|
+
#### Database Location
|
90
|
+
|
91
|
+
This extension uses [SQLite3] to calculate similarity between articles.
|
92
|
+
|
93
|
+
Database location is `${PROJECT_ROOT}/.similar.db` by default.
|
94
|
+
|
95
|
+
You can specify database location using `db:` option.
|
119
96
|
|
120
97
|
```ruby
|
121
|
-
|
122
|
-
|
98
|
+
# Expands to ${HOME}/similar.db
|
99
|
+
activate :similar, db: '~/similar.db'
|
123
100
|
|
124
|
-
|
125
|
-
|
101
|
+
# Expands to ${PROJECT_ROOT}/tmp/middleman-blog-similar.db
|
102
|
+
activate :similar, db: 'tmp/middleman-blog-similar.db'
|
126
103
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
[![Code Quality](https://codeclimate.com/github/ngs/middleman-blog-similar.png)][codeclimate]
|
104
|
+
# Stores in memory database
|
105
|
+
activate :similar, db: ':memory:'
|
106
|
+
```
|
131
107
|
|
132
108
|
License
|
133
109
|
-------
|
134
110
|
|
135
|
-
Copyright (c) 2014 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.
|
111
|
+
Copyright (c) 2014-2017 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.
|
136
112
|
|
137
113
|
[middleman]: http://middlemanapp.com
|
138
114
|
[middleman-blog]: https://github.com/middleman/middleman-blog
|
@@ -140,10 +116,9 @@ Copyright (c) 2014 [Atsushi Nagase]. MIT Licensed, see [LICENSE] for details.
|
|
140
116
|
[travis]: http://travis-ci.org/ngs/middleman-blog-similar
|
141
117
|
[gemnasium]: https://gemnasium.com/ngs/middleman-blog-similar
|
142
118
|
[codeclimate]: https://codeclimate.com/github/ngs/middleman-blog-similar
|
143
|
-
[LICENSE]:
|
144
|
-
[Atsushi Nagase]:
|
145
|
-
[
|
146
|
-
[
|
147
|
-
[
|
148
|
-
[
|
149
|
-
[MeCab]: http://mecab.googlecode.com/svn/trunk/mecab/doc/index.html
|
119
|
+
[LICENSE]: LICENSE.md
|
120
|
+
[Atsushi Nagase]: https://ngs.io
|
121
|
+
[coveralls]: https://coveralls.io/github/ngs/middleman-blog-similar
|
122
|
+
[MeCab]: http://taku910.github.io/mecab/
|
123
|
+
[EngTagger]: https://github.com/yohasebe/engtagger
|
124
|
+
[SQLite3]: https://www.sqlite.org/
|
data/Rakefile
CHANGED
@@ -3,33 +3,35 @@ Bundler::GemHelper.install_tasks
|
|
3
3
|
|
4
4
|
require 'cucumber/rake/task'
|
5
5
|
require 'rspec/core/rake_task'
|
6
|
+
require 'rubocop/rake_task'
|
7
|
+
RuboCop::RakeTask.new
|
6
8
|
|
7
9
|
RSpec::Core::RakeTask.new(:spec)
|
8
10
|
|
9
11
|
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
10
|
-
exempt_tags =
|
11
|
-
exempt_tags <<
|
12
|
+
exempt_tags = ''
|
13
|
+
exempt_tags << '--tags ~@nojava ' if RUBY_PLATFORM == 'java'
|
12
14
|
t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
13
15
|
end
|
14
16
|
|
15
17
|
require 'rake/clean'
|
16
18
|
|
17
|
-
task :
|
19
|
+
task test: %w(rubocop spec cucumber)
|
18
20
|
|
19
21
|
begin
|
20
22
|
require 'cane/rake_task'
|
21
23
|
|
22
|
-
desc
|
24
|
+
desc 'Run cane to check quality metrics'
|
23
25
|
Cane::RakeTask.new(:quality) do |cane|
|
24
26
|
cane.no_style = true
|
25
27
|
cane.no_doc = true
|
26
|
-
cane.abc_glob =
|
28
|
+
cane.abc_glob = 'lib/middleman-blog-similar/**/*.rb'
|
27
29
|
end
|
28
30
|
rescue LoadError
|
29
|
-
|
31
|
+
warn 'cane not available, quality task not provided.'
|
30
32
|
end
|
31
33
|
|
32
|
-
desc
|
34
|
+
desc 'Build HTML documentation'
|
33
35
|
task :doc do
|
34
36
|
sh 'bundle exec yard'
|
35
37
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Default
|
2
|
+
|
3
|
+
Scenario: iterate simlar_articles
|
4
|
+
Given a fixture app "test-app"
|
5
|
+
And a file named "config.rb" with:
|
6
|
+
"""
|
7
|
+
activate :blog do|blog|
|
8
|
+
blog.layout = "article"
|
9
|
+
end
|
10
|
+
activate :similar
|
11
|
+
"""
|
12
|
+
Given the Server is running at "test-app"
|
13
|
+
When I go to "/2014/05/08/article0.html"
|
14
|
+
Then I should see "<h1>Article 0</h1>"
|
15
|
+
Then I should see '<body data-similar-article-count="4">'
|
16
|
+
Then I should see '<li class="a0"><a href="/2014/05/14/article6.html"><span class="title">Article 6</span><span class="tags">dog, Brown, cat</span></a></li>'
|
17
|
+
Then I should see '<li class="a1"><a href="/2014/05/12/article4.html"><span class="title">Article 4</span><span class="tags">dog, cat, fox</span></a></li>'
|
18
|
+
Then I should see '<li class="a2"><a href="/2014/05/09/article1.html"><span class="title">Article 1</span><span class="tags">dog, cat</span></a></li>'
|
19
|
+
Then I should see '<li class="a3"><a href="/2014/05/13/article5.html"><span class="title">Article 5</span><span class="tags">dog</span></a></li>'
|
20
|
+
When I go to "/page.html"
|
21
|
+
Then I should see '<body data-similar-article-count="0">'
|
data/features/support/env.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'codeclimate-test-reporter'
|
2
|
+
require 'coveralls'
|
3
|
+
require 'simplecov'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
6
|
+
Coveralls::SimpleCov::Formatter,
|
7
|
+
SimpleCov::Formatter::HTMLFormatter,
|
8
|
+
CodeClimate::TestReporter::Formatter
|
9
|
+
]
|
7
10
|
|
8
|
-
|
9
|
-
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/features/'
|
10
13
|
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
ENV['COVERALLS_REPO_TOKEN'] && Coveralls.wear!
|
16
|
+
|
17
|
+
ENV['TEST'] = 'true'
|
18
|
+
ENV['AUTOLOAD_SPROCKETS'] = 'false'
|
19
|
+
|
20
|
+
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
21
|
+
require 'middleman-core'
|
22
|
+
require 'middleman-core/step_definitions'
|
23
|
+
require 'middleman-blog'
|
24
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-blog-similar')
|