sitepress-rails 1.0.1 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,6 @@ describe "Sitepress.configuration" do
8
8
  before do
9
9
  app.config.eager_load = cache_classes # WTF?
10
10
  end
11
- it "has site" do
12
- app.initialize!
13
- expect(subject.site.root_path).to eql(app.root.join("app/content"))
14
- end
15
11
  it "has Rails.application as parent engine" do
16
12
  app.initialize!
17
13
  expect(subject.parent_engine).to eql(app)
@@ -43,24 +39,4 @@ describe "Sitepress.configuration" do
43
39
  end
44
40
  end
45
41
  end
46
- context "Rails.configuration.paths" do
47
- subject { Rails.configuration.paths[path].to_a }
48
- context "views" do
49
- let(:path) { "app/views" }
50
- it { should include(app.root.join("app/content").to_s) }
51
- end
52
- context "helpers" do
53
- let(:path) { "app/helpers" }
54
- it { should include(app.root.join("app/content/helpers").to_s) }
55
- end
56
- context "assets" do
57
- let(:path) { "app/assets" }
58
- it { should include(app.root.join("app/content/assets").to_s) }
59
- end
60
- end
61
- context "#partals" do
62
- it "excludes partials" do
63
- expect(subject.site.resources.size).to eql(2)
64
- end
65
- end
66
- end
42
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+ require "tmpdir"
3
+ require "fileutils"
4
+
5
+ describe Sitepress::Compiler do
6
+ let(:site) { Sitepress.site }
7
+ let(:target) { Pathname.new(Dir::tmpdir).join("build") }
8
+ # Write compiler output to /dev/null so our test output remains clean.
9
+ let(:stdout) { File.open(File::NULL, "w") }
10
+ subject { Sitepress::Compiler.new(site: site, stdout: stdout) }
11
+ describe "#compile" do
12
+ before { FileUtils.mkdir_p(target) }
13
+ after { FileUtils.rm_rf(target) }
14
+ it "writes files to target" do
15
+ subject.compile(target_path: target)
16
+ expect(Dir.glob(target.join("**")).size).to eql(2) # 2 items in the site... mkay?
17
+ end
18
+ end
19
+ end
@@ -10,10 +10,12 @@ describe Sitepress::SiteController, type: :controller do
10
10
  end
11
11
  end
12
12
 
13
+ let(:site) { Sitepress.configuration.site }
14
+
13
15
  context "templated page" do
14
16
  render_views
15
17
  before { get_resource "/time" }
16
- let(:resource) { Sitepress.site.get("/time") }
18
+ let(:resource) { site.get("/time") }
17
19
  it "is status 200" do
18
20
  expect(response.status).to eql(200)
19
21
  end
@@ -24,7 +26,7 @@ describe Sitepress::SiteController, type: :controller do
24
26
  expect(response.body).to include("<title>Test layout</title>")
25
27
  end
26
28
  it "responds with content type" do
27
- expect(response.content_type).to eql("text/html")
29
+ expect(response.content_type).to include("text/html")
28
30
  end
29
31
  context "helper methods" do
30
32
  subject { @controller }
@@ -32,7 +34,7 @@ describe Sitepress::SiteController, type: :controller do
32
34
  expect(subject.send(:current_page).asset.path).to eql(resource.asset.path)
33
35
  end
34
36
  it "#site" do
35
- expect(subject.send(:site)).to eql(Sitepress.site)
37
+ expect(subject.send(:site)).to eql(site)
36
38
  end
37
39
  end
38
40
  end
@@ -46,11 +48,11 @@ describe Sitepress::SiteController, type: :controller do
46
48
  it "renders body" do
47
49
  expect(response.body).to include("<h1>Hi!</h1>")
48
50
  end
49
- it "renders layout" do
50
- expect(response.body).to include("<title>Dummy</title>")
51
+ it "does not render layout" do
52
+ expect(response.body).to_not include("<title>Dummy</title>")
51
53
  end
52
54
  it "responds with content type" do
53
- expect(response.content_type).to eql("text/html")
55
+ expect(response.content_type).to include("text/html")
54
56
  end
55
57
  end
56
58
 
@@ -62,25 +64,40 @@ describe Sitepress::SiteController, type: :controller do
62
64
  end
63
65
  end
64
66
 
