sinatra-export 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # sinatra-export
2
2
 
3
- > Exports your Sinatra app to static files. Depends on [sinatra-advanced-routes](https://github.com/rkh/sinatra-advanced-routes).
3
+ > Exports all your Sinatra application routes to static files in your public folder.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/hooktstudios/sinatra-export.png)](https://travis-ci.org/hooktstudios/sinatra-export)
6
6
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/hooktstudios/sinatra-export)
@@ -13,9 +13,15 @@ Add to your `Gemfile` :
13
13
  gem 'sinatra-export'
14
14
  ```
15
15
 
16
- Setup your `Rakefile` :
16
+ Setup your application with [sinatra-advanced-routes](https://github.com/rkh/sinatra-advanced-routes) :
17
17
 
18
+ ```ruby
19
+ register Sinatra::AdvancedRoutes
18
20
  ```
21
+
22
+ Setup your `Rakefile` :
23
+
24
+ ```ruby
19
25
  APP_FILE = 'app.rb'
20
26
  APP_CLASS = 'App'
21
27
 
@@ -43,6 +49,10 @@ class App < Sinatra::Base
43
49
  "<h1>My contact page<h1>"
44
50
  end
45
51
 
52
+ get '/data.json' do
53
+ "{test: 'ok'}"
54
+ end
55
+
46
56
  end
47
57
  ```
48
58
 
@@ -50,14 +60,17 @@ Running your app ex. `rake sinatra:export` will automatically generate theses fi
50
60
 
51
61
  public/index.html -> "<h1>My homepage</h1>"
52
62
  public/contact/index.html -> "<h1>My contact page<h1>"
63
+ public/data.json -> "{test: 'ok'}"
53
64
 
54
65
  ## Usage
55
66
 
56
- rake sinatra:export
67
+ $ rake sinatra:export
57
68
 
58
69
  Or invoke it manually :
59
70
 
60
- Sinatra::Export.new(App).build!
71
+ ````ruby
72
+ Sinatra::Export.new(App).build!
73
+ ```
61
74
 
62
75
  ### Advanced Assets Management
63
76
 
@@ -1,4 +1,5 @@
1
1
  require 'rack/test'
2
+ require 'term/ansicolor'
2
3
 
3
4
  module Sinatra
4
5
  class Export
@@ -9,7 +10,7 @@ module Sinatra
9
10
 
10
11
  include Rack::Test::Methods
11
12
 
12
- require 'term/ansicolor'
13
+
13
14
  class ColorString < String
14
15
  include Term::ANSIColor
15
16
  end
@@ -35,9 +36,10 @@ module Sinatra
35
36
  end
36
37
 
37
38
  def build_path(path, dir)
39
+ body = get_path(path).body
38
40
  ::FileUtils.mkdir_p(dir_for_path(path, dir))
39
41
  ::File.open(file_for_path(path, dir), 'w+') do |f|
40
- f.write(get_path(path).body)
42
+ f.write(body)
41
43
  end
42
44
  end
43
45
 
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'sinatra-export'
3
- s.version = '0.9.1'
3
+ s.version = '0.9.2'
4
4
 
5
5
  s.authors = ['Jean-Philippe Doyle', 'Paul Asmuth']
6
6
  s.date = '2013-01-16'
7
- s.description = 'Export your sinatra app to a directory of static files.'
7
+ s.description = 'Exports all your Sinatra application routes to static files in your public folder'
8
8
  s.summary = 'Sinatra static export.'
9
9
  s.email = 'jeanphilippe.doyle@hooktstudios.com'
10
10
  s.files = [
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  'sinatra-export.gemspec',
14
14
  'lib/sinatra/export.rb',
15
15
  'lib/sinatra/export/rake.rb',
16
- 'readme.md'
16
+ 'README.md'
17
17
  ]
18
18
  s.homepage = 'http://github.com/hooktstudios/sinatra-export'
19
19
  s.license = 'MIT'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -140,7 +140,8 @@ dependencies:
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  none: false
143
- description: Export your sinatra app to a directory of static files.
143
+ description: Exports all your Sinatra application routes to static files in your public
144
+ folder
144
145
  email: jeanphilippe.doyle@hooktstudios.com
145
146
  executables: []
146
147
  extensions: []
@@ -151,7 +152,7 @@ files:
151
152
  - sinatra-export.gemspec
152
153
  - lib/sinatra/export.rb
153
154
  - lib/sinatra/export/rake.rb
154
- - readme.md
155
+ - README.md
155
156
  homepage: http://github.com/hooktstudios/sinatra-export
156
157
  licenses:
157
158
  - MIT