nacelle 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.byebug_history +22 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/app/controllers/admin/cells_controller.rb +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/routes.rb +6 -0
- data/lib/nacelle.rb +13 -0
- data/lib/nacelle/cells_ext.rb +28 -0
- data/lib/nacelle/middleware.rb +48 -0
- data/lib/nacelle/version.rb +3 -0
- data/nacelle.gemspec +30 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22e80566ff4a1407bd07ac2519ceb84f45c354e7
|
4
|
+
data.tar.gz: 129e8cbbdf6c777549d17c55ae0bb0141fbdd681
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c59cebe992329fc4bb80659005da6867fe1a9241d68b44d8a2f08747edff8401562dec8f3518307222cfdeb0ae52d5faae03324998c83e9fc2f1a56914a5c53
|
7
|
+
data.tar.gz: 6f85b7a28a057fce45eaae53dd818f0a09d252573b6cdfbb834b4cd004dd54f8ac5e760c059414c94f9c3a20538b6eff28a5cd802a7b85377c5aba38f5998fbe
|
data/.byebug_history
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
c
|
2
|
+
kkc
|
3
|
+
q
|
4
|
+
puts TestApp.middleware.middlewares.map(&:name)
|
5
|
+
puts TestApp.middleware.middlewares
|
6
|
+
q
|
7
|
+
puts TestApp.middleware.middlewares.last.name
|
8
|
+
puts TestApp.middleware.middlewares.last
|
9
|
+
q
|
10
|
+
puts TestApp.middleware.middlewares.map(&:name)
|
11
|
+
q
|
12
|
+
n
|
13
|
+
q
|
14
|
+
puts TestApp.middleware.middlewares.map(&:name)
|
15
|
+
q
|
16
|
+
puts TestApp.middleware.middlewares.map(&:name)
|
17
|
+
q
|
18
|
+
puts TestApp.middleware.middlewares.map(&:name)
|
19
|
+
TestApp.middleware.middlewares.map(&:name)
|
20
|
+
TestApp.middleware.middlewares
|
21
|
+
TestApp.middleware
|
22
|
+
TestApp.middlewares
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
nacelle
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.2.6
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Micah Geisel
|
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,39 @@
|
|
1
|
+
# Nacelle
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nacelle`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'nacelle'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install nacelle
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/nacelle/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Admin::CellsController < Admin::BaseController
|
2
|
+
def index
|
3
|
+
@cells = Cell.all
|
4
|
+
|
5
|
+
respond_to do |format|
|
6
|
+
format.xml { render :xml => @cells.to_xml(:root => 'cells', :skip_types => true) }
|
7
|
+
format.json { render :json => { cells: @cells.map(&:to_json).flatten } }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nacelle"
|
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
data/config/routes.rb
ADDED
data/lib/nacelle.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rails/all"
|
2
|
+
require "cells"
|
3
|
+
require "nacelle/version"
|
4
|
+
require "nacelle/middleware"
|
5
|
+
require "nacelle/cells_ext"
|
6
|
+
|
7
|
+
module Nacelle
|
8
|
+
class Engine < ::Rails::Engine
|
9
|
+
initializer "nacelle.init" do |app|
|
10
|
+
app.config.middleware.use Nacelle::Middleware
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Cell
|
2
|
+
class << self
|
3
|
+
def to_json
|
4
|
+
cell_name = self.to_s.sub("Cell", "").underscore
|
5
|
+
action_methods.map do |state|
|
6
|
+
{
|
7
|
+
id: "#{cell_name}/#{state.to_s}",
|
8
|
+
name: "#{cell_name.humanize} #{state.to_s.humanize}",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def all
|
14
|
+
@all ||= begin
|
15
|
+
require_all_cells
|
16
|
+
BaseCell.subclasses
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def require_all_cells
|
23
|
+
# TODO pull in cells from engines, too
|
24
|
+
cell_files = Dir[::Rails.root.join('app/cells/*.rb')]
|
25
|
+
cell_files.each { |cell_file| require cell_file }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Nacelle
|
2
|
+
class Middleware
|
3
|
+
def initialize app
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call env
|
8
|
+
status, headers, body = @app.call env
|
9
|
+
return [status, headers, body] unless headers["Content-Type"].try(:include?, "text/html")
|
10
|
+
|
11
|
+
new_body = ""
|
12
|
+
body.each { |part| new_body << part }
|
13
|
+
process! new_body
|
14
|
+
headers["Content-Length"] = new_body.length.to_s
|
15
|
+
[status, headers, [new_body]]
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def process! body
|
21
|
+
cells = cells body
|
22
|
+
|
23
|
+
body.gsub!(/(#{cells.keys.join('|')})/) do |tag|
|
24
|
+
name, state, attrs = cells[tag]
|
25
|
+
attrs = HashWithIndifferentAccess.new(attrs)
|
26
|
+
cell = "#{name.camelize}Cell".constantize.new
|
27
|
+
args = [state]
|
28
|
+
attrs.delete "class" # ignore styling class
|
29
|
+
args << attrs unless attrs.empty?
|
30
|
+
begin
|
31
|
+
cell.render_state *args
|
32
|
+
rescue AbstractController::ActionNotFound
|
33
|
+
"<strong>Cell “#{name.capitalize} #{state}” not found!</strong>"
|
34
|
+
end
|
35
|
+
end unless cells.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def cells body
|
39
|
+
body.scan(/(<cell[^>]*\/\s*>|<cell[^>]*>.*?<\/cell>)/m).inject({}) do |cells, matches|
|
40
|
+
tag = matches.first
|
41
|
+
attrs = Hash.from_xml(tag)['cell']
|
42
|
+
name, state = attrs.delete('name').split('/')
|
43
|
+
cells[tag] = [name, state, attrs]
|
44
|
+
cells
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/nacelle.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nacelle/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nacelle"
|
8
|
+
spec.version = Nacelle::VERSION
|
9
|
+
spec.authors = ["Micah Geisel"]
|
10
|
+
spec.email = ["micah@botandrose.com"]
|
11
|
+
|
12
|
+
spec.summary = "Embed cells in the markup of your CMS."
|
13
|
+
spec.description = "Embed cells in the markup of your CMS."
|
14
|
+
spec.homepage = "https://github.com/botandrose/nacelle"
|
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_development_dependency "bundler", "~> 1.9"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
spec.add_development_dependency "capybara"
|
26
|
+
spec.add_development_dependency "byebug"
|
27
|
+
|
28
|
+
spec.add_dependency "rails"
|
29
|
+
spec.add_dependency "cells", "~>3.0"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nacelle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Micah Geisel
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
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: cells
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
description: Embed cells in the markup of your CMS.
|
112
|
+
email:
|
113
|
+
- micah@botandrose.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".byebug_history"
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".ruby-gemset"
|
122
|
+
- ".ruby-version"
|
123
|
+
- ".travis.yml"
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- app/controllers/admin/cells_controller.rb
|
129
|
+
- bin/console
|
130
|
+
- bin/setup
|
131
|
+
- config/routes.rb
|
132
|
+
- lib/nacelle.rb
|
133
|
+
- lib/nacelle/cells_ext.rb
|
134
|
+
- lib/nacelle/middleware.rb
|
135
|
+
- lib/nacelle/version.rb
|
136
|
+
- nacelle.gemspec
|
137
|
+
homepage: https://github.com/botandrose/nacelle
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.4.8
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Embed cells in the markup of your CMS.
|
161
|
+
test_files: []
|