ember-cli-rails-deploy-redis 0.0.2 → 0.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +77 -70
- data/ember-cli-rails-deploy-redis.gemspec +2 -2
- data/lib/ember_cli/deploy/redis.rb +55 -0
- data/lib/ember_cli/deploy/redis/version.rb +7 -0
- metadata +5 -7
- data/lib/ember-cli/deploy/page.rb +0 -55
- data/lib/ember-cli/deploy/redis.rb +0 -84
- data/lib/ember-cli/deploy/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5c7f3078429466c27bcc7f640adb22618d35ed1
|
4
|
+
data.tar.gz: 7e4e2b8d539de1d7b1d28e225d35082859d3ca7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a26fe4f83931158dfdfe225543c5b21d836a25affb880a76df464afabaf22a4159ea0f9c32ef2aa3e71f16ab0221bd62829b1ca11d0393f9bb3c2abaa28005a
|
7
|
+
data.tar.gz: 8a0e9cad0901ea1e63b31dc315e9d35fc7200148fd13ec2fa5da755bfc6b28ed60f17b276ca067fcc37c7eb51b172e6b1da7e8028399a7dabaceb62772deb573
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
master
|
2
2
|
------
|
3
3
|
|
4
|
+
0.1.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
* Integrate with `ember-cli-rails` deployment strategies. [#4]
|
8
|
+
* Rename `EmberCLI` module to `EmberCli`. [#4]
|
9
|
+
* Rename `ember-cli` directories to `ember_cli`. [#4]
|
10
|
+
|
11
|
+
[#4]: https://github.com/seanpdoyle/ember-cli-rails-deploy-redis/pull/4
|
12
|
+
|
4
13
|
0.0.2
|
5
14
|
-----
|
6
15
|
|
data/README.md
CHANGED
@@ -1,119 +1,126 @@
|
|
1
|
-
#
|
1
|
+
# EmberCli::Deploy::Redis
|
2
2
|
|
3
|
-
[EmberCLI Rails] is
|
4
|
-
Rails 3.1 and up.
|
3
|
+
[EmberCLI Rails] is a tool to unify your EmberCLI and Rails Workflows.
|
5
4
|
|
6
5
|
[ember-cli-deploy] is a simple, flexible deployment for your Ember CLI app.
|
7
6
|
|
8
|
-
[ember-deploy-redis] is
|
7
|
+
[ember-cli-deploy-redis] is an `ember-cli-deploy` plugin to upload `index.html`
|
8
|
+
to a Redis store.
|
9
9
|
|
10
|
-
`ember-cli-rails-deploy-redis`
|
10
|
+
`ember-cli-rails-deploy-redis` is a gem that integrates all three.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
[ember-deploy-redis]: https://github.com/LevelbossMike/ember-deploy-redis
|
12
|
+
This project streamlines the process of pushing and serving EmberCLI-built
|
13
|
+
assets from Rails.
|
15
14
|
|
16
|
-
|
15
|
+
[EmberCLI Rails]: https://github.com/thoughtbot/ember-cli-rails
|
16
|
+
[ember-cli-deploy]: http://ember-cli.com/ember-cli-deploy/
|
17
|
+
[ember-cli-deploy-redis]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis
|
18
|
+
|
19
|
+
## Install
|
17
20
|
|
18
21
|
Add this line to your application's Gemfile:
|
19
22
|
|
20
23
|
```ruby
|
21
|
-
|
24
|
+
group :production do
|
25
|
+
gem "ember-cli-rails-deploy-redis"
|
26
|
+
end
|
22
27
|
```
|
23
28
|
|
24
29
|
And then execute:
|
25
30
|
|
26
31
|
```bash
|
27
|
-
$ bundle
|
32
|
+
$ bundle install
|
28
33
|
```
|
29
34
|
|
30
|
-
##
|
35
|
+
## Setup
|
31
36
|
|
32
|
-
|
33
|
-
|
37
|
+
First, [configure your application to integrate with
|
38
|
+
`ember-cli-rails`][ember-cli-rails-setup].
|
34
39
|
|
35
|
-
|
36
|
-
EmberCLI-
|
40
|
+
Then, to integrate with `ember-cli-deploy`'s ["Lightning Fast Deploys"][lightning]
|
41
|
+
(using the Redis adapter) in `production`, instantiate configure EmberCLI-Rails
|
42
|
+
to deploy with the `EmberCli::Deploy::Redis` strategy:
|
37
43
|
|
38
|
-
|
39
|
-
(using the Redis adapter), instantiate an `EmberCLI::Deploy::Redis`
|
40
|
-
in your controller:
|
44
|
+
[ember-cli-rails-setup]: https://github.com/thoughtbot/ember-cli-rails#setup
|
41
45
|
|
42
46
|
```ruby
|
43
|
-
|
44
|
-
|
45
|
-
class ApplicationController < ActionController::Base
|
46
|
-
def index
|
47
|
-
@deploy = EmberCLI::Deploy::Redis.new(namespace: "frontend")
|
47
|
+
# config/initializers/ember.rb
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
EmberCli.configure do |config|
|
50
|
+
config.app :frontend, deploy: { production: EmberCli::Deploy::Redis }
|
51
51
|
end
|
52
52
|
```
|
53
53
|
|
54
|
-
|
55
|
-
your initializer) and handles all interaction with the Redis instance.
|
54
|
+
Finally, set `ENV["REDIS_URL"]` to the URL [ember-cli-deploy-redis references][redis-config].
|
56
55
|
|
57
|
-
|
58
|
-
step
|
56
|
+
If you're deploying from Redis in `development` or `test`, disable
|
57
|
+
EmberCLI-Rails' build step by setting `ENV["SKIP_EMBER"] = true`.
|
59
58
|
|
60
|
-
|
61
|
-
will replace the call to the Redis instance. This allows integration with the
|
62
|
-
normal `ember-cli-rails` workflow:
|
59
|
+
[redis-config]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis#configuration-options
|
63
60
|
|
64
|
-
|
65
|
-
require "ember-cli/deploy/redis"
|
61
|
+
## Deploy
|
66
62
|
|
67
|
-
|
68
|
-
def index
|
69
|
-
@deploy = EmberCLI::Deploy::Redis.new(
|
70
|
-
namespace: "frontend",
|
71
|
-
index_html: index_html,
|
72
|
-
)
|
63
|
+
Deploy your application through [ember-cli-deploy-redis][deploy].
|
73
64
|
|
74
|
-
|
75
|
-
end
|
65
|
+
[deploy]: https://github.com/ember-cli-deploy/ember-cli-deploy-redis#quick-start
|
76
66
|
|
77
|
-
|
67
|
+
## Use without `ember-cli-rails`
|
78
68
|
|
79
|
-
|
80
|
-
|
81
|
-
render_to_string(:index)
|
82
|
-
end
|
83
|
-
end
|
69
|
+
Although this gem was designed to integrate with `ember-cli-rails`, there isn't
|
70
|
+
a direct dependency on it.
|
84
71
|
|
85
|
-
|
86
|
-
! %w[production staging].include?(Rails.env)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
```
|
72
|
+
Similar behavior can be achieved by using a gem like [`html_page`][html_page]:
|
90
73
|
|
91
|
-
|
92
|
-
controllers to inject additional markup, such as metadata, CSRF tokens, or
|
93
|
-
analytics tags:
|
74
|
+
[html_page]: https://github.com/seanpdoyle/html_page
|
94
75
|
|
76
|
+
```rb
|
77
|
+
require "html_page"
|
95
78
|
|
96
|
-
|
97
|
-
|
79
|
+
class EmberHelper
|
80
|
+
def render_html(html)
|
81
|
+
capturer = HtmlPage::Capture.new(self, &block)
|
98
82
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
83
|
+
head, body = capturer.capture
|
84
|
+
|
85
|
+
renderer = HtmlPage::Renderer.new(
|
86
|
+
content: html,
|
87
|
+
head: head,
|
88
|
+
body: body,
|
104
89
|
)
|
105
90
|
|
106
|
-
|
107
|
-
|
91
|
+
render inline: renderer.render
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class EmberController
|
96
|
+
def index
|
97
|
+
redis = EmberCli::Deploy::Redis.new(ember_app)
|
108
98
|
|
109
|
-
|
99
|
+
@html_from_redis = redis.index_html
|
100
|
+
|
101
|
+
render layout: false
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def ember_app
|
107
|
+
OpenStruct.new(name: "my-ember-app")
|
110
108
|
end
|
111
|
-
# ...
|
112
109
|
end
|
113
110
|
```
|
114
111
|
|
115
|
-
|
116
|
-
|
112
|
+
```erb
|
113
|
+
<!-- app/views/ember/index.html.erb -->
|
114
|
+
<%= render_html @html_from_redis do |head, body| %>
|
115
|
+
<% head.append do %>
|
116
|
+
<title>Appended to the `head` element</title>
|
117
|
+
<% end %>
|
118
|
+
|
119
|
+
<% body.append do %>
|
120
|
+
<p>Appended to the `body` element</p>
|
121
|
+
<% end %>
|
122
|
+
<% end %>
|
123
|
+
```
|
117
124
|
|
118
125
|
## Development
|
119
126
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "
|
4
|
+
require "ember_cli/deploy/redis/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "ember-cli-rails-deploy-redis"
|
8
|
-
spec.version =
|
8
|
+
spec.version = EmberCli::Deploy::Redis::VERSION
|
9
9
|
spec.authors = ["Sean Doyle"]
|
10
10
|
spec.email = ["sean.p.doyle24@gmail.com"]
|
11
11
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
|
+
require "redis"
|
3
|
+
|
4
|
+
module EmberCli
|
5
|
+
module Deploy
|
6
|
+
class Redis
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def index_html
|
12
|
+
redis_client.get(deploy_key).presence || index_html_missing!
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :app
|
18
|
+
|
19
|
+
def redis_client
|
20
|
+
@redis_client ||= ::Redis.new(url: ENV.fetch("REDIS_URL"))
|
21
|
+
end
|
22
|
+
|
23
|
+
def namespace
|
24
|
+
app.name
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_key
|
28
|
+
"#{namespace}:current"
|
29
|
+
end
|
30
|
+
|
31
|
+
def deploy_key
|
32
|
+
key = redis_client.get(current_key).presence ||
|
33
|
+
deployment_not_activated!
|
34
|
+
|
35
|
+
"#{namespace}:#{key}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def index_html_missing!
|
39
|
+
raise KeyError.new <<-FAIL
|
40
|
+
HTML for #{deploy_key} is missing.
|
41
|
+
|
42
|
+
Did you forget to call `ember deploy`?
|
43
|
+
FAIL
|
44
|
+
end
|
45
|
+
|
46
|
+
def deployment_not_activated!
|
47
|
+
raise KeyError.new <<-FAIL
|
48
|
+
#{current_key} is empty.
|
49
|
+
|
50
|
+
Did you forget to call `ember deploy:activate`?
|
51
|
+
FAIL
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ember-cli-rails-deploy-redis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Doyle
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -147,9 +147,8 @@ files:
|
|
147
147
|
- bin/console
|
148
148
|
- bin/setup
|
149
149
|
- ember-cli-rails-deploy-redis.gemspec
|
150
|
-
- lib/
|
151
|
-
- lib/
|
152
|
-
- lib/ember-cli/deploy/version.rb
|
150
|
+
- lib/ember_cli/deploy/redis.rb
|
151
|
+
- lib/ember_cli/deploy/redis/version.rb
|
153
152
|
homepage: https://github.com/seanpdoyle/ember-cli-rails-deploy-redis
|
154
153
|
licenses:
|
155
154
|
- MIT
|
@@ -170,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
169
|
version: '0'
|
171
170
|
requirements: []
|
172
171
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.5.
|
172
|
+
rubygems_version: 2.4.5.1
|
174
173
|
signing_key:
|
175
174
|
specification_version: 4
|
176
175
|
summary: Lightning Fast deploys with ember-cli-rails
|
177
176
|
test_files: []
|
178
|
-
has_rdoc:
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module EmberCLI
|
2
|
-
module Deploy
|
3
|
-
class Page
|
4
|
-
def initialize(html:)
|
5
|
-
@html = html.clone
|
6
|
-
@body_markup = []
|
7
|
-
@head_markup = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def build
|
11
|
-
if has_head?
|
12
|
-
head_markup.each do |markup|
|
13
|
-
html.insert(head_position, markup)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
if has_body?
|
18
|
-
body_markup.each do |markup|
|
19
|
-
html.insert(body_position, markup)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
html
|
24
|
-
end
|
25
|
-
|
26
|
-
def append_to_body(markup)
|
27
|
-
body_markup << markup
|
28
|
-
end
|
29
|
-
|
30
|
-
def append_to_head(markup)
|
31
|
-
head_markup << markup
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
attr_reader :body_markup, :head_markup, :html
|
37
|
-
|
38
|
-
def has_head?
|
39
|
-
html.include?("<head")
|
40
|
-
end
|
41
|
-
|
42
|
-
def has_body?
|
43
|
-
html.include?("<body")
|
44
|
-
end
|
45
|
-
|
46
|
-
def head_position
|
47
|
-
html.index("</head")
|
48
|
-
end
|
49
|
-
|
50
|
-
def body_position
|
51
|
-
html.index("</body")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require "active_support/core_ext/object/blank"
|
2
|
-
require "ember-cli/deploy/page"
|
3
|
-
require "redis"
|
4
|
-
|
5
|
-
module EmberCLI
|
6
|
-
module Deploy
|
7
|
-
class Redis
|
8
|
-
def initialize(namespace:, index_html: nil, redis_client: build_client)
|
9
|
-
@redis_client = redis_client
|
10
|
-
@namespace = namespace
|
11
|
-
@index_html = index_html
|
12
|
-
@body_markup = []
|
13
|
-
@head_markup = []
|
14
|
-
end
|
15
|
-
|
16
|
-
def append_to_body(markup)
|
17
|
-
body_markup << markup
|
18
|
-
end
|
19
|
-
|
20
|
-
def append_to_head(markup)
|
21
|
-
head_markup << markup
|
22
|
-
end
|
23
|
-
|
24
|
-
def html
|
25
|
-
if index_html.present?
|
26
|
-
page = Page.new(html: index_html)
|
27
|
-
|
28
|
-
body_markup.each do |markup|
|
29
|
-
page.append_to_body(markup)
|
30
|
-
end
|
31
|
-
|
32
|
-
head_markup.each do |markup|
|
33
|
-
page.append_to_head(markup)
|
34
|
-
end
|
35
|
-
|
36
|
-
page.build
|
37
|
-
else
|
38
|
-
index_html_missing!
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
attr_reader :body_markup, :head_markup, :namespace, :redis_client
|
45
|
-
|
46
|
-
def index_html
|
47
|
-
@index_html ||= redis_client.get(deploy_key).presence
|
48
|
-
end
|
49
|
-
|
50
|
-
def current_key
|
51
|
-
"#{namespace}:current"
|
52
|
-
end
|
53
|
-
|
54
|
-
def deploy_key
|
55
|
-
key = redis_client.get(current_key).presence || deployment_not_activated!
|
56
|
-
"#{namespace}:#{key}"
|
57
|
-
end
|
58
|
-
|
59
|
-
def build_client
|
60
|
-
::Redis.new(url: ENV.fetch("REDIS_URL"))
|
61
|
-
end
|
62
|
-
|
63
|
-
def index_html_missing!
|
64
|
-
message = <<-FAIL
|
65
|
-
HTML for #{deploy_key} is missing.
|
66
|
-
|
67
|
-
Did you forget to call `ember deploy`?
|
68
|
-
FAIL
|
69
|
-
|
70
|
-
raise KeyError, message
|
71
|
-
end
|
72
|
-
|
73
|
-
def deployment_not_activated!
|
74
|
-
message = <<-FAIL
|
75
|
-
#{current_key} is empty.
|
76
|
-
|
77
|
-
Did you forget to call `ember deploy:activate`?
|
78
|
-
FAIL
|
79
|
-
|
80
|
-
raise KeyError, message
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|