ember-cli-rails-deploy-redis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1ea2cca772b7169bd2fcc9fd8029f5b1078a1cc
4
+ data.tar.gz: aeb1189d85e41a1cd404c9d20e615237281de410
5
+ SHA512:
6
+ metadata.gz: 882f9727de085ee330028ad05162ee05c8b8103d50dfdd90a491e72fa31131909ca7eacf0e36c02936a73c8f546452ffe3a65142c97a58316b5c210ebab7d914
7
+ data.tar.gz: 9bf5a49ef7583049848fbee9b92b66318e3a7e29c7c841a66ba036ddb5c5c8e93c64bc176d12fb975889fc93247f85afa40f1934b0a000b3307402612613b190
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
5
+ notifications:
6
+ email: false
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ember-cli-rails-deploy-redis.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sean Doyle
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,132 @@
1
+ # EmberCLI::Rails - Deploy Redis
2
+
3
+ [EmberCLI Rails] is an integration story between (surprise suprise) EmberCLI and
4
+ Rails 3.1 and up.
5
+
6
+ [ember-cli-deploy] is a simple, flexible deployment for your Ember CLI app.
7
+
8
+ [ember-deploy-redis] is the redis-adapter implementation to use Redis with ember-deploy.
9
+
10
+ `ember-cli-rails-deploy-redis` wires up all three.
11
+
12
+ [EmberCLI Rails]: https://github.com/rwz/ember-cli-rails
13
+ [ember-cli-deploy]: https://github.com/ember-cli/ember-cli-deploy
14
+ [ember-deploy-redis]: https://github.com/LevelbossMike/ember-deploy-redis
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'ember-cli-rails-deploy-redis'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```bash
27
+ $ bundle
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ The EmberCLI community recently unified the various deployment techniques into a
33
+ single, core-team supported project: [ember-cli-deploy][ember-cli-deploy].
34
+
35
+ This project attempts to streamline the process of pushing and serving
36
+ EmberCLI-built static assets.
37
+
38
+ To integrate with `ember-cli-deploy`'s ["Lightning Fast Deploys"][lightning]
39
+ (using the Redis adapter), instantiate an `EmberCLI::Deploy::Redis`
40
+ in your controller:
41
+
42
+ ```ruby
43
+ require "ember-cli/deploy/redis"
44
+
45
+ class ApplicationController < ActionController::Base
46
+ def index
47
+ @deploy = EmberCLI::Deploy::Redis.new(namespace: "frontend")
48
+
49
+ render text: @deploy.html, layout: false
50
+ end
51
+ end
52
+ ```
53
+
54
+ `EmberCLI::Deploy::Redis` takes a `namespace` (the name of your app declared in
55
+ your initializer) and handles all interaction with the Redis instance.
56
+
57
+ This is great for `staging` and `production` deploys, but introduces an extra
58
+ step in the feedback loop during development.
59
+
60
+ Luckily, `EmberCLI::Deploy::Redis` also accepts an `index_html` override, which
61
+ will replace the call to the Redis instance. This allows integration with the
62
+ normal `ember-cli-rails` workflow:
63
+
64
+ ```ruby
65
+ require "ember-cli/deploy/redis"
66
+
67
+ class ApplicationController < ActionController::Base
68
+ def index
69
+ @deploy = EmberCLI::Deploy::Redis.new(
70
+ namespace: "frontend",
71
+ index_html: index_html,
72
+ )
73
+
74
+ render text: @deploy.html, layout: false
75
+ end
76
+
77
+ private
78
+
79
+ def index_html
80
+ if serve_with_ember_cli_rails?
81
+ render_to_string(:index)
82
+ end
83
+ end
84
+
85
+ def serve_with_ember_cli_rails?
86
+ ! %w[production staging].include?(Rails.env)
87
+ end
88
+ end
89
+ ```
90
+
91
+ Additionally, having access to the outbound HTML beforehand also enables
92
+ controllers to inject additional markup, such as metadata, CSRF tokens, or
93
+ analytics tags:
94
+
95
+
96
+ ```ruby
97
+ require "ember-cli/deploy"
98
+
99
+ class ApplicationController < ActionController::Base
100
+ def index
101
+ @deploy = EmberCLI::Deploy::Redis.new(
102
+ namespace: "frontend",
103
+ index_html: index_html,
104
+ )
105
+
106
+ @deploy.append_to_head(render_to_string(partial: "my_csrf_and_metadata")
107
+ @deploy.append_to_body(render_to_string(partial: "my_analytics")
108
+
109
+ render text: @deploy.html, layout: false
110
+ end
111
+ # ...
112
+ end
113
+ ```
114
+
115
+ [ember-cli-deploy]: https://github.com/ember-cli/ember-cli-deploy
116
+ [lightning]: https://github.com/ember-cli/ember-cli-deploy#lightning-approach-workflow
117
+
118
+ ## Development
119
+
120
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
121
+
122
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ember-cli-rails-deploy-redis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
127
+
128
+
129
+ ## License
130
+
131
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
132
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ember/cli/rails/deploy/redis"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ember-cli/deploy/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ember-cli-rails-deploy-redis"
8
+ spec.version = EmberCLI::Rails::Deploy::VERSION
9
+ spec.authors = ["Sean Doyle"]
10
+ spec.email = ["sean.p.doyle24@gmail.com"]
11
+
12
+ spec.summary = %q{Lightning Fast deploys with ember-cli-rails}
13
+ spec.description = %q{Lightning Fast deploys with ember-cli-rails}
14
+ spec.homepage = "https://github.com/seanpdoyle/ember-cli-rails-deploy-redis"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "railties", ">= 3.1", "< 5"
23
+ spec.add_dependency "redis", ">= 3.0"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec"
28
+ spec.add_development_dependency "climate_control"
29
+ spec.add_development_dependency "fakeredis"
30
+ spec.add_development_dependency "pry"
31
+ end
@@ -0,0 +1,55 @@
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
@@ -0,0 +1,83 @@
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
+ redis_client.get(current_key).presence || deployment_not_activated!
56
+ end
57
+
58
+ def build_client
59
+ ::Redis.new(url: ENV.fetch("REDIS_URL"))
60
+ end
61
+
62
+ def index_html_missing!
63
+ message = <<-FAIL
64
+ HTML for #{deploy_key} is missing.
65
+
66
+ Did you forget to call `ember deploy`?
67
+ FAIL
68
+
69
+ raise KeyError, message
70
+ end
71
+
72
+ def deployment_not_activated!
73
+ message = <<-FAIL
74
+ #{current_key} is empty.
75
+
76
+ Did you forget to call `ember deploy:activate`?
77
+ FAIL
78
+
79
+ raise KeyError, message
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,7 @@
1
+ module EmberCLI
2
+ module Rails
3
+ module Deploy
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ember-cli-rails-deploy-redis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Doyle
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5'
33
+ - !ruby/object:Gem::Dependency
34
+ name: redis
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.10'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.10'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: climate_control
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: fakeredis
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: pry
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ description: Lightning Fast deploys with ember-cli-rails
132
+ email:
133
+ - sean.p.doyle24@gmail.com
134
+ executables: []
135
+ extensions: []
136
+ extra_rdoc_files: []
137
+ files:
138
+ - ".gitignore"
139
+ - ".rspec"
140
+ - ".travis.yml"
141
+ - CODE_OF_CONDUCT.md
142
+ - Gemfile
143
+ - LICENSE.txt
144
+ - README.md
145
+ - Rakefile
146
+ - bin/console
147
+ - bin/setup
148
+ - ember-cli-rails-deploy-redis.gemspec
149
+ - lib/ember-cli/deploy/page.rb
150
+ - lib/ember-cli/deploy/redis.rb
151
+ - lib/ember-cli/deploy/version.rb
152
+ homepage: https://github.com/seanpdoyle/ember-cli-rails-deploy-redis
153
+ licenses:
154
+ - MIT
155
+ metadata: {}
156
+ post_install_message:
157
+ rdoc_options: []
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
170
+ requirements: []
171
+ rubyforge_project:
172
+ rubygems_version: 2.4.8
173
+ signing_key:
174
+ specification_version: 4
175
+ summary: Lightning Fast deploys with ember-cli-rails
176
+ test_files: []
177
+ has_rdoc: