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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4791e37639ec38d3703d84e25feb40184997097
4
- data.tar.gz: 11982f6b235436a28ce0addd868d918f90f0f0e8
3
+ metadata.gz: 4ca4ea19f11faace7ebb481d6f404ba32b3f8b92
4
+ data.tar.gz: a806d24fd4486f358ba71e927f3a4d34d63a92c6
5
5
  SHA512:
6
- metadata.gz: ddef1dfc312319c7907069f11af08ee47dd382df4ac727e24009d3be05b4f60e46b6773a01f3de30707abaad7c401c12596146554662818a4aad4235a7a40bfa
7
- data.tar.gz: 61b841719e5338f447912fbf0c804a04f29cead34be5013e66f2a0502e53ccf18f282cdcc931725d77707099e4d59013dcfede5f8a7e1b7e66010f21a3eff115
6
+ metadata.gz: ab468137e22f2497b171a3a7e656996f33edce4c3ed12cf4454054201b9eeec27fe23a7393ade8b86e4c437a1d49b7e0a8be32cea94159bbc65599130befa4d5
7
+ data.tar.gz: 8985d7a877611d167f8f1711b5f6658249f2037b0c5d96a21d413371960f4c8caf9a477a45a9c923a753d97678cddbb561dddf238a5d74eb624115f011ff0950
@@ -0,0 +1,3 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: false
@@ -6,7 +6,9 @@ env:
6
6
  global:
7
7
  - TEST=true
8
8
  before_install:
9
- - curl -L https://git.io/vSUUX | bash
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
- 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'
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', group: :development, require: false
20
- gem 'rack', '~> 1.6.5', require: false
21
- gem 'rake', '~> 10.1.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.8.0', require: false
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
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  require 'rake/clean'
18
18
 
19
- task test: %w(rubocop spec cucumber)
19
+ task test: %w[rubocop spec cucumber]
20
20
 
21
21
  begin
22
22
  require 'cane/rake_task'
@@ -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(resource).map(&:downcase).each do |tag_name|
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
@@ -1,7 +1,7 @@
1
1
  module Middleman
2
2
  module Blog
3
3
  module Similar
4
- VERSION = '2.0.0'.freeze
4
+ VERSION = '2.0.1'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  $LOAD_PATH.push File.expand_path('../lib', __FILE__)
3
4
  require 'middleman-blog-similar/version'
4
5
 
@@ -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(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) }
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(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) }
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(dog cat brown) }
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(quick brown fox jumps over the lazy dog dog dog) }
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(fox jumps dog) }
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.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-03-24 00:00:00.000000000 Z
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"