sitespec 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9fc89ff9faa0578468ba10193d3c0ce7503a2c9
4
- data.tar.gz: 5de14be6b1383849c8027a460eb1a6815be8f239
3
+ metadata.gz: aebce21985d8078df2ad1316e59c50af7875aa0c
4
+ data.tar.gz: 6d1876b3790b7a3c23b8494f91a63bd139a92d79
5
5
  SHA512:
6
- metadata.gz: 0dcf588bd912f06ec9a57677e76ac66684fcd8afbb91de6f1d8e097bec25dcde54b53bbc75cc90d425c903cc9f85ffa7e3cfafc26b5e02d0745ce42359ec6593
7
- data.tar.gz: 431a14bb5c21985f7be8154c985f22e1efb2b84eca0210bd1a159cbda6caee36bdd2b12b923ffb2a4f2379469fe89ab96e5fc8d317de7c18e3caeb3cdd1962a5
6
+ metadata.gz: 7a89ac98879b869473638475f2b8679e26cf7e2cfb32af84884c5b2edb2ca01f6d79058f06e76267c360a23fec33ba7bfc8c9068ec245516c69cdb5beb9117e5
7
+ data.tar.gz: 080a4c535fb11be1325fc8b50df792e72af17ac5eb76c5e1db97a2bb84fd16422db8cbd9f498fc8bb31c4a0841e02450ae02d9810e0b46494fdf09cd8655c018
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.0
2
+ - Add auto_complete_html_path configuration (default: true)
3
+
1
4
  ## 1.0.0
2
5
  - Renewal with Ruby 2, RSpec 3, and rack-test
3
6
 
data/README.md CHANGED
@@ -1,24 +1,24 @@
1
1
  # Sitespec
2
- Generate static site from your rack application & spec definition.
2
+ Generate static site from your rack application & test files.
3
3
 
4
4
  * Provides the same way to create both dynamic & static website
5
5
  * Generates static website from your existing dynamic website
6
6
  * Sitespec can be executable specification, good documentation, and well-tested implementation
7
7
 
8
8
  ## Usage
9
- ### Add sitespec into your Gemfile
9
+ ### 1. Add sitespec into your Gemfile
10
10
  ```rb
11
11
  # Gemfile
12
12
  gem "sitespec"
13
13
  ```
14
14
 
15
- ### Require sitespec/rspec in your specs
15
+ ### 2. Require sitespec/rspec in your specs
16
16
  ```rb
17
17
  # spec/spec_helper.rb
18
18
  require "sitespec/rspec"
19
19
  ```
20
20
 
21
- ### Write request-specs with `:sitespec` metadata
21
+ ### 3. Write request-specs with `:sitespec` metadata
22
22
  Note: [rack/test](https://github.com/brynary/rack-test) is automatically enabled
23
23
  in the example groups that have `:sitespec`.
24
24
 
@@ -46,7 +46,7 @@ describe "Sitespec" do
46
46
  end
47
47
  ```
48
48
 
49
- ### Run rspec to build static files
49
+ ### 4. Run rspec to build static files
50
50
  Note: only successful examples generate static files.
51
51
 
52
52
  ```
@@ -65,6 +65,7 @@ Finished in 0.08302 seconds (files took 0.79161 seconds to load)
65
65
  ```
66
66
 
67
67
  ## Configuration
68
+ - `Sitespec.configuration.auto_complete_html_path` - Flag to autocomplete .html (default: `true`)
68
69
  - `Sitespec.configuration.build_path` - Where to locate files (default: `"build"`)
69
70
  - `Sitespec.configuration.enabled` - Flag to enable sitespec (default: `true`)
70
71
 
@@ -60,9 +60,28 @@ module Sitespec
60
60
  pathname.parent.mkpath
61
61
  end
62
62
 
63
- # @return [Pathname] Where to an artifact file is located
63
+ # @return [String] Where to an artifact file is located
64
+ def path
65
+ File.join(Sitespec.configuration.build_pathname, request.path) + path_suffix
66
+ end
67
+
68
+ # @return [String]
69
+ def path_suffix
70
+ case
71
+ when !Sitespec.configuration.auto_complete_html_path
72
+ ""
73
+ when response.content_type.nil? || !response.content_type.include?("text/html") || request.path.end_with?(".html")
74
+ ""
75
+ when request.path == "/"
76
+ "index.html"
77
+ else
78
+ ".html"
79
+ end
80
+ end
81
+
82
+ # @return [Pathname]
64
83
  def pathname
65
- Pathname.new(File.join(Sitespec.configuration.build_pathname, request.path))
84
+ Pathname.new(path)
66
85
  end
67
86
 
68
87
  # @note We expect `request` is provided via rack-test
@@ -4,10 +4,15 @@ module Sitespec
4
4
  class Configuration
5
5
  DEFAULT_BUILD_PATH = "build"
6
6
 
7
- attr_writer :build_path
7
+ attr_writer :auto_complete_html_path, :build_path
8
8
 
9
9
  def initialize
10
10
  @enabled = true
11
+ @auto_complete_html_path = true
12
+ end
13
+
14
+ def auto_complete_html_path
15
+ !!@auto_complete_html_path
11
16
  end
12
17
 
13
18
  def build_path
@@ -1,3 +1,3 @@
1
1
  module Sitespec
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
data/sitespec.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Sitespec::VERSION
8
8
  spec.authors = ["Ryo Nakamura"]
9
9
  spec.email = ["r7kamura@gmail.com"]
10
- spec.summary = "Generate static site from your rack application & spec definition"
10
+ spec.summary = "Generate static site from your rack application & test files"
11
11
  spec.homepage = "https://github.com/r7kamura/sitespec"
12
12
  spec.license = "MIT"
13
13
  spec.files = `git ls-files`.split($/)
@@ -6,8 +6,8 @@ describe "Example application" do
6
6
  end
7
7
 
8
8
  %w[
9
- /2000-01-01-hello.html
10
- /index.html
9
+ /
10
+ /2000-01-01-hello
11
11
  /stylesheets/all.css
12
12
  ].each do |path|
13
13
  describe "GET #{path}", :sitespec do
@@ -18,11 +18,11 @@ module Sitespec
18
18
  scss :all
19
19
  end
20
20
 
21
- get "/index.html" do
21
+ get "/" do
22
22
  slim :index
23
23
  end
24
24
 
25
- get "/:year-:month-:day-:title.html" do
25
+ get "/:year-:month-:day-:title" do
26
26
  slim :show, locals: { body: article }
27
27
  end
28
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sitespec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -187,7 +187,7 @@ rubyforge_project:
187
187
  rubygems_version: 2.4.5
188
188
  signing_key:
189
189
  specification_version: 4
190
- summary: Generate static site from your rack application & spec definition
190
+ summary: Generate static site from your rack application & test files
191
191
  test_files:
192
192
  - spec/sitespec_spec.rb
193
193
  - spec/spec_helper.rb