middleman-robots 1.3.2 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'middleman-robots/generators/blocks'
4
+
5
+ RSpec.describe Middleman::Robots::Generators::Blocks do
6
+ describe '#text' do
7
+ subject { described_class.new(rules).text }
8
+
9
+ context 'with all options' do
10
+ let(:rules) do
11
+ [
12
+ {
13
+ user_agent: 'GoogleBot',
14
+ disallow: %w[tmp/* /someting/dir/disallow.html],
15
+ allow: %w[allow/* /someting/dir/allow.html]
16
+ },
17
+ {
18
+ user_agent: 'GoogleBot-Image',
19
+ disallow: %w[tmp/* /someting/dir/disallow.html],
20
+ allow: %w[allow/* /someting/dir/allow.html]
21
+ }
22
+ ]
23
+ end
24
+ let(:expected) do
25
+ expected = <<~ROBOTS
26
+ User-Agent: GoogleBot
27
+ Disallow: /tmp/*
28
+ Disallow: /someting/dir/disallow.html
29
+ Allow: /allow/*
30
+ Allow: /someting/dir/allow.html
31
+
32
+ User-Agent: GoogleBot-Image
33
+ Disallow: /tmp/*
34
+ Disallow: /someting/dir/disallow.html
35
+ Allow: /allow/*
36
+ Allow: /someting/dir/allow.html
37
+ ROBOTS
38
+ expected.chomp
39
+ end
40
+
41
+ it { is_expected.to eq expected }
42
+ end
43
+
44
+ context 'without option' do
45
+ let(:rules) { {} }
46
+
47
+ it { is_expected.to be_nil }
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'middleman-robots/generators/sitemap_uri'
4
+
5
+ RSpec.describe Middleman::Robots::Generators::SitemapUri do
6
+ describe '#text' do
7
+ subject { described_class.new(uri).text }
8
+
9
+ context 'with uri value is' do
10
+ context 'URL String' do
11
+ let(:uri) { 'https://example.com/sitemap.xml' }
12
+
13
+ it { is_expected.to eq "Sitemap: #{uri}" }
14
+ end
15
+
16
+ context 'nil' do
17
+ let(:uri) { nil }
18
+
19
+ it { is_expected.to be_nil }
20
+ end
21
+
22
+ context 'empty' do
23
+ let(:uri) { '' }
24
+
25
+ it { is_expected.to be_nil }
26
+ end
27
+
28
+ context 'ERROR when' do
29
+ subject { -> { described_class.new(rule).text } }
30
+
31
+ context 'Array' do
32
+ let(:rule) { { uri: %w[a b] } }
33
+
34
+ it { is_expected.to raise_error ArgumentError }
35
+ end
36
+
37
+ context 'Numeric' do
38
+ let(:rule) { { uri: 1_000 } }
39
+
40
+ it { is_expected.to raise_error ArgumentError }
41
+ end
42
+
43
+ context 'Symbol' do
44
+ let(:rule) { { uri: :uri } }
45
+
46
+ it { is_expected.to raise_error ArgumentError }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with :rspec do |expectations|
5
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
6
+ end
7
+
8
+ config.mock_with :rspec do |mocks|
9
+ mocks.verify_partial_doubles = true
10
+ end
11
+
12
+ config.shared_context_metadata_behavior = :apply_to_host_groups
13
+ end
metadata CHANGED
@@ -1,22 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-robots
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuya Matsushima
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-09 00:00:00.000000000 Z
11
+ date: 2021-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: middleman
14
+ name: middleman-cli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: '4.4'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,90 +27,146 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '4.0'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '4.4'
27
33
  - !ruby/object:Gem::Dependency
28
- name: cucumber
34
+ name: middleman-core
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '1.3'
39
+ version: '4.0'
40
+ - - "<="
41
+ - !ruby/object:Gem::Version
42
+ version: '4.4'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '4.0'
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: '4.4'
53
+ - !ruby/object:Gem::Dependency
54
+ name: aruba
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.14.3
34
60
  type: :development
35
61
  prerelease: false
36
62
  version_requirements: !ruby/object:Gem::Requirement
37
63
  requirements:
38
64
  - - ">="
39
65
  - !ruby/object:Gem::Version
40
- version: '1.3'
66
+ version: 0.14.3
41
67
  - !ruby/object:Gem::Dependency
42
- name: capybara
68
+ name: bundler
43
69
  requirement: !ruby/object:Gem::Requirement
44
70
  requirements:
45
- - - "~>"
71
+ - - ">="
46
72
  - !ruby/object:Gem::Version
47
- version: 2.5.0
73
+ version: '1.16'
48
74
  type: :development
49
75
  prerelease: false
50
76
  version_requirements: !ruby/object:Gem::Requirement
51
77
  requirements:
52
- - - "~>"
78
+ - - ">="
53
79
  - !ruby/object:Gem::Version
54
- version: 2.5.0
80
+ version: '1.16'
55
81
  - !ruby/object:Gem::Dependency
56
- name: aruba
82
+ name: capybara
57
83
  requirement: !ruby/object:Gem::Requirement
58
84
  requirements:
59
85
  - - ">="
60
86
  - !ruby/object:Gem::Version
61
- version: '0.6'
87
+ version: 2.18.0
62
88
  type: :development
63
89
  prerelease: false
64
90
  version_requirements: !ruby/object:Gem::Requirement
65
91
  requirements:
66
92
  - - ">="
67
93
  - !ruby/object:Gem::Version
68
- version: '0.6'
94
+ version: 2.18.0
69
95
  - !ruby/object:Gem::Dependency
70
- name: bundler
96
+ name: cucumber
71
97
  requirement: !ruby/object:Gem::Requirement
72
98
  requirements:
73
99
  - - ">="
74
100
  - !ruby/object:Gem::Version
75
- version: '1.5'
101
+ version: 3.1.0
76
102
  type: :development
77
103
  prerelease: false
78
104
  version_requirements: !ruby/object:Gem::Requirement
79
105
  requirements:
80
106
  - - ">="
81
107
  - !ruby/object:Gem::Version
82
- version: '1.5'
108
+ version: 3.1.0
83
109
  - !ruby/object:Gem::Dependency
84
110
  name: rake
85
111
  requirement: !ruby/object:Gem::Requirement
86
112
  requirements:
87
113
  - - ">="
88
114
  - !ruby/object:Gem::Version
89
- version: '10'
115
+ version: '12.3'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '12.3'
123
+ - !ruby/object:Gem::Dependency
124
+ name: rspec
125
+ requirement: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ type: :development
131
+ prerelease: false
132
+ version_requirements: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: rubocop
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 0.52.1
90
144
  type: :development
91
145
  prerelease: false
92
146
  version_requirements: !ruby/object:Gem::Requirement
93
147
  requirements:
94
148
  - - ">="
95
149
  - !ruby/object:Gem::Version
96
- version: '10'
97
- description: Generate robots.txt by config.rb.
150
+ version: 0.52.1
151
+ description: middleman-robots create robots.txt includes Allow or Disallow and sitemap
152
+ path.
98
153
  email:
99
154
  - terra@e2esound.com
100
155
  executables: []
101
156
  extensions: []
102
157
  extra_rdoc_files: []
103
158
  files:
159
+ - ".github/workflows/ci.yml"
104
160
  - ".gitignore"
161
+ - ".rspec"
162
+ - ".rubocop.yml"
105
163
  - ".travis.yml"
106
164
  - Gemfile
107
165
  - LICENSE.txt
108
166
  - README.jp.md
109
167
  - README.md
110
168
  - Rakefile
169
+ - cucumber.yml
111
170
  - features/build.feature
112
171
  - features/server.feature
113
172
  - features/support/env.rb
@@ -119,18 +178,23 @@ files:
119
178
  - lib/middleman-robots.rb
120
179
  - lib/middleman-robots/extension.rb
121
180
  - lib/middleman-robots/generator.rb
122
- - lib/middleman-robots/group.rb
181
+ - lib/middleman-robots/generators/block.rb
182
+ - lib/middleman-robots/generators/blocks.rb
183
+ - lib/middleman-robots/generators/sitemap_uri.rb
123
184
  - lib/middleman-robots/version.rb
124
185
  - lib/middleman_extension.rb
125
186
  - middleman-robots.gemspec
126
- - tests/test_generator.rb
127
- - tests/test_group.rb
187
+ - spec/lib/middleman-robots/generator_spec.rb
188
+ - spec/lib/middleman-robots/generators/block_spec.rb
189
+ - spec/lib/middleman-robots/generators/blocks_spec.rb
190
+ - spec/lib/middleman-robots/generators/sitemap_uri_spec.rb
191
+ - spec/spec_helper.rb
128
192
  - tmp/robots/.gitkeep
129
193
  homepage: https://github.com/yterajima/middleman-robots
130
194
  licenses:
131
195
  - MIT
132
196
  metadata: {}
133
- post_install_message:
197
+ post_install_message:
134
198
  rdoc_options: []
135
199
  require_paths:
136
200
  - lib
@@ -138,19 +202,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
202
  requirements:
139
203
  - - ">="
140
204
  - !ruby/object:Gem::Version
141
- version: 2.0.0
205
+ version: 2.6.0
142
206
  required_rubygems_version: !ruby/object:Gem::Requirement
143
207
  requirements:
144
208
  - - ">="
145
209
  - !ruby/object:Gem::Version
146
210
  version: '0'
147
211
  requirements: []
148
- rubyforge_project:
149
- rubygems_version: 2.6.11
150
- signing_key:
212
+ rubygems_version: 3.2.22
213
+ signing_key:
151
214
  specification_version: 4
152
215
  summary: Generate robots.txt by config.rb.
153
216
  test_files:
154
217
  - features/build.feature
155
218
  - features/server.feature
156
219
  - features/support/env.rb
220
+ - spec/lib/middleman-robots/generator_spec.rb
221
+ - spec/lib/middleman-robots/generators/block_spec.rb
222
+ - spec/lib/middleman-robots/generators/blocks_spec.rb
223
+ - spec/lib/middleman-robots/generators/sitemap_uri_spec.rb
224
+ - spec/spec_helper.rb
@@ -1,50 +0,0 @@
1
- module Middleman
2
- module Robots
3
- # Robots Group Class
4
- #
5
- # Group class generate block in robots.txt
6
- class Group
7
- attr_reader :user_agent, :disallow, :allow
8
-
9
- def initialize(rule)
10
- @user_agent = generate_user_agent(rule)
11
- @disallow = generate_disallow(rule)
12
- @allow = generate_allow(rule)
13
- end
14
-
15
- def text
16
- group = []
17
- group << "User-Agent: #{@user_agent}" unless @user_agent.empty?
18
- group << @disallow.collect{|item| "Disallow: #{item}" }.join("\n") if @disallow.length > 0
19
- group << @allow.collect{|item| "Allow: #{item}" }.join("\n") if @allow.length > 0
20
- group.join("\n") + "\n"
21
- end
22
-
23
- private
24
- def generate_user_agent(rule)
25
- return '*' unless rule.key?('user-agent') || rule.key?(:user_agent)
26
- rule[:user_agent] || rule['user-agent']
27
- end
28
-
29
- def generate_disallow(rule)
30
- paths = []
31
- return paths unless rule.has_key?(:disallow)
32
-
33
- rule[:disallow].each do |path|
34
- paths << File.join('/', path)
35
- end
36
- paths
37
- end
38
-
39
- def generate_allow(rule)
40
- paths = []
41
- return paths unless rule.has_key?(:allow)
42
-
43
- rule[:allow].each do |path|
44
- paths << File.join('/', path)
45
- end
46
- paths
47
- end
48
- end
49
- end
50
- end
@@ -1,37 +0,0 @@
1
- require 'minitest/autorun'
2
- require_relative '../lib/middleman-robots/generator.rb'
3
-
4
- class Test_Generator < MiniTest::Test
5
- def test_process
6
- rules = [
7
- {
8
- user_agent: 'Googlebot',
9
- disallow: %w(tmp/* /something/dir/file_disallow.html),
10
- allow: %w(allow/* /something/dir/file_allow.html)
11
- },
12
- {
13
- user_agent: 'Googlebot-Image',
14
- disallow: %w(tmp/* /something/dir/file_disallow.html),
15
- allow: %w(allow/* /something/dir/file_allow.html)
16
- }
17
- ]
18
- sitemap_uri = 'http://example.com/sitemap.xml'
19
- generator = Middleman::Robots::Generator.new(rules, sitemap_uri)
20
-
21
- expected = "User-Agent: Googlebot
22
- Disallow: /tmp/*
23
- Disallow: /something/dir/file_disallow.html
24
- Allow: /allow/*
25
- Allow: /something/dir/file_allow.html
26
-
27
- User-Agent: Googlebot-Image
28
- Disallow: /tmp/*
29
- Disallow: /something/dir/file_disallow.html
30
- Allow: /allow/*
31
- Allow: /something/dir/file_allow.html
32
-
33
- Sitemap: http://example.com/sitemap.xml"
34
-
35
- assert_equal expected, generator.process
36
- end
37
- end