67
+ context "paths" do
68
+ context "view_paths" do
69
+ subject { Sitepress::SiteController.view_paths.map(&:path) }
70
+ it { is_expected.to include(site.root_path.to_s) }
71
+ it { is_expected.to include(site.pages_path.to_s) }
72
+ end
73
+ context "helper_paths" do
74
+ subject{ Sitepress::SiteController.helpers_path }
75
+ it { is_expected.to include(site.helpers_path.to_s) }
76
+ it "has site#helper_paths in ActiveSupport::Dependencies.autoload_paths" do
77
+ expect(ActiveSupport::Dependencies.autoload_paths).to include(site.helpers_path.to_s)
78
+ end
79
+ end
80
+ end
81
+
65
82
  context "render cache" do
66
83
  context "cache_resources=true" do
67
- before { Sitepress.site.cache_resources = true }
84
+ before { site.cache_resources = true }
68
85
  it "enables cache" do
69
- expect(Sitepress.site.cache_resources).to be true
70
- expect(Sitepress.site).to receive(:cache_resources=).with(true)
71
- expect(Sitepress.site).to receive(:cache_resources=).with(true)
86
+ expect(site.cache_resources).to be true
87
+ expect(site).to receive(:cache_resources=).with(true)
88
+ expect(site).to receive(:cache_resources=).with(true)
72
89
  get_resource "/time"
73
- expect(Sitepress.site.cache_resources).to be true
90
+ expect(site.cache_resources).to be true
74
91
  end
75
92
  end
76
93
  context "cache_resources=false" do
77
- before { Sitepress.site.cache_resources = false }
94
+ before { site.cache_resources = false }
78
95
  it "enables cache" do
79
- expect(Sitepress.site.cache_resources).to be false
80
- expect(Sitepress.site).to receive(:cache_resources=).with(true)
81
- expect(Sitepress.site).to receive(:cache_resources=).with(false)
96
+ expect(site.cache_resources).to be false
97
+ expect(site).to receive(:cache_resources=).with(true)
98
+ expect(site).to receive(:cache_resources=).with(false)
82
99
  get_resource "/time"
83
- expect(Sitepress.site.cache_resources).to be false
100
+ expect(site.cache_resources).to be false
84
101
  end
85
102
  end
86
103
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitepress-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-22 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-rails
@@ -45,7 +45,7 @@ dependencies:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
- type: :runtime
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
@@ -58,15 +58,57 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.1
61
+ version: 2.0.0.beta1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.1
69
- description:
68
+ version: 2.0.0.beta1
69
+ - !ruby/object:Gem::Dependency
70
+ name: railties
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: actionpack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sprockets-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 2.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.0.0
111
+ description:
70
112
  email:
71
113
  - bradgessler@gmail.com
72
114
  executables: []
@@ -77,16 +119,17 @@ files:
77
119
  - Rakefile
78
120
  - app/controllers/concerns/sitepress/site_pages.rb
79
121
  - app/controllers/sitepress/site_controller.rb
80
- - app/helpers/sitepress/application_helper.rb
81
122
  - config/routes.rb
82
123
  - lib/sitepress-rails.rb
124
+ - lib/sitepress/build_paths/directory_index_path.rb
125
+ - lib/sitepress/build_paths/index_path.rb
126
+ - lib/sitepress/build_paths/root_path.rb
127
+ - lib/sitepress/compiler.rb
83
128
  - lib/sitepress/engine.rb
84
- - lib/sitepress/extensions/index_request_path.rb
85
- - lib/sitepress/extensions/partials_remover.rb
86
- - lib/sitepress/extensions/rails_request_paths.rb
87
129
  - lib/sitepress/rails.rb
88
130
  - lib/sitepress/rails_configuration.rb
89
- - lib/sitepress/rails_configuration.rb.orig
131
+ - lib/sitepress/renderers/controller.rb
132
+ - lib/sitepress/renderers/server.rb
90
133
  - lib/sitepress/route_constraint.rb
91
134
  - lib/tasks/sitepress_tasks.rake
92
135
  - spec/dummy/Rakefile
@@ -138,9 +181,6 @@ files:
138
181
  - spec/dummy/config/routes.rb
139
182
  - spec/dummy/config/secrets.yml
140
183
  - spec/dummy/config/spring.rb
141
- - spec/dummy/db/production.sqlite3
142
- - spec/dummy/db/test.sqlite3
143
- - spec/dummy/log/production.log
144
184
  - spec/dummy/log/test.log
145
185
  - spec/dummy/public/404.html
146
186
  - spec/dummy/public/422.html
@@ -149,9 +189,7 @@ files:
149
189
  - spec/dummy/public/apple-touch-icon.png
150
190
  - spec/dummy/public/favicon.ico
