ember-cli-deploy-rack 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +45 -0
- data/CONTRIBUTING.md +18 -0
- data/LICENSE +21 -0
- data/README.md +219 -0
- data/lib/ember/cli/deploy/rack.rb +11 -0
- data/lib/ember/cli/deploy/rack/engine.rb +128 -0
- data/lib/ember/cli/deploy/rack/version.rb +9 -0
- data/lib/tasks/bundler.rake +9 -0
- data/lib/tasks/rspec.rake +5 -0
- data/lib/tasks/rubocop.rake +10 -0
- data/resources/config/settings.yml +22 -0
- data/spec/ember_cli_deploy_rack_helper.rb +45 -0
- data/spec/fixtures/ember/cli/deploy/rack/engine/revisions/current-content.html +17 -0
- data/spec/fixtures/ember/cli/deploy/rack/engine/revisions/e56b0f2850be071697ab61c41ce8f3c0.html +17 -0
- data/spec/integration/ember/cli/deploy/rack/engine/views/debug_spec.rb +25 -0
- data/spec/integration/ember/cli/deploy/rack/engine_spec.rb +52 -0
- data/spec/spec_helper.rb +71 -0
- data/spec/support/database_cleaner.rb +17 -0
- data/spec/support/simplecov.rb +1 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9ba5426b5df3a3f69d10b951d9a5fec1e98e0778
|
4
|
+
data.tar.gz: 85a123bb973db7248f2adbf270d0a4509de11c14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d953512e96e53912513345d1d0762b006dcda54075e7ffcc8b75ffd1842beba973675e728e1d2d2462a81b1e5696338a7d28cb6cc03778d3e26ea960f701b20
|
7
|
+
data.tar.gz: 4ddffd63486a18effb0c88b6fd9d13fd3ce2632ad88bba3ec675ef266ed186474dd820e6d2229a674a3b5aa34120c7fc3781bf613c5b88fd4f7e8bcdce4d3d81
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
2.3.0
|
2
|
+
=====
|
3
|
+
|
4
|
+
* [✖] Removed logging out of engine, should be configured via `config.ru`
|
5
|
+
* [✓] Use `Sinatra::Base` instead of `Sinatra::Application`
|
6
|
+
* [➠] Improved `debug` view
|
7
|
+
|
8
|
+
2.2.0 (Yanked)
|
9
|
+
==============
|
10
|
+
|
11
|
+
* [➠] First release on RubyGems
|
12
|
+
* [➠] Debug information can be enabled / disabled
|
13
|
+
* [➠] Formatted debug information
|
14
|
+
|
15
|
+
2.1.0
|
16
|
+
=====
|
17
|
+
|
18
|
+
* [➠] Updated README
|
19
|
+
* [➠] Refactored engine code
|
20
|
+
* [✚] Added `debug` route
|
21
|
+
* [✖] Removed `config` gem, `sinatra/config_file` is perfectly adequate
|
22
|
+
|
23
|
+
2.0.1
|
24
|
+
=====
|
25
|
+
|
26
|
+
* [➠] Response with 400 when revision is not valid
|
27
|
+
|
28
|
+
2.0.0
|
29
|
+
=====
|
30
|
+
|
31
|
+
* [➠] Renamed `index_id` to `key_prefix`
|
32
|
+
* [➠] Added `active_content_suffix` and `revision` options
|
33
|
+
* [➠] Compatibility with the latest version of `ember-cli-deploy-redis`
|
34
|
+
|
35
|
+
1.0.1
|
36
|
+
=====
|
37
|
+
|
38
|
+
* [✓] Fixed version require
|
39
|
+
|
40
|
+
1.0.0
|
41
|
+
=====
|
42
|
+
|
43
|
+
* [✚] Added specs
|
44
|
+
* [➠] Configured Travis CI, Code Climate, Test Coverage, RuboCop and Gemnasium
|
45
|
+
* [❶] First commit (born from Bitaculous Booster)
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Contribution Guidelines
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Making a pull request
|
5
|
+
---------------------
|
6
|
+
|
7
|
+
If you'd like to submit a pull request please adhere to the following:
|
8
|
+
|
9
|
+
1. Your code *must* be tested. Please TDD your code!
|
10
|
+
2. 120 characters code width
|
11
|
+
3. Two-spaces instead of tabs
|
12
|
+
4. Single-quotes instead of double-quotes unless you are using string interpolation or escapes
|
13
|
+
5. No single-character variables
|
14
|
+
6. General Ruby naming conventions for files and classes
|
15
|
+
|
16
|
+
Please note that you must adhere to each of the above mentioned rules. Failure to do so will result in an immediate
|
17
|
+
closing of the pull request. If you update and rebase the pull request to follow the guidelines your pull request will
|
18
|
+
be re-opened and considered for inclusion.
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015-2016 Bitaculous
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,219 @@
|
|
1
|
+
[Ember CLI Deploy Rack]
|
2
|
+
=======================
|
3
|
+
|
4
|
+
[![Travis CI Status][Travis CI Status]][Travis CI]
|
5
|
+
[![Code Climate Status][Code Climate Status]][Code Climate]
|
6
|
+
[![Test Coverage Status][Test Coverage Status]][Test Coverage]
|
7
|
+
[![Gemnasium Status][Gemnasium Status]][Gemnasium]
|
8
|
+
|
9
|
+
**A [Rack] package to launch your [Ember.js] application into the Cloud.**
|
10
|
+
|
11
|
+
Summary
|
12
|
+
-------
|
13
|
+
|
14
|
+
Ember CLI Deploy Rack can be used to serve an [Ember CLI] application deployed with the help of [Ember CLI Deploy] and
|
15
|
+
[ember-deploy-redis].
|
16
|
+
|
17
|
+
Basically, it is a [Sinatra] application, which connects to Redis and returns the uploaded index.html.
|
18
|
+
|
19
|
+
You can deploy your application to production, test it out by passing an `revision` parameter with the revision you want
|
20
|
+
to test and activate when you feel confident that everything is working as expected.
|
21
|
+
|
22
|
+
For further information see [Ember CLI Deploy].
|
23
|
+
|
24
|
+
Prerequisites
|
25
|
+
-------------
|
26
|
+
|
27
|
+
* [Ruby]
|
28
|
+
* [Redis]
|
29
|
+
|
30
|
+
Installation
|
31
|
+
------------
|
32
|
+
|
33
|
+
1. Create a Gemfile
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
#!/usr/bin/env bundle
|
37
|
+
|
38
|
+
source 'https://rubygems.org'
|
39
|
+
|
40
|
+
gem 'ember-cli-deploy-rack', require: false
|
41
|
+
```
|
42
|
+
|
43
|
+
2. Run `bundle` to install all dependencies with [Bundler]
|
44
|
+
|
45
|
+
Usage
|
46
|
+
-----
|
47
|
+
|
48
|
+
1. Create a Rack configuration
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
#!/usr/bin/env rackup
|
52
|
+
|
53
|
+
# This file is used by Rack-based servers to start the application.
|
54
|
+
|
55
|
+
require 'bundler/setup'
|
56
|
+
|
57
|
+
require 'ember/cli/deploy/rack'
|
58
|
+
|
59
|
+
run Ember::CLI::Deploy::Rack::Engine
|
60
|
+
```
|
61
|
+
|
62
|
+
2. Run the engine with `rackup` or your favorite Ruby Webserver
|
63
|
+
|
64
|
+
Configuration
|
65
|
+
-------------
|
66
|
+
|
67
|
+
Ember CLI Deploy Rack can be configured in various ways:
|
68
|
+
|
69
|
+
1. Via settings
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
engine = Ember::CLI::Deploy::Rack::Engine.new
|
73
|
+
|
74
|
+
# === Settings ====
|
75
|
+
|
76
|
+
# engine.settings.set :root, Dir.pwd
|
77
|
+
# engine.settings.set :key_prefix, 'ember-cli-deploy-rack:index'
|
78
|
+
# engine.settings.set :active_content_suffix, 'current-content'
|
79
|
+
# engine.settings.set :revision, { regexp: '^[0-9a-f]{32}$' }
|
80
|
+
# engine.settings.set :redis, { host: '127.0.0.1', ... }
|
81
|
+
# engine.settings.set :redis_client, proc { Redis.new settings.redis }
|
82
|
+
# engine.settings.set :debug, false
|
83
|
+
# ...
|
84
|
+
|
85
|
+
# === Logging ====
|
86
|
+
|
87
|
+
# log_dir = File.expand_path 'log'
|
88
|
+
#
|
89
|
+
# if File.directory? log_dir
|
90
|
+
# log_file = File.expand_path "#{engine.settings.environment}.log", log_dir
|
91
|
+
#
|
92
|
+
# logger = Logger.new log_file, File::WRONLY | File::APPEND | File::CREAT
|
93
|
+
# logger.level = Logger::ERROR
|
94
|
+
#
|
95
|
+
# engine.settings.set :logger, logger
|
96
|
+
# end
|
97
|
+
|
98
|
+
run engine
|
99
|
+
```
|
100
|
+
|
101
|
+
2. Via YAML configuration file
|
102
|
+
|
103
|
+
Just create a configuration file `config/settings.yml` and adjust properly, for an example see
|
104
|
+
[resources/config/settings.yml].
|
105
|
+
|
106
|
+
### Options
|
107
|
+
|
108
|
+
#### Key Prefix
|
109
|
+
|
110
|
+
The prefix to be used for the Redis key under which file will be uploaded to Redis. The Redis key will be a combination
|
111
|
+
of the `key_prefix` and the `revision_key`. Typically this is the `project.name` property from the deployment context
|
112
|
+
and `:index` at the end. By default this option will be `ember-cli-deploy-rack:index`.
|
113
|
+
|
114
|
+
For more details, see https://github.com/ember-cli-deploy/ember-cli-deploy-redis#keyprefix.
|
115
|
+
|
116
|
+
#### Active Content Suffix
|
117
|
+
|
118
|
+
The suffix to be used for the Redis key under which the activated revision content will be stored in Redis. By default
|
119
|
+
this option will be `current-content`. This makes the default activated revision in Redis looks like: The `project.name`
|
120
|
+
property from the deployment and `:index:current-content` at the end.
|
121
|
+
|
122
|
+
For more details, see https://github.com/ember-cli-deploy/ember-cli-deploy-redis#activecontentsuffix.
|
123
|
+
|
124
|
+
#### Revision
|
125
|
+
|
126
|
+
#### Regexp
|
127
|
+
|
128
|
+
The regular expression to check the revision. By default this option will be `^[0-9a-f]{32}$`.
|
129
|
+
|
130
|
+
#### Redis
|
131
|
+
|
132
|
+
The options for the Redis client. For available options see [Redis::Client::DEFAULTS].
|
133
|
+
|
134
|
+
#### Debug
|
135
|
+
|
136
|
+
If enabled, debug information can be viewed under `/debug`. By default this option will be `false`.
|
137
|
+
|
138
|
+
Development
|
139
|
+
-----------
|
140
|
+
|
141
|
+
### Run specs with [RSpec]
|
142
|
+
|
143
|
+
Run `rspec`.
|
144
|
+
|
145
|
+
or via [Guard]:
|
146
|
+
|
147
|
+
```
|
148
|
+
$ guard -g spec
|
149
|
+
```
|
150
|
+
|
151
|
+
### See Test Coverage
|
152
|
+
|
153
|
+
Run `COVERAGE=true rspec`.
|
154
|
+
|
155
|
+
### Run [RuboCop]
|
156
|
+
|
157
|
+
Run `rubocop`.
|
158
|
+
|
159
|
+
To run all specs and RuboCop altogether, run `rake`.
|
160
|
+
|
161
|
+
### Rack
|
162
|
+
|
163
|
+
```
|
164
|
+
$ rackup
|
165
|
+
```
|
166
|
+
|
167
|
+
#### Thin
|
168
|
+
|
169
|
+
```
|
170
|
+
$ thin -R config.ru -d start
|
171
|
+
$ thin stop
|
172
|
+
```
|
173
|
+
|
174
|
+
Bug Reports
|
175
|
+
-----------
|
176
|
+
|
177
|
+
Github Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues
|
178
|
+
and submit new problems [here].
|
179
|
+
|
180
|
+
Versioning
|
181
|
+
----------
|
182
|
+
|
183
|
+
This library aims to adhere to [Semantic Versioning 2.0.0]. Violations of this scheme should be reported as bugs.
|
184
|
+
Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be
|
185
|
+
immediately yanked and / or a new version should be immediately released that restores compatibility.
|
186
|
+
|
187
|
+
License
|
188
|
+
-------
|
189
|
+
|
190
|
+
Ember CLI Deploy Rack is released under the [MIT License (MIT)], see [LICENSE].
|
191
|
+
|
192
|
+
[Bundler]: http://bundler.io "The best way to manage a Ruby application's gems"
|
193
|
+
[Code Climate]: https://codeclimate.com/github/bitaculous/ember-cli-deploy-rack "Ember CLI Deploy Rack at Code Climate"
|
194
|
+
[Code Climate Status]: https://img.shields.io/codeclimate/github/bitaculous/ember-cli-deploy-rack.svg?style=flat "Code Climate Status"
|
195
|
+
[Ember CLI]: http://www.ember-cli.com "The command line interface for ambitious web applications."
|
196
|
+
[Ember CLI Deploy Rack]: https://bitaculous.github.io/ember-cli-deploy-rack/ "A Rack package to launch your Ember.js application into the Cloud."
|
197
|
+
[Ember CLI Deploy]: http://ember-cli.github.io/ember-cli-deploy "Simple, flexible deployment for your Ember app"
|
198
|
+
[ember-deploy-redis]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis "An ember-cli-deploy plugin to upload index.html to a Redis store."
|
199
|
+
[Ember.js]: http://emberjs.com "A framework for creating ambitious web applications."
|
200
|
+
[Foreman]: http://ddollar.github.io/foreman "Manage Procfile-based applications"
|
201
|
+
[Gemnasium]: https://gemnasium.com/bitaculous/ember-cli-deploy-rack "Ember CLI Deploy Rack at Gemnasium"
|
202
|
+
[Gemnasium Status]: https://img.shields.io/gemnasium/bitaculous/ember-cli-deploy-rack.svg?style=flat "Gemnasium Status"
|
203
|
+
[Guard]: http://guardgem.org "A command line tool to easily handle events on file system modifications."
|
204
|
+
[here]: https://github.com/bitaculous/ember-cli-deploy-rack/issues "Github Issues"
|
205
|
+
[LICENSE]: https://raw.githubusercontent.com/bitaculous/ember-cli-deploy-rack/master/LICENSE "License"
|
206
|
+
[MIT License (MIT)]: http://opensource.org/licenses/MIT "The MIT License (MIT)"
|
207
|
+
[Rack]: http://rack.github.io "A Ruby Webserver Interface"
|
208
|
+
[Redis]: http://redis.io "An open source, BSD licensed, advanced key-value cache and store."
|
209
|
+
[Redis::Client::DEFAULTS]: https://github.com/redis/redis-rb/blob/master/lib/redis/client.rb#L8 "The redis-rb defaults"
|
210
|
+
[resources/config/settings.yml]: https://github.com/bitaculous/ember-cli-deploy-rack/blob/master/resources/config/settings.yml "Sample YAML configuration"
|
211
|
+
[RSpec]: http://rspec.info "Behaviour Driven Development for Ruby"
|
212
|
+
[RuboCop]: https://github.com/bbatsov/rubocop "A Ruby static code analyzer, based on the community Ruby style guide."
|
213
|
+
[Ruby]: https://www.ruby-lang.org "A dynamic, open source programming language with a focus on simplicity and productivity."
|
214
|
+
[Semantic Versioning 2.0.0]: http://semver.org "Semantic Versioning 2.0.0"
|
215
|
+
[Sinatra]: http://www.sinatrarb.com "A DSL for quickly creating web applications in Ruby with minimal effort."
|
216
|
+
[Test Coverage]: https://codeclimate.com/github/bitaculous/ember-cli-deploy-rack "Test Coverage (Code Climate)"
|
217
|
+
[Test Coverage Status]: https://img.shields.io/codeclimate/coverage/github/bitaculous/ember-cli-deploy-rack.svg?style=flat "Test Coverage Status"
|
218
|
+
[Travis CI]: https://travis-ci.org/bitaculous/ember-cli-deploy-rack "Ember CLI Deploy Rack at Travis CI"
|
219
|
+
[Travis CI Status]: https://img.shields.io/travis/bitaculous/ember-cli-deploy-rack.svg?style=flat "Travis CI Status"
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'redis'
|
3
|
+
require 'sinatra/base'
|
4
|
+
require 'sinatra/config_file'
|
5
|
+
require 'sinatra/custom_logger'
|
6
|
+
require 'sinatra/reloader'
|
7
|
+
|
8
|
+
module Ember
|
9
|
+
module CLI
|
10
|
+
module Deploy
|
11
|
+
module Rack # :nodoc:
|
12
|
+
# = Engine
|
13
|
+
#
|
14
|
+
# The engine class of `Ember::CLI::Deploy::Rack`, inherited from `Sinatra::Base`.
|
15
|
+
class Engine < Sinatra::Base
|
16
|
+
# === Constants ===
|
17
|
+
|
18
|
+
TRAIL = File.expand_path '../../../../../../', __FILE__
|
19
|
+
VIEWS = File.expand_path 'views', TRAIL
|
20
|
+
CONFIG = 'config/settings.yml'
|
21
|
+
|
22
|
+
KEY_PREFIX = 'ember-cli-deploy-rack:index'
|
23
|
+
ACTIVE_CONTENT_SUFFIX = 'current-content'
|
24
|
+
REVISION_REGEXP = '^[0-9a-f]{32}$'
|
25
|
+
|
26
|
+
# === Settings ===
|
27
|
+
|
28
|
+
set :root, TRAIL
|
29
|
+
|
30
|
+
set :views, VIEWS
|
31
|
+
|
32
|
+
set :key_prefix, KEY_PREFIX
|
33
|
+
|
34
|
+
set :active_content_suffix, ACTIVE_CONTENT_SUFFIX
|
35
|
+
|
36
|
+
set :revision, 'regexp' => REVISION_REGEXP
|
37
|
+
|
38
|
+
set :redis, proc {
|
39
|
+
defaults = Redis::Client::DEFAULTS.dup
|
40
|
+
|
41
|
+
defaults.keys.each do |key|
|
42
|
+
# Fill in defaults if needed
|
43
|
+
defaults[key] = defaults[key].call if defaults[key].respond_to? :call
|
44
|
+
end
|
45
|
+
|
46
|
+
defaults
|
47
|
+
}
|
48
|
+
|
49
|
+
set :redis_client, proc {
|
50
|
+
Redis.new settings.redis
|
51
|
+
}
|
52
|
+
|
53
|
+
set :debug, false
|
54
|
+
|
55
|
+
set :version, Ember::CLI::Deploy::Rack::VERSION
|
56
|
+
|
57
|
+
# === Extensions ===
|
58
|
+
|
59
|
+
register Sinatra::ConfigFile
|
60
|
+
|
61
|
+
config_file File.expand_path CONFIG
|
62
|
+
|
63
|
+
# === Helpers ===
|
64
|
+
|
65
|
+
helpers Sinatra::CustomLogger
|
66
|
+
|
67
|
+
# === Configuration ===
|
68
|
+
|
69
|
+
configure :development do
|
70
|
+
register Sinatra::Reloader
|
71
|
+
end
|
72
|
+
|
73
|
+
# === Routes ===
|
74
|
+
|
75
|
+
get '/' do
|
76
|
+
content_type 'text/html'
|
77
|
+
|
78
|
+
logger.debug 'Processing request for `/` route...'
|
79
|
+
|
80
|
+
index params[:revision]
|
81
|
+
end
|
82
|
+
|
83
|
+
get '/debug' do
|
84
|
+
if settings.debug
|
85
|
+
@id = 'debug'
|
86
|
+
@title = 'Debug'
|
87
|
+
@settings = settings
|
88
|
+
|
89
|
+
haml :debug
|
90
|
+
else
|
91
|
+
halt 403
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# === Private ===
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def index(revision)
|
100
|
+
key = get_key revision
|
101
|
+
|
102
|
+
logger.debug "Getting content from Redis with key: `#{key}`..."
|
103
|
+
|
104
|
+
redis_client = settings.redis_client
|
105
|
+
|
106
|
+
redis_client.get(key) || halt(404)
|
107
|
+
end
|
108
|
+
|
109
|
+
def get_key(revision)
|
110
|
+
key = "#{settings.key_prefix}:#{settings.active_content_suffix}"
|
111
|
+
|
112
|
+
if revision
|
113
|
+
regexp = Regexp.new settings.revision['regexp'], 1
|
114
|
+
|
115
|
+
if revision =~ regexp
|
116
|
+
key = "#{settings.key_prefix}:#{revision}"
|
117
|
+
else
|
118
|
+
halt 400
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
key
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# The prefix to be used for the Redis key under which file will be uploaded to Redis. The Redis key will be a
|
2
|
+
# combination of the `key_prefix` and the `revision_key`. Typically this is the `project.name` property from the
|
3
|
+
# deployment context and `:index` at the end. By default this option will be `ember-cli-deploy-rack:index`.
|
4
|
+
# For more details, see <https://github.com/ember-cli-deploy/ember-cli-deploy-redis#keyprefix>.
|
5
|
+
key_prefix: 'ember-cli-deploy-rack:index'
|
6
|
+
|
7
|
+
# The suffix to be used for the Redis key under which the activated revision content will be stored in Redis. By default
|
8
|
+
# this option will be `current-content`. This makes the default activated revision in Redis looks like:
|
9
|
+
# The `project.name` property from the deployment and `:index:current-content` at the end.
|
10
|
+
# For more details, see <https://github.com/ember-cli-deploy/ember-cli-deploy-redis#activecontentsuffix>.
|
11
|
+
active_content_suffix: 'current-content'
|
12
|
+
|
13
|
+
revision:
|
14
|
+
# The regular expression to check the revision. By default this option will be `^[0-9a-f]{32}$`.
|
15
|
+
regexp: '^[0-9a-f]{32}$'
|
16
|
+
|
17
|
+
redis:
|
18
|
+
# For available options see `Redis::Client::DEFAULTS`.
|
19
|
+
url: 'redis://<PASSWORD>@<HOST>:<PORT>/<DATABASE>'
|
20
|
+
|
21
|
+
# If enabled, debug information can be viewed under `/debug`. By default this option will be `false`.
|
22
|
+
debug: false
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
|
3
|
+
root = File.expand_path '../../', __FILE__
|
4
|
+
|
5
|
+
# Configure the Rack environment.
|
6
|
+
ENV['RACK_ENV'] ||= 'test'
|
7
|
+
|
8
|
+
# Require the test object.
|
9
|
+
require 'ember/cli/deploy/rack'
|
10
|
+
|
11
|
+
# Define RSpec mixin.
|
12
|
+
module RSpecMixin
|
13
|
+
include Rack::Test::Methods
|
14
|
+
|
15
|
+
def app
|
16
|
+
Ember::CLI::Deploy::Rack::Engine
|
17
|
+
end
|
18
|
+
|
19
|
+
def fixtures
|
20
|
+
File.expand_path '../fixtures', __FILE__
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Require the spec helper.
|
25
|
+
require 'spec_helper'
|
26
|
+
|
27
|
+
# Add additional requires below this line.
|
28
|
+
|
29
|
+
# Requires supporting Ruby files with custom matchers, macros etc. in `spec/support` and its subdirectories. Files
|
30
|
+
# matching `spec/**/*_spec.rb` are run as spec files by default. This means that files in `spec/support` that end in
|
31
|
+
# `_spec.rb` will both be required and run as specs, causing the specs to be run twice. It is recommended that you do
|
32
|
+
# not name files matching this glob to end with `_spec.rb`. You can configure this pattern with the `--pattern` option
|
33
|
+
# on the command line or in `~/.rspec`, `.rspec` or `.rspec-local`.
|
34
|
+
|
35
|
+
# The following line is provided for convenience purposes. It has the downside of increasing the boot-up time by
|
36
|
+
# auto-requiring all files in the `support` directory. Alternatively, in the individual `*_spec.rb` files, manually
|
37
|
+
# require only the support files necessary.
|
38
|
+
support = File.expand_path 'spec/support', root
|
39
|
+
|
40
|
+
Dir["#{support}/**/*.rb"].each { |file| require file }
|
41
|
+
|
42
|
+
RSpec.configure do |config|
|
43
|
+
# Include the above defined RSpec mixin.
|
44
|
+
config.include RSpecMixin
|
45
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Current content revision (`current-content`)</title>
|
5
|
+
|
6
|
+
<meta charset="utf-8" />
|
7
|
+
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
|
+
|
10
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<!-- This file lives in `spec/fixtures/ember/cli/deploy/rack/engine/revision/current.html` -->
|
15
|
+
<h1>Current content revision (`current-content`)</h1>
|
16
|
+
</body>
|
17
|
+
</html>
|
data/spec/fixtures/ember/cli/deploy/rack/engine/revisions/e56b0f2850be071697ab61c41ce8f3c0.html
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Revision `e56b0f2850be071697ab61c41ce8f3c0`</title>
|
5
|
+
|
6
|
+
<meta charset="utf-8" />
|
7
|
+
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
|
+
|
10
|
+
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
11
|
+
</head>
|
12
|
+
|
13
|
+
<body>
|
14
|
+
<!-- This file lives in `spec/fixtures/ember/cli/deploy/rack/engine/revision/e56b0f2850be071697ab61c41ce8f3c0.html` -->
|
15
|
+
<h1>Revision `e56b0f2850be071697ab61c41ce8f3c0`</h1>
|
16
|
+
</body>
|
17
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec.describe Ember::CLI::Deploy::Rack::Engine do
|
2
|
+
context 'debug is enabled' do
|
3
|
+
describe '/debug' do
|
4
|
+
it 'renders debug information' do
|
5
|
+
app.settings.debug = true
|
6
|
+
|
7
|
+
get '/debug'
|
8
|
+
|
9
|
+
expect(last_response).to be_ok
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'debug is disabled' do
|
15
|
+
describe '/debug' do
|
16
|
+
it 'response with 403' do
|
17
|
+
app.settings.debug = false
|
18
|
+
|
19
|
+
get '/debug'
|
20
|
+
|
21
|
+
expect(last_response.status).to eq 403
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
RSpec.describe Ember::CLI::Deploy::Rack::Engine do
|
2
|
+
let(:key_prefix) { app.settings.key_prefix }
|
3
|
+
let(:redis) { app.settings.redis_client }
|
4
|
+
|
5
|
+
it 'response with 400 when revision is not valid' do
|
6
|
+
revision = 'invalid-revision'
|
7
|
+
|
8
|
+
get '/', revision: revision
|
9
|
+
|
10
|
+
expect(last_response.status).to eq 400
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'data available' do
|
14
|
+
describe '/' do
|
15
|
+
it 'returns the `current-content` revision as default' do
|
16
|
+
revision = 'current-content'
|
17
|
+
fixture = File.expand_path "ember/cli/deploy/rack/engine/revisions/#{revision}.html", fixtures
|
18
|
+
html = IO.read fixture
|
19
|
+
|
20
|
+
redis.set "#{key_prefix}:#{revision}", html
|
21
|
+
|
22
|
+
get '/'
|
23
|
+
|
24
|
+
expect(last_response).to be_ok
|
25
|
+
expect(last_response.body).to eq html
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a specific revision' do
|
29
|
+
revision = 'e56b0f2850be071697ab61c41ce8f3c0'
|
30
|
+
fixture = File.expand_path "ember/cli/deploy/rack/engine/revisions/#{revision}.html", fixtures
|
31
|
+
html = IO.read fixture
|
32
|
+
|
33
|
+
redis.set "#{key_prefix}:#{revision}", html
|
34
|
+
|
35
|
+
get '/', revision: revision
|
36
|
+
|
37
|
+
expect(last_response).to be_ok
|
38
|
+
expect(last_response.body).to eq html
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'no data available' do
|
44
|
+
describe '/' do
|
45
|
+
it 'response with 404' do
|
46
|
+
get '/'
|
47
|
+
|
48
|
+
expect(last_response.status).to eq 404
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# Conventionally, all specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. The `.rspec` file
|
2
|
+
# contains `--require ember_cli_deploy_rack_helper` which will cause this file to always be loaded, without a need to
|
3
|
+
# explicitly require it in any files.
|
4
|
+
#
|
5
|
+
# Given that it is always loaded, you are encouraged to keep this file as light-weight as possible. Requiring
|
6
|
+
# heavyweight dependencies from this file will add to the boot time of your test suite on EVERY test run, even for an
|
7
|
+
# individual file that may not need all of that loaded. Instead, consider making a separate helper file that requires
|
8
|
+
# the additional dependencies and performs the additional setup, and require it from the spec files that actually need
|
9
|
+
# it.
|
10
|
+
#
|
11
|
+
# The `.rspec` file also contains a few flags that are not defaults but that users commonly want.
|
12
|
+
#
|
13
|
+
# See <http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration> for more information.
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# RSpec Expectations configuration goes here. You can use an alternate assertion / expectation library such as `wrong`
|
17
|
+
# or the `stdlib/minitest` assertions if you prefer.
|
18
|
+
config.expect_with :rspec do |expectations|
|
19
|
+
# This option will default to `true` in RSpec 4. It makes the `description` and `failure_message` of custom matchers
|
20
|
+
# include text for helper methods defined using `chain`.
|
21
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
22
|
+
end
|
23
|
+
|
24
|
+
# RSpec Mocks configuration goes here. You can use an alternate test double library (such as `bogus` or `mocha`) by
|
25
|
+
# changing the `mock_with` option here.
|
26
|
+
config.mock_with :rspec do |mocks|
|
27
|
+
# Prevents you from mocking or stubbing a method that does not exist on a real object. This is generally recommended,
|
28
|
+
# and will default to `true` in RSpec 4.
|
29
|
+
mocks.verify_partial_doubles = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# The settings below are suggested to provide a good initial experience with RSpec, but feel free to customize to your
|
33
|
+
# heart's content.
|
34
|
+
|
35
|
+
# These two settings work together to allow you to limit a spec run to individual examples or groups you care about by
|
36
|
+
# tagging them with `:focus` metadata. When nothing is tagged with `:focus`, all examples get run.
|
37
|
+
config.filter_run :focus
|
38
|
+
config.run_all_when_everything_filtered = true
|
39
|
+
|
40
|
+
# Allows RSpec to persist some state between runs in order to support the `--only-failures` and `--next-failure` CLI
|
41
|
+
# options. We recommend you configure your source control system to ignore this file.
|
42
|
+
# config.example_status_persistence_file_path = 'spec/examples.txt'
|
43
|
+
|
44
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended. For more details, see:
|
45
|
+
#
|
46
|
+
# - <http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax>
|
47
|
+
# - <http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax>
|
48
|
+
# - <http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching>
|
49
|
+
config.disable_monkey_patching!
|
50
|
+
|
51
|
+
# Many RSpec users commonly either run the entire suite or an individual file, and it's useful to allow more verbose
|
52
|
+
# output when running an individual spec file.
|
53
|
+
if config.files_to_run.one?
|
54
|
+
# Use the documentation formatter for detailed output, unless a formatter has already been configured (e.g. via a
|
55
|
+
# command-line flag).
|
56
|
+
config.default_formatter = 'doc'
|
57
|
+
end
|
58
|
+
|
59
|
+
# Print the 10 slowest examples and example groups at the end of the spec run, to help surface which specs are running
|
60
|
+
# particularly slow.
|
61
|
+
config.profile_examples = 10
|
62
|
+
|
63
|
+
# Run specs in random order to surface order dependencies. If you find an order dependency and want to debug it, you
|
64
|
+
# can fix the order by providing the seed (`--seed 1234`), which is printed after each run.
|
65
|
+
config.order = :random
|
66
|
+
|
67
|
+
# Seed global randomization in this process using the `--seed` CLI option. Setting this allows you to use `--seed` to
|
68
|
+
# deterministically reproduce test failures related to randomization by passing the same `--seed` value as the one
|
69
|
+
# that triggered the failure.
|
70
|
+
Kernel.srand config.seed
|
71
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'database_cleaner'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.before(:suite) do
|
5
|
+
DatabaseCleaner[:redis, { connection: :test }].strategy = :truncation
|
6
|
+
|
7
|
+
DatabaseCleaner[:redis].clean_with :truncation
|
8
|
+
end
|
9
|
+
|
10
|
+
config.before(:each) do
|
11
|
+
DatabaseCleaner[:redis].start
|
12
|
+
end
|
13
|
+
|
14
|
+
config.after(:each) do
|
15
|
+
DatabaseCleaner[:redis].clean
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'simplecov'
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ember-cli-deploy-rack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maik Kempe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.4.6
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.4.6
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sinatra-contrib
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.4'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.4.6
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.4'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.4.6
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: haml
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '4.0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 4.0.7
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '4.0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 4.0.7
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: redis
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.2'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.2
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.2'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 3.2.2
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rake
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '10.4'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 10.4.2
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '10.4'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 10.4.2
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: rspec
|
115
|
+
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - "~>"
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '3.4'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 3.4.0
|
123
|
+
type: :development
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - "~>"
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '3.4'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 3.4.0
|
133
|
+
description:
|
134
|
+
email: mkempe@bitaculous.com
|
135
|
+
executables: []
|
136
|
+
extensions: []
|
137
|
+
extra_rdoc_files:
|
138
|
+
- CHANGELOG.md
|
139
|
+
- CONTRIBUTING.md
|
140
|
+
- LICENSE
|
141
|
+
- README.md
|
142
|
+
files:
|
143
|
+
- CHANGELOG.md
|
144
|
+
- CONTRIBUTING.md
|
145
|
+
- LICENSE
|
146
|
+
- README.md
|
147
|
+
- lib/ember/cli/deploy/rack.rb
|
148
|
+
- lib/ember/cli/deploy/rack/engine.rb
|
149
|
+
- lib/ember/cli/deploy/rack/version.rb
|
150
|
+
- lib/tasks/bundler.rake
|
151
|
+
- lib/tasks/rspec.rake
|
152
|
+
- lib/tasks/rubocop.rake
|
153
|
+
- resources/config/settings.yml
|
154
|
+
- spec/ember_cli_deploy_rack_helper.rb
|
155
|
+
- spec/fixtures/ember/cli/deploy/rack/engine/revisions/current-content.html
|
156
|
+
- spec/fixtures/ember/cli/deploy/rack/engine/revisions/e56b0f2850be071697ab61c41ce8f3c0.html
|
157
|
+
- spec/integration/ember/cli/deploy/rack/engine/views/debug_spec.rb
|
158
|
+
- spec/integration/ember/cli/deploy/rack/engine_spec.rb
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
- spec/support/database_cleaner.rb
|
161
|
+
- spec/support/simplecov.rb
|
162
|
+
homepage: https://bitaculous.github.io/ember-cli-deploy-rack/
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
metadata: {}
|
166
|
+
post_install_message:
|
167
|
+
rdoc_options: []
|
168
|
+
require_paths:
|
169
|
+
- lib
|
170
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
+
requirements:
|
172
|
+
- - "~>"
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '2.2'
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '2.4'
|
180
|
+
requirements: []
|
181
|
+
rubyforge_project:
|
182
|
+
rubygems_version: 2.5.1
|
183
|
+
signing_key:
|
184
|
+
specification_version: 4
|
185
|
+
summary: A Rack package to launch your Ember.js application into the Cloud.
|
186
|
+
test_files: []
|
187
|
+
has_rdoc:
|