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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +33 -0
  5. data/.travis.yml +12 -21
  6. data/Gemfile +20 -35
  7. data/Guardfile +9 -9
  8. data/README.md +57 -82
  9. data/Rakefile +9 -7
  10. data/features/default.feature +21 -0
  11. data/features/support/env.rb +20 -10
  12. data/fixtures/test-app/source/{2014-05-08-article0.md → 2014-05-08-article0.html.md} +2 -1
  13. data/fixtures/test-app/source/{2014-05-09-article1.md → 2014-05-09-article1.html.md} +2 -0
  14. data/fixtures/test-app/source/{2014-05-10-article2.md → 2014-05-10-article2.html.md} +1 -1
  15. data/fixtures/test-app/source/{2014-05-11-article3.md → 2014-05-11-article3.html.md} +0 -0
  16. data/fixtures/test-app/source/{2014-05-12-article4.md → 2014-05-12-article4.html.md} +1 -0
  17. data/fixtures/test-app/source/{2014-05-13-article5.md → 2014-05-13-article5.html.md} +1 -0
  18. data/fixtures/test-app/source/{2014-05-14-article6.md → 2014-05-14-article6.html.md} +1 -0
  19. data/fixtures/test-app/source/index.html.slim +1 -0
  20. data/fixtures/test-app/source/layout.slim +1 -1
  21. data/fixtures/test-app/source/layouts/article.slim +6 -6
  22. data/lib/middleman-blog-similar.rb +3 -3
  23. data/lib/middleman-blog-similar/blog_article_extensions.rb +8 -20
  24. data/lib/middleman-blog-similar/database.rb +70 -0
  25. data/lib/middleman-blog-similar/extension.rb +37 -15
  26. data/lib/middleman-blog-similar/helpers.rb +12 -6
  27. data/lib/middleman-blog-similar/models/article.rb +33 -0
  28. data/lib/middleman-blog-similar/models/migration.rb +32 -0
  29. data/lib/middleman-blog-similar/models/tag.rb +10 -0
  30. data/lib/middleman-blog-similar/models/tagging.rb +10 -0
  31. data/lib/middleman-blog-similar/resource_list_manipulator.rb +19 -0
  32. data/lib/middleman-blog-similar/tagger/entagger.rb +17 -0
  33. data/lib/middleman-blog-similar/tagger/mecab.rb +19 -0
  34. data/lib/middleman-blog-similar/tagger/tags.rb +13 -0
  35. data/lib/middleman-blog-similar/version.rb +1 -1
  36. data/lib/middleman_extension.rb +0 -1
  37. data/middleman-blog-similar.gemspec +18 -13
  38. data/spec/middleman-blog-similar/extension_spec.rb +44 -1
  39. data/spec/middleman-blog-similar/tagger_spec.rb +24 -0
  40. data/spec/spec_helper.rb +33 -24
  41. metadata +77 -72
  42. data/features/damerau_levenshtein.feature +0 -20
  43. data/features/levenshtein.feature +0 -20
  44. data/features/word_frequency.feature +0 -15
  45. data/lib/middleman-blog-similar/algorithm.rb +0 -19
  46. data/lib/middleman-blog-similar/algorithm/damerau_levenshtein.rb +0 -7
  47. data/lib/middleman-blog-similar/algorithm/levenshtein.rb +0 -7
  48. data/lib/middleman-blog-similar/algorithm/unigrams.csv +0 -21089
  49. data/lib/middleman-blog-similar/algorithm/word_frequency.rb +0 -69
  50. data/lib/middleman-blog-similar/algorithm/word_frequency/mecab.rb +0 -22
  51. data/lib/middleman-blog-similar/algorithm/word_frequency/tree_tagger.rb +0 -20
  52. data/spec/helper_spec.rb +0 -4
  53. data/spec/middleman-blog-similar/algorithm/damerau_levenshtein_spec.rb +0 -42
  54. data/spec/middleman-blog-similar/algorithm/levenshtein_spec.rb +0 -42
  55. data/spec/middleman-blog-similar/algorithm/word_frequency/mecab_spec.rb +0 -41
  56. data/spec/middleman-blog-similar/algorithm/word_frequency/tree_tagger_spec.rb +0 -52
  57. data/spec/middleman-blog-similar/algorithm/word_frequency_spec.rb +0 -73
  58. 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: 5ee2d869f0fbef993f19006dbb2a3ffd062aa3e1