151
191
  - spec/sitepress-rails_spec.rb
152
- - spec/sitepress/extensions/index_request_path_spec.rb
153
- - spec/sitepress/extensions/partials_remover_spec.rb
154
- - spec/sitepress/extensions/rails_request_paths_spec.rb
192
+ - spec/sitepress/compiler_spec.rb
155
193
  - spec/sitepress/rails_configuration_spec.rb
156
194
  - spec/sitepress/route_constraint_spec.rb
157
195
  - spec/sitepress/routes_spec.rb
@@ -166,7 +204,7 @@ files:
166
204
  homepage: https://github.com/sitepress/sitepress
167
205
  licenses: []
168
206
  metadata: {}
169
- post_install_message:
207
+ post_install_message:
170
208
  rdoc_options: []
171
209
  require_paths:
172
210
  - lib
@@ -177,86 +215,81 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
215
  version: '0'
178
216
  required_rubygems_version: !ruby/object:Gem::Requirement
179
217
  requirements:
180
- - - ">="
218
+ - - ">"
181
219
  - !ruby/object:Gem::Version
182
- version: '0'
220
+ version: 1.3.1
183
221
  requirements: []
184
- rubygems_version: 3.1.2
185
- signing_key:
222
+ rubygems_version: 3.2.3
223
+ signing_key:
186
224
  specification_version: 4
187
225
  summary: Sitepress rails integration.
188
226
  test_files:
189
- - spec/spec_helper.rb
190
- - spec/sitepress-rails_spec.rb
191
- - spec/dummy/app/mailers/application_mailer.rb
227
+ - spec/dummy/Rakefile
228
+ - spec/dummy/app/assets/config/manifest.js
229
+ - spec/dummy/app/assets/javascripts/application.js
230
+ - spec/dummy/app/assets/javascripts/cable.js
231
+ - spec/dummy/app/assets/stylesheets/application.css
232
+ - spec/dummy/app/content/helpers/sample_helper.rb
192
233
  - spec/dummy/app/content/layouts/sitepress_test_layout.html.erb
193
- - spec/dummy/app/content/pages/time.html.erb
194
234
  - spec/dummy/app/content/pages/_stupid.html.erb
195
235
  - spec/dummy/app/content/pages/hi.html
196
236
  - spec/dummy/app/content/pages/partials/_really_stupid.html.erb
197
- - spec/dummy/app/content/helpers/sample_helper.rb
198
- - spec/dummy/app/jobs/application_job.rb
237
+ - spec/dummy/app/content/pages/time.html.erb
199
238
  - spec/dummy/app/controllers/application_controller.rb
200
239
  - spec/dummy/app/controllers/baseline_controller.rb
240
+ - spec/dummy/app/helpers/application_helper.rb
241
+ - spec/dummy/app/jobs/application_job.rb
242
+ - spec/dummy/app/mailers/application_mailer.rb
201
243
  - spec/dummy/app/views/baseline/show.html.erb
202
244
  - spec/dummy/app/views/layouts/application.html.erb
203
245
  - spec/dummy/app/views/layouts/mailer.html.erb
204
246
  - spec/dummy/app/views/layouts/mailer.text.erb
205
- - spec/dummy/app/assets/config/manifest.js
206
- - spec/dummy/app/assets/javascripts/cable.js
207
- - spec/dummy/app/assets/javascripts/application.js
208
- - spec/dummy/app/assets/stylesheets/application.css
209
- - spec/dummy/app/helpers/application_helper.rb
210
- - spec/dummy/bin/update
211
- - spec/dummy/bin/rake
212
- - spec/dummy/bin/setup
213
247
  - spec/dummy/bin/bundle
214
248
  - spec/dummy/bin/rails
215
- - spec/dummy/config/secrets.yml
216
- - spec/dummy/config/routes.rb
217
- - spec/dummy/config/locales/en.yml
249
+ - spec/dummy/bin/rake
250
+ - spec/dummy/bin/setup
251
+ - spec/dummy/bin/update
252
+ - spec/dummy/config/application.rb
253
+ - spec/dummy/config/boot.rb
218
254
  - spec/dummy/config/cable.yml
219
- - spec/dummy/config/environments/production.rb
255
+ - spec/dummy/config/database.yml
256
+ - spec/dummy/config/environment.rb
220
257
  - spec/dummy/config/environments/development.rb
258
+ - spec/dummy/config/environments/production.rb
221
259
  - spec/dummy/config/environments/test.rb
