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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d6222e445f895dd7381c1814d6f8147f759cc5d
4
- data.tar.gz: 0ab9b64d04ef3c0fde3190861d62fbadef7b05dd
3
+ metadata.gz: 32b4903979b3477ec52f3f5abafc65755a78d50b
4
+ data.tar.gz: 814a01e8f3cb237f06d285b357ea08a7a446f732
5
5
  SHA512:
6
- metadata.gz: 25f303786ec48c337ac19b5f8f9c1edf0659e46ec2f9b34ead47507fdeabc710266c2f2b3e2f812ef7a9ede6e64cacb66e27d6f7c32bda87c861e1ad94962a25
7
- data.tar.gz: 88e4be9dafab41c38f2f8357fd94dfccbb3489e80eb8f06e38bced2737aefa95419ac5a509909899c5a267cd0c39b1d522505042e038c337a66667b9b2b0d3f6
6
+ metadata.gz: 74587c38c538d935cdb6659aaa41f5b629ee4ef56b673f4d23e9c0e34ac98cd8693194fa330531b4abbcf2a94c00d0e556fc94cfa400614c26f1cb4b0b37e94e
7
+ data.tar.gz: 15caf3f35597c5b504edc3fa67e7f891f7acd04c922ee9abc45b1e044385fc2428e9ba46a296861841ef8c3283303df58564bc12420e45c42272dd7ea4f0a301
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .sass-cache
5
6
  .yardoc
6
7
  /build
7
8
  Gemfile.lock
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.2
2
+ * Pretty RSpec formatter
3
+
4
+ ## 0.0.1
5
+ * Basic features to generate files from request spec
6
+ * The 1st release on 2013-11-15
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 "Static site generation" do
26
+ describe "Sitespec" do
21
27
  include Sitespec
22
28
 
23
- it "generates static files from rack application" do
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
- def self.configuration
10
- @configuration ||= Configuration.new
11
- end
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
- def self.configure(&block)
14
- configuration.instance_eval(&block)
23
+ def build_count
24
+ @build_count ||= 0
25
+ end
15
26
  end
16
27
 
17
28
  module_function
@@ -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,4 @@
1
+ module Sitespec
2
+ class Error < StandardError
3
+ end
4
+ 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
@@ -0,0 +1,2 @@
1
+ RSpec.configuration.formatters.clear
2
+ RSpec.configuration.formatter = Sitespec::Formatter
@@ -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,
@@ -1,3 +1,3 @@
1
1
  module Sitespec
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -11,7 +11,7 @@ module Sitespec
11
11
 
12
12
  def write
13
13
  mkpath
14
- create
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
@@ -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
- response.status.should == 200
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,2 @@
1
+ require File.expand_path("../example_application", __FILE__)
2
+ run Sitespec::ExampleApplication.new
@@ -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,5 @@
1
+ .main {
2
+ width: 840px;
3
+ madgin: 0 auto;
4
+ padding: 40px;
5
+ }
@@ -0,0 +1 @@
1
+ = "OK"
@@ -0,0 +1,11 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta charset="utf-8"
5
+ meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1"
6
+ title title
7
+ = stylesheet_link_tag :all
8
+
9
+ body
10
+ .main
11
+ = yield
@@ -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.1
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-15 00:00:00.000000000 Z
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: