sitespec 0.0.1 → 0.0.2
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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +22 -6
- data/lib/sitespec.rb +16 -5
- data/lib/sitespec/builder.rb +5 -1
- data/lib/sitespec/configuration.rb +2 -3
- data/lib/sitespec/error.rb +4 -0
- data/lib/sitespec/formatter.rb +19 -0
- data/lib/sitespec/initialize.rb +2 -0
- data/lib/sitespec/request.rb +1 -1
- data/lib/sitespec/version.rb +1 -1
- data/lib/sitespec/writer.rb +17 -1
- data/sitespec.gemspec +3 -0
- data/spec/sitespec_spec.rb +2 -7
- data/spec/spec_helper.rb +4 -0
- data/spec/support/sitespec/config.ru +2 -0
- data/spec/support/sitespec/example_application.rb +32 -0
- data/spec/support/sitespec/stylesheets/all.scss +5 -0
- data/spec/support/sitespec/views/index.slim +1 -0
- data/spec/support/sitespec/views/layouts/application.slim +11 -0
- data/spec/support/sitespec/views/show.slim +1 -0
- metadata +60 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b4903979b3477ec52f3f5abafc65755a78d50b
|
4
|
+
data.tar.gz: 814a01e8f3cb237f06d285b357ea08a7a446f732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74587c38c538d935cdb6659aaa41f5b629ee4ef56b673f4d23e9c0e34ac98cd8693194fa330531b4abbcf2a94c00d0e556fc94cfa400614c26f1cb4b0b37e94e
|
7
|
+
data.tar.gz: 15caf3f35597c5b504edc3fa67e7f891f7acd04c922ee9abc45b1e044385fc2428e9ba46a296861841ef8c3283303df58564bc12420e45c42272dd7ea4f0a301
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Sitespec
|
2
2
|
Generate static site from your rack application & spec definition.
|
3
3
|
|
4
|
+
## Features
|
5
|
+
* Provides the same way to create both dynamic & static website
|
6
|
+
* Generates static website from your existing dynamic website
|
7
|
+
* Sitespec can be executable specification, good documentation, and well-tested implementation
|
8
|
+
|
4
9
|
## Installation
|
5
10
|
```sh
|
6
11
|
# shell-command
|
@@ -15,23 +20,34 @@ require "sitespec"
|
|
15
20
|
Sitespec.configure do
|
16
21
|
self.application = MyRackApplication.new
|
17
22
|
self.build_path = "build"
|
23
|
+
self.raise_http_error = true
|
18
24
|
end
|
19
25
|
|
20
|
-
describe "
|
26
|
+
describe "Sitespec" do
|
21
27
|
include Sitespec
|
22
28
|
|
23
|
-
it "generates static
|
24
|
-
get "/stylesheets/all.css"
|
25
|
-
get "/images/favicon.ico"
|
26
|
-
get "/index.html"
|
29
|
+
it "generates static site from your rack application & spec definition" do
|
27
30
|
get "/2000/01/01/hello.html"
|
28
31
|
get "/2000/01/02/world.html"
|
29
32
|
get "/feed.xml"
|
33
|
+
get "/images/favicon.ico"
|
34
|
+
get "/index.html"
|
35
|
+
get "/stylesheets/all.css"
|
30
36
|
end
|
31
37
|
end
|
32
38
|
```
|
33
39
|
|
34
40
|
```sh
|
35
41
|
# shell-command
|
36
|
-
rspec
|
42
|
+
$ rspec
|
43
|
+
Build started...
|
44
|
+
|
45
|
+
✔ 2000/01/01/hello.html
|
46
|
+
✔ 2000/01/02/world.html
|
47
|
+
✔ feed.xml
|
48
|
+
✔ images/favicon.ico
|
49
|
+
✔ index.html
|
50
|
+
✔ stylesheets/all.css
|
51
|
+
|
52
|
+
Build finished with 6 files in 0.00151 seconds.
|
37
53
|
```
|
data/lib/sitespec.rb
CHANGED
@@ -1,17 +1,28 @@
|
|
1
1
|
require "sitespec/builder"
|
2
2
|
require "sitespec/configuration"
|
3
|
+
require "sitespec/error"
|
4
|
+
require "sitespec/formatter"
|
3
5
|
require "sitespec/request"
|
4
6
|
require "sitespec/response"
|
5
7
|
require "sitespec/version"
|
6
8
|
require "sitespec/writer"
|
9
|
+
require "sitespec/initialize"
|
7
10
|
|
8
11
|
module Sitespec
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
class << self
|
13
|
+
attr_writer :build_count
|
14
|
+
|
15
|
+
def configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure(&block)
|
20
|
+
configuration.instance_eval(&block)
|
21
|
+
end
|
12
22
|
|
13
|
-
|
14
|
-
|
23
|
+
def build_count
|
24
|
+
@build_count ||= 0
|
25
|
+
end
|
15
26
|
end
|
16
27
|
|
17
28
|
module_function
|
data/lib/sitespec/builder.rb
CHANGED
@@ -13,7 +13,11 @@ module Sitespec
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
Sitespec.configuration.application.call(@request.env)
|
16
|
+
Sitespec.configuration.application.call(@request.env).tap do |status, header, body|
|
17
|
+
if Sitespec.configuration.raise_http_error && status >= 400
|
18
|
+
raise Error, "#{@request.uri} returned #{status}"
|
19
|
+
end
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
1
|
module Sitespec
|
4
2
|
class Configuration
|
5
|
-
attr_accessor :application, :build_path
|
3
|
+
attr_accessor :application, :build_path, :raise_http_error
|
6
4
|
|
7
5
|
def initialize
|
8
6
|
@build_path = "build"
|
7
|
+
@raise_http_error = true
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "rspec/core/formatters/documentation_formatter"
|
2
|
+
|
3
|
+
module Sitespec
|
4
|
+
class Formatter < RSpec::Core::Formatters::BaseTextFormatter
|
5
|
+
def start(*)
|
6
|
+
super
|
7
|
+
output.puts "Build started...\n\n"
|
8
|
+
end
|
9
|
+
|
10
|
+
def dump_summary(duration, example_count, failure_count, pending_count)
|
11
|
+
@duration = duration
|
12
|
+
@example_count = example_count
|
13
|
+
@failure_count = failure_count
|
14
|
+
@pending_count = pending_count
|
15
|
+
output.puts "\nBuild finished with #{Sitespec.build_count} files in #{format_duration(duration)}.\n"
|
16
|
+
dump_commands_to_rerun_failed_examples
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/sitespec/request.rb
CHANGED
@@ -15,7 +15,7 @@ module Sitespec
|
|
15
15
|
"HTTPS" => https? ? "on" : "off",
|
16
16
|
"HTTP_HOST" => uri.host,
|
17
17
|
"PATH_INFO" => uri.path,
|
18
|
-
"QUERY_STRING" => uri.query,
|
18
|
+
"QUERY_STRING" => uri.query || "",
|
19
19
|
"REQUEST_METHOD" => @method.to_s.upcase,
|
20
20
|
"REQUEST_URI" => uri.to_s,
|
21
21
|
"SERVER_NAME" => uri.hostname,
|
data/lib/sitespec/version.rb
CHANGED
data/lib/sitespec/writer.rb
CHANGED
@@ -11,7 +11,7 @@ module Sitespec
|
|
11
11
|
|
12
12
|
def write
|
13
13
|
mkpath
|
14
|
-
|
14
|
+
create_with_output_and_build_count
|
15
15
|
end
|
16
16
|
|
17
17
|
def path
|
@@ -25,5 +25,21 @@ module Sitespec
|
|
25
25
|
def create
|
26
26
|
path.open("w") {|file| file << @response.body }
|
27
27
|
end
|
28
|
+
|
29
|
+
def create_with_output
|
30
|
+
create.tap { puts "#{color(?✔)} #{path}" }
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_with_output_and_build_count
|
34
|
+
create_with_output.tap { Sitespec.build_count += 1 }
|
35
|
+
end
|
36
|
+
|
37
|
+
def color(text)
|
38
|
+
RSpec.configuration.color_enabled? ? "\e[32m#{text}\e[0m" : text
|
39
|
+
end
|
40
|
+
|
41
|
+
def puts(text)
|
42
|
+
RSpec.configuration.formatters[0].output.puts text
|
43
|
+
end
|
28
44
|
end
|
29
45
|
end
|
data/sitespec.gemspec
CHANGED
@@ -17,7 +17,10 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
19
|
spec.add_development_dependency "bundler", ">= 1.4"
|
20
|
+
spec.add_development_dependency "padrino"
|
20
21
|
spec.add_development_dependency "pry"
|
21
22
|
spec.add_development_dependency "rake"
|
22
23
|
spec.add_development_dependency "rspec", ">= 2.14.1"
|
24
|
+
spec.add_development_dependency "sass"
|
25
|
+
spec.add_development_dependency "slim"
|
23
26
|
end
|
data/spec/sitespec_spec.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Sitespec do
|
4
|
-
before do
|
5
|
-
Sitespec.configuration.application = ->(env) do
|
6
|
-
[200, {}, ["OK"]]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
4
|
it "generates static files from rack application" do
|
5
|
+
get "/stylesheets/all.css"
|
11
6
|
get "/index.html"
|
12
|
-
|
7
|
+
get "/2001-01-01-title.html"
|
13
8
|
end
|
14
9
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
2
2
|
require "sitespec"
|
3
3
|
|
4
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f }
|
5
|
+
|
4
6
|
RSpec.configure do |config|
|
5
7
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
8
|
config.include Sitespec
|
7
9
|
end
|
10
|
+
|
11
|
+
Sitespec.configuration.application = Sitespec::ExampleApplication
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "padrino"
|
2
|
+
require "sass"
|
3
|
+
require "slim"
|
4
|
+
|
5
|
+
module Sitespec
|
6
|
+
class ExampleApplication < Padrino::Application
|
7
|
+
register Padrino::Helpers
|
8
|
+
register Padrino::Rendering
|
9
|
+
|
10
|
+
set :scss, views: "#{root}/stylesheets"
|
11
|
+
set :show_exceptions, false
|
12
|
+
set :slim, pretty: true
|
13
|
+
|
14
|
+
disable :logging
|
15
|
+
|
16
|
+
error do |exception|
|
17
|
+
raise exception
|
18
|
+
end
|
19
|
+
|
20
|
+
get "/stylesheets/all.css" do
|
21
|
+
scss :all
|
22
|
+
end
|
23
|
+
|
24
|
+
get "/index.html" do
|
25
|
+
slim :index
|
26
|
+
end
|
27
|
+
|
28
|
+
get "/:year-:month-:day-:title.html" do
|
29
|
+
slim :show
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
= "OK"
|
@@ -0,0 +1 @@
|
|
1
|
+
= "show"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitespec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: padrino
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: pry
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,34 @@ dependencies:
|
|
66
80
|
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 2.14.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sass
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: slim
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description:
|
70
112
|
email:
|
71
113
|
- r7kamura@gmail.com
|
@@ -74,6 +116,7 @@ extensions: []
|
|
74
116
|
extra_rdoc_files: []
|
75
117
|
files:
|
76
118
|
- .gitignore
|
119
|
+
- CHANGELOG.md
|
77
120
|
- Gemfile
|
78
121
|
- LICENSE.txt
|
79
122
|
- README.md
|
@@ -81,6 +124,9 @@ files:
|
|
81
124
|
- lib/sitespec.rb
|
82
125
|
- lib/sitespec/builder.rb
|
83
126
|
- lib/sitespec/configuration.rb
|
127
|
+
- lib/sitespec/error.rb
|
128
|
+
- lib/sitespec/formatter.rb
|
129
|
+
- lib/sitespec/initialize.rb
|
84
130
|
- lib/sitespec/request.rb
|
85
131
|
- lib/sitespec/response.rb
|
86
132
|
- lib/sitespec/version.rb
|
@@ -88,6 +134,12 @@ files:
|
|
88
134
|
- sitespec.gemspec
|
89
135
|
- spec/sitespec_spec.rb
|
90
136
|
- spec/spec_helper.rb
|
137
|
+
- spec/support/sitespec/config.ru
|
138
|
+
- spec/support/sitespec/example_application.rb
|
139
|
+
- spec/support/sitespec/stylesheets/all.scss
|
140
|
+
- spec/support/sitespec/views/index.slim
|
141
|
+
- spec/support/sitespec/views/layouts/application.slim
|
142
|
+
- spec/support/sitespec/views/show.slim
|
91
143
|
homepage: https://github.com/r7kamura/sitespec
|
92
144
|
licenses:
|
93
145
|
- MIT
|
@@ -115,4 +167,10 @@ summary: Generate static site from your rack application & spec definition
|
|
115
167
|
test_files:
|
116
168
|
- spec/sitespec_spec.rb
|
117
169
|
- spec/spec_helper.rb
|
170
|
+
- spec/support/sitespec/config.ru
|
171
|
+
- spec/support/sitespec/example_application.rb
|
172
|
+
- spec/support/sitespec/stylesheets/all.scss
|
173
|
+
- spec/support/sitespec/views/index.slim
|
174
|
+
- spec/support/sitespec/views/layouts/application.slim
|
175
|
+
- spec/support/sitespec/views/show.slim
|
118
176
|
has_rdoc:
|