4
- data.tar.gz: 7051b96407a79365e0959785210a2a3e55b5191a
3
+ metadata.gz: b4791e37639ec38d3703d84e25feb40184997097
4
+ data.tar.gz: 11982f6b235436a28ce0addd868d918f90f0f0e8
5
5
  SHA512:
6
- metadata.gz: 419555674c318f4d018b1c39e9de9012b16f7f6fcb5ee9d95a7aa941fac010dcbc33da4dbbb014161d619cde8c3addfce3155f248472c8c0d7bbc43783eeca61
7
- data.tar.gz: 840433955aabe91a21b59701ebe1598d4bec976752ea89e7da40de575d05fb33749e30bec8bc821b70c1901c96c629e8b77d6b8f4f0f04634c414d3f57248fa4
6
+ metadata.gz: ddef1dfc312319c7907069f11af08ee47dd382df4ac727e24009d3be05b4f60e46b6773a01f3de30707abaad7c401c12596146554662818a4aad4235a7a40bfa
7
+ data.tar.gz: 61b841719e5338f447912fbf0c804a04f29cead34be5013e66f2a0502e53ccf18f282cdcc931725d77707099e4d59013dcfede5f8a7e1b7e66010f21a3eff115
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ tmp
16
16
  Makefile
17
17
  .mm-pid-*
18
18
  *.gem
19
+ similar.db
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
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
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.0
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
- - TAGGER_DIR=$TRAVIS_BUILD_DIR/tagger
14
- - TREETAGGER_COMMAND=$TAGGER_DIR/cmd/tree-tagger-english
15
- - TEST=true
7
+ - TEST=true
16
8
  before_install:
17
- - sudo apt-get -yV install mecab
18
- - sudo apt-get -yV install mecab-ipadic-utf8
19
- - mkdir $TAGGER_DIR
20
- - curl --progress-bar -o $TAGGER_DIR/tree-tagger-linux-3.2.tar.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/tree-tagger-linux-3.2.tar.gz
21
- - curl --progress-bar -o $TAGGER_DIR/tagger-scripts.tar.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/tagger-scripts.tar.gz
22
- - curl --progress-bar -o $TAGGER_DIR/install-tagger.sh http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/install-tagger.sh
23
- - curl --progress-bar -o $TAGGER_DIR/english-par-linux-3.2.bin.gz http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/data/english-par-linux-3.2.bin.gz
24
- - cd $TAGGER_DIR && sh install-tagger.sh && cd -
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 'rake', '~> 10.1.0', :require => false
10
- gem 'yard', '~> 0.8.0', :require => false
11
-
12
- # Test tools
13
- gem 'cucumber', '~> 1.3.1'
14
- gem 'fivemat'
15
- gem 'aruba', '~> 0.5.1'
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-spork'
22
- gem 'slim'
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 'sqlite3'
25
-
26
- # Code Quality
27
- gem 'cane', :platforms => [:mri_19, :mri_20], :require => false
28
-
29
- # Similarity engines
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 'spork' do
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
- Middleman-Blog-Similar
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
- ### Usage
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
- # Word frequency sort:
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 library supports [levenshtein-ffi], [levenshtein] and [damerau-levenshtein].
48
+ This extension finds similar articles using those are using tags by default.
63
49
 
64
- ## Morphological Analysis
50
+ #### Built-in Tagger
65
51
 
66
- ### [MeCab]
52
+ You can set taggers using `tagger:` option. [MeCab] and [EngTagger] adopters are built in this extension.
67
53
 
