middleman-blog-similar 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +3 -0
- data/.travis.yml +3 -1
- data/Gemfile +24 -23
- data/Rakefile +1 -1
- data/lib/middleman-blog-similar/database.rb +4 -2
- data/lib/middleman-blog-similar/version.rb +1 -1
- data/middleman-blog-similar.gemspec +1 -0
- data/spec/middleman-blog-similar/extension_spec.rb +8 -8
- data/spec/middleman-blog-similar/tagger_spec.rb +4 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ca4ea19f11faace7ebb481d6f404ba32b3f8b92
|
4
|
+
data.tar.gz: a806d24fd4486f358ba71e927f3a4d34d63a92c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab468137e22f2497b171a3a7e656996f33edce4c3ed12cf4454054201b9eeec27fe23a7393ade8b86e4c437a1d49b7e0a8be32cea94159bbc65599130befa4d5
|
7
|
+
data.tar.gz: 8985d7a877611d167f8f1711b5f6658249f2037b0c5d96a21d413371960f4c8caf9a477a45a9c923a753d97678cddbb561dddf238a5d74eb624115f011ff0950
|
data/.codeclimate.yml
ADDED
data/.travis.yml
CHANGED
@@ -6,7 +6,9 @@ env:
|
|
6
6
|
global:
|
7
7
|
- TEST=true
|
8
8
|
before_install:
|
9
|
-
- curl -L https://
|
9
|
+
- curl -L "https://dl.bintray.com/ngs/travis/mecab-with-ipa-dic.tar.gz" -o mecab.tgz && sudo tar xvfz mecab.tgz -C /usr && rm -f mecab.tgz
|
10
|
+
after_succes:
|
11
|
+
- bundle exec codeclimate-test-reporter
|
10
12
|
script: bundle exec rake test
|
11
13
|
deploy:
|
12
14
|
provider: rubygems
|
data/Gemfile
CHANGED
@@ -3,26 +3,27 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in middleman-blog-similar.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
|
7
|
-
gem '
|
8
|
-
gem 'capybara', '~> 2.
|
9
|
-
gem 'codeclimate-test-reporter', '~> 1.0', require: false
|
10
|
-
gem 'coveralls', require: false
|
11
|
-
gem 'cucumber', '~> 2.0', require: false
|
12
|
-
gem 'engtagger'
|
13
|
-
gem 'guard-cucumber'
|
14
|
-
gem 'guard-rake'
|
15
|
-
gem 'guard-rspec'
|
16
|
-
gem 'guard-rubocop', require: false
|
17
|
-
gem 'middleman-cli', '>= 4.0.0'
|
18
|
-
gem 'natto', '~> 1.1'
|
19
|
-
gem 'pry', '~> 0.10',
|
20
|
-
gem 'rack', '~> 1.6.5', require: false
|
21
|
-
gem 'rake', '~>
|
22
|
-
gem 'redcarpet'
|
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
|
6
|
+
group :development do
|
7
|
+
gem 'aruba', '~> 0.7.4', require: false
|
8
|
+
gem 'capybara', '~> 2.13.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'
|
13
|
+
gem 'guard-cucumber'
|
14
|
+
gem 'guard-rake'
|
15
|
+
gem 'guard-rspec'
|
16
|
+
gem 'guard-rubocop', require: false
|
17
|
+
gem 'middleman-cli', '>= 4.0.0'
|
18
|
+
gem 'natto', '~> 1.1'
|
19
|
+
gem 'pry', '~> 0.10', require: false
|
20
|
+
gem 'rack', '~> 1.6.5', require: false
|
21
|
+
gem 'rake', '~> 12.0', require: false
|
22
|
+
gem 'redcarpet'
|
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.9.8', require: false
|
29
|
+
end
|
data/Rakefile
CHANGED
@@ -42,7 +42,9 @@ module Middleman
|
|
42
42
|
article = Article.find_or_create_by(page_id: page_id)
|
43
43
|
new_tagging_ids = []
|
44
44
|
@taggers.each do |tagger|
|
45
|
-
tagger[1].call
|
45
|
+
tags = tagger[1].call resource
|
46
|
+
tags = [tags] unless tags.is_a?(Array)
|
47
|
+
tags.map(&:downcase).each do |tag_name|
|
46
48
|
tag = Tag.find_or_create_by name: tag_name
|
47
49
|
tagging = Tagging.find_or_create_by tag_id: tag.id, article_id: article.id
|
48
50
|
tagging.weight = tagger[0]
|
@@ -62,7 +64,7 @@ module Middleman
|
|
62
64
|
return [] unless article
|
63
65
|
article.similar_article_page_ids.map do |page_id|
|
64
66
|
@id_map[page_id]
|
65
|
-
end
|
67
|
+
end.select(&:present?)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
@@ -22,10 +22,10 @@ describe Middleman::Blog::SimilarExtension do
|
|
22
22
|
describe 'results' do
|
23
23
|
subject { resource.similar_articles.map { |a| [a.page_id, a.data.category || '<none>'].concat a.tags } }
|
24
24
|
it { is_expected.to have(4).items }
|
25
|
-
its([0]) { is_expected.to eq %w
|
26
|
-
its([1]) { is_expected.to eq %w
|
27
|
-
its([2]) { is_expected.to eq %w
|
28
|
-
its([3]) { is_expected.to eq %w
|
25
|
+
its([0]) { is_expected.to eq %w[2014-05-14-article6 <none> dog Brown cat] }
|
26
|
+
its([1]) { is_expected.to eq %w[2014-05-12-article4 <none> dog cat fox] }
|
27
|
+
its([2]) { is_expected.to eq %w[2014-05-09-article1 test dog cat] }
|
28
|
+
its([3]) { is_expected.to eq %w[2014-05-13-article5 <none> dog] }
|
29
29
|
context 'when configured with weight map' do
|
30
30
|
before :all do
|
31
31
|
@app = middleman_app('test-app') do
|
@@ -38,10 +38,10 @@ describe Middleman::Blog::SimilarExtension do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
it { is_expected.to have(4).items }
|
41
|
-
its([0]) { is_expected.to eq %w
|
42
|
-
its([1]) { is_expected.to eq %w
|
43
|
-
its([2]) { is_expected.to eq %w
|
44
|
-
its([3]) { is_expected.to eq %w
|
41
|
+
its([0]) { is_expected.to eq %w[2014-05-09-article1 test dog cat] }
|
42
|
+
its([1]) { is_expected.to eq %w[2014-05-14-article6 <none> dog Brown cat] }
|
43
|
+
its([2]) { is_expected.to eq %w[2014-05-12-article4 <none> dog cat fox] }
|
44
|
+
its([3]) { is_expected.to eq %w[2014-05-13-article5 <none> dog] }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -7,18 +7,18 @@ describe 'tagger' do
|
|
7
7
|
let(:page_id) { '2014-05-08-article0' }
|
8
8
|
subject { described_class.new.call resource }
|
9
9
|
describe ::Middleman::Blog::Similar::Tagger::Tags do
|
10
|
-
it { is_expected.to eq %w
|
10
|
+
it { is_expected.to eq %w[dog cat brown] }
|
11
11
|
end
|
12
12
|
describe ::Middleman::Blog::Similar::Tagger::Mecab do
|
13
13
|
let(:page_id) { '2014-05-11-article3' }
|
14
|
-
it { is_expected.to eq %w
|
14
|
+
it { is_expected.to eq %w[叫び 悪口 教師 西洋 尻 時分 坊ちゃん 国家 この世 人間 国家 隙] }
|
15
15
|
context 'written in English' do
|
16
16
|
let(:page_id) { '2014-05-10-article2' }
|
17
|
-
it { is_expected.to eq %w
|
17
|
+
it { is_expected.to eq %w[quick brown fox jumps over the lazy dog dog dog] }
|
18
18
|
end
|
19
19
|
end
|
20
20
|
describe ::Middleman::Blog::Similar::Tagger::Entagger do
|
21
21
|
let(:page_id) { '2014-05-10-article2' }
|
22
|
-
it { is_expected.to eq %w
|
22
|
+
it { is_expected.to eq %w[fox jumps dog] }
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-blog-similar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atsushi Nagase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -93,6 +93,7 @@ executables: []
|
|
93
93
|
extensions: []
|
94
94
|
extra_rdoc_files: []
|
95
95
|
files:
|
96
|
+
- ".codeclimate.yml"
|
96
97
|
- ".gitignore"
|
97
98
|
- ".rspec"
|
98
99
|
- ".rubocop.yml"
|