222
- - spec/dummy/config/spring.rb
223
- - spec/dummy/config/environment.rb
224
- - spec/dummy/config/application.rb
225
- - spec/dummy/config/puma.rb
226
- - spec/dummy/config/database.yml
227
- - spec/dummy/config/boot.rb
228
260
  - spec/dummy/config/initializers/application_controller_renderer.rb
261
+ - spec/dummy/config/initializers/assets.rb
229
262
  - spec/dummy/config/initializers/backtrace_silencers.rb
230
- - spec/dummy/config/initializers/null_logger.rb
231
- - spec/dummy/config/initializers/mime_types.rb
263
+ - spec/dummy/config/initializers/cookies_serializer.rb
232
264
  - spec/dummy/config/initializers/filter_parameter_logging.rb
265
+ - spec/dummy/config/initializers/inflections.rb
266
+ - spec/dummy/config/initializers/mime_types.rb
267
+ - spec/dummy/config/initializers/null_logger.rb
233
268
  - spec/dummy/config/initializers/session_store.rb
234
269
  - spec/dummy/config/initializers/wrap_parameters.rb
235
- - spec/dummy/config/initializers/assets.rb
236
- - spec/dummy/config/initializers/cookies_serializer.rb
237
- - spec/dummy/config/initializers/inflections.rb
270
+ - spec/dummy/config/locales/en.yml
271
+ - spec/dummy/config/puma.rb
272
+ - spec/dummy/config/routes.rb
273
+ - spec/dummy/config/secrets.yml
274
+ - spec/dummy/config/spring.rb
238
275
  - spec/dummy/config.ru
239
- - spec/dummy/Rakefile
240
- - spec/dummy/public/favicon.ico
276
+ - spec/dummy/log/test.log
277
+ - spec/dummy/public/404.html
241
278
  - spec/dummy/public/422.html
242
- - spec/dummy/public/apple-touch-icon.png
243
279
  - spec/dummy/public/500.html
244
- - spec/dummy/public/404.html
245
280
  - spec/dummy/public/apple-touch-icon-precomposed.png
246
- - spec/dummy/db/production.sqlite3
247
- - spec/dummy/db/test.sqlite3
248
- - spec/dummy/log/test.log
249
- - spec/dummy/log/production.log
281
+ - spec/dummy/public/apple-touch-icon.png
282
+ - spec/dummy/public/favicon.ico
283
+ - spec/sitepress/compiler_spec.rb
284
+ - spec/sitepress/rails_configuration_spec.rb
285
+ - spec/sitepress/route_constraint_spec.rb
286
+ - spec/sitepress/routes_spec.rb
287
+ - spec/sitepress/sitepress_site_controller_spec.rb
288
+ - spec/sitepress-rails_spec.rb
250
289
  - spec/sites/sample/pages/index.html.erb
251
- - spec/sites/sample/pages/test.html.haml
290
+ - spec/sites/sample/pages/nothing
252
291
  - spec/sites/sample/pages/sin_frontmatter.html.haml
253
292
  - spec/sites/sample/pages/super.duper/index.html
254
- - spec/sites/sample/pages/nothing
293
+ - spec/sites/sample/pages/test.html.haml
255
294
  - spec/sites/sample/pages/text.txt
256
- - spec/sitepress/extensions/rails_request_paths_spec.rb
257
- - spec/sitepress/extensions/partials_remover_spec.rb
258
- - spec/sitepress/extensions/index_request_path_spec.rb
259
- - spec/sitepress/sitepress_site_controller_spec.rb
260
- - spec/sitepress/rails_configuration_spec.rb
261
- - spec/sitepress/routes_spec.rb
262
- - spec/sitepress/route_constraint_spec.rb
295
+ - spec/spec_helper.rb
@@ -1,4 +0,0 @@
1
- module Sitepress
2
- module ApplicationHelper
3
- end
4
- end
@@ -1,24 +0,0 @@
1
- module Sitepress
2
- module Extensions
3
- # Removes files beginning with "_" from the resource collection.
4
- class IndexRequestPath
5
- # Name of the file that we'll want to change to a / path
6
- FILE_NAME = "index.html".freeze
7
-
8
- def initialize(file_name: FILE_NAME)
9
- @file_name = file_name
10
- end
11
-
12
- def process_resources(node)
13
- node.flatten.each do |r|
14
- asset = r.asset
15
- if asset.path.basename.to_s.start_with? @file_name
16
- request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s
17
- node.formats.remove(r)
18
- node.add(path: request_path, asset: asset)
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end