68
- You need to install `mecab` command in your `PATH`.
69
-
70
- #### Mac OS X with Homebrew
54
+ ```ruby
55
+ # Find by tags (default)
56
+ activate :similar, tagger: :tags
71
57
 
72
- ```bash
73
- brew install mecab mecab-ipadic
74
- ```
58
+ # Using MeCab / Need to add `gem 'natto'` in Gemfile
59
+ activate :similar, tagger: :mecab
75
60
 
76
- ### [TreeTagger]
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
- ## Customizing
65
+ #### Using Lambda
98
66
 
99
- You can use custom algorithm and morphological analyser with implementing modules like this:
67
+ You can use lambda as tagger
100
68
 
101
69
  ```ruby
102
- class Middleman::Blog::Similar::Algorithm::MyFastDistance < ::Middleman::Blog::Similar::Algorithm
103
- def similar_articles
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
- class Middleman::Blog::Similar::Algorithm::WordFrequency::SuperClever < ::Middleman::Blog::Similar::Algorithm
111
- def words
112
- # Do stuff and return words
113
- end
114
- end
115
- end
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
- then in your `config.rb`
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
- activate :similar, :algorithm => :my_fast_distance
122
- ```
98
+ # Expands to ${HOME}/similar.db
99
+ activate :similar, db: '~/similar.db'
123
100
 
124
- Build & Dependency Status
125
- -------------------------
101
+ # Expands to ${PROJECT_ROOT}/tmp/middleman-blog-similar.db
102
+ activate :similar, db: 'tmp/middleman-blog-similar.db'
126
103
 
127
- [![Gem Version](https://badge.fury.io/rb/middleman-blog-similar.png)][gem]
128
- [![Build Status](https://travis-ci.org/ngs/middleman-blog-similar.svg?branch=master)][travis]
129
- [![Dependency Status](https://gemnasium.com/ngs/middleman-blog-similar.png?travis)][gemnasium]
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]: https://github.com/ngs/middleman-blog-similar/blob/master/LICENSE.md
144
- [Atsushi Nagase]: http://ngs.io/
145
- [levenshtein-ffi]: https://github.com/dbalatero/levenshtein-ffi
146
- [levenshtein]: https://github.com/schuyler/levenshtein
147
- [damerau-levenshtein]: https://github.com/GlobalNamesArchitecture/damerau-levenshtein
148
- [TreeTagger]: http://www.cis.uni-muenchen.de/~schmid/tools/TreeTagger/
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 << "--tags ~@nojava " if RUBY_PLATFORM == "java"
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 :test => ["spec", "cucumber"]
19
+ task test: %w(rubocop spec cucumber)
18
20
 
19
21
  begin
20
22
  require 'cane/rake_task'
21
23
 
22
- desc "Run cane to check quality metrics"
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 = "lib/middleman-blog-similar/**/*.rb"
28
+ cane.abc_glob = 'lib/middleman-blog-similar/**/*.rb'
27
29
  end
28
30
  rescue LoadError
29
- # warn "cane not available, quality task not provided."
31
+ warn 'cane not available, quality task not provided.'
30
32
  end
31
33
 
32
- desc "Build HTML documentation"
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">'
@@ -1,14 +1,24 @@
1
- PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
- ENV['TEST'] = 'true'
1
+ require 'codeclimate-test-reporter'
2
+ require 'coveralls'
3
+ require 'simplecov'
3
4
 
4
- require 'rubygems'
5
- require 'spork'
6
- $LOAD_PATH.unshift File.join(PROJECT_ROOT_PATH, 'lib')
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
6
+ Coveralls::SimpleCov::Formatter,
7
+ SimpleCov::Formatter::HTMLFormatter,
8
+ CodeClimate::TestReporter::Formatter
9
+ ]
7
10
 
8
- Spork.prefork do
9
- require "middleman-blog-similar"
11
+ SimpleCov.start do
12
+ add_filter '/features/'
10
13
  end
11
14
 
12
- require "middleman-core"
13
- require "middleman-blog"
14
- require "middleman-core/step_definitions"
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')