karasi 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +45 -5
- data/app/controllers/karasi/karasi_controller.rb +41 -0
- data/config/routes.rb +3 -0
- data/lib/karasi.rb +1 -0
- data/lib/karasi/engine.rb +5 -0
- data/lib/karasi/version.rb +1 -1
- metadata +4 -2
- data/Gemfile.lock +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adbacd92b9c3a47dfb47a380183163af868c3e58c0dc3360042c64c2aa54723a
|
4
|
+
data.tar.gz: 6fb6f98074b5dad9e7d6cfdb16c2b99586ac40d4a55ec790e621c9721633a1a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72db440a90721ef71a14ee7817e6b13a8e2811e373d67bfbf53d433747ed085b225964c866d7e81cd50ab5eea5b392fe7dc2158ce695cbc9296bc5f3b253ec9e
|
7
|
+
data.tar.gz: ff7936c1b6484d726009597ceae83eb5a251ce8e1e082b61566267be7189c67aaadb1b1ffec6f07d8ea9d419b0dbb496c32a5c72e39b1653d6af9867162ae8d6
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
# Karasi
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
**Karasi** previewable your `rails` application views without controllers implementation.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem 'karasi'
|
10
|
+
gem 'karasi', group: :development
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
@@ -22,7 +20,45 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
### config/routes.rb
|
24
|
+
|
25
|
+
#### Subdomain access with Rails engine
|
26
|
+
```
|
27
|
+
constraints subdomain: 'preview' do
|
28
|
+
mount Karasi::Engine, at: '/'
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Path access
|
33
|
+
|
34
|
+
```
|
35
|
+
get 'preview/*path', to: 'karasi/karasi#show'
|
36
|
+
```
|
37
|
+
|
38
|
+
### config/karasi.yml
|
39
|
+
|
40
|
+
```
|
41
|
+
hello/index:
|
42
|
+
title: Hello world!
|
43
|
+
"@message": This is example application.
|
44
|
+
```
|
45
|
+
|
46
|
+
### app/views/hello/index.erb
|
47
|
+
|
48
|
+
```
|
49
|
+
<h1><%= title %></h1>
|
50
|
+
<p><%= @message %></p>
|
51
|
+
```
|
52
|
+
|
53
|
+
And access to `/hello/index` show to the hello messages.
|
54
|
+
|
55
|
+
### Use layout
|
56
|
+
|
57
|
+
Add `config/karasi.yml` to
|
58
|
+
|
59
|
+
```
|
60
|
+
layout: application
|
61
|
+
```
|
26
62
|
|
27
63
|
## Development
|
28
64
|
|
@@ -33,3 +69,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
33
69
|
## Contributing
|
34
70
|
|
35
71
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/karasi.
|
72
|
+
|
73
|
+
## TODO
|
74
|
+
|
75
|
+
* helpers
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Karasi::KarasiController < ActionController::Base
|
2
|
+
def show
|
3
|
+
render '/' + path, layout: layout, locals: locals
|
4
|
+
end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def path; params[:path]; end
|
9
|
+
|
10
|
+
def root_template_params
|
11
|
+
YAML.load_file('config/karasi.yml').symbolize_keys
|
12
|
+
end
|
13
|
+
|
14
|
+
def template_params
|
15
|
+
YAML.load_file('config/karasi.yml')[path].symbolize_keys
|
16
|
+
end
|
17
|
+
|
18
|
+
def locals
|
19
|
+
template_params.map do |key,value|
|
20
|
+
{ key => deep_structize(value) }
|
21
|
+
end.inject(:merge)
|
22
|
+
end
|
23
|
+
|
24
|
+
def deep_structize(params)
|
25
|
+
if params.is_a? Array
|
26
|
+
params.map(&method(:deep_structize))
|
27
|
+
elsif params.is_a? Hash
|
28
|
+
params.symbolize_keys!
|
29
|
+
children = params.symbolize_keys.map do |key,value|
|
30
|
+
{ key => deep_structize(value) }
|
31
|
+
end.inject(:merge)
|
32
|
+
OpenStruct.new(children)
|
33
|
+
else
|
34
|
+
params
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def layout
|
39
|
+
template_params[:layout] || root_template_params[:layout]
|
40
|
+
end
|
41
|
+
end
|
data/config/routes.rb
ADDED
data/lib/karasi.rb
CHANGED
data/lib/karasi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karasi
|
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
|
- Akira SUENAMI
|
@@ -63,13 +63,15 @@ files:
|
|
63
63
|
- ".rspec"
|
64
64
|
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
|
-
- Gemfile.lock
|
67
66
|
- README.md
|
68
67
|
- Rakefile
|
68
|
+
- app/controllers/karasi/karasi_controller.rb
|
69
69
|
- bin/console
|
70
70
|
- bin/setup
|
71
|
+
- config/routes.rb
|
71
72
|
- karasi.gemspec
|
72
73
|
- lib/karasi.rb
|
74
|
+
- lib/karasi/engine.rb
|
73
75
|
- lib/karasi/version.rb
|
74
76
|
homepage: ''
|
75
77
|
licenses: []
|
data/Gemfile.lock
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
karasi (0.0.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.3)
|
10
|
-
rake (10.5.0)
|
11
|
-
rspec (3.8.0)
|
12
|
-
rspec-core (~> 3.8.0)
|
13
|
-
rspec-expectations (~> 3.8.0)
|
14
|
-
rspec-mocks (~> 3.8.0)
|
15
|
-
rspec-core (3.8.0)
|
16
|
-
rspec-support (~> 3.8.0)
|
17
|
-
rspec-expectations (3.8.2)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.8.0)
|
20
|
-
rspec-mocks (3.8.0)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.8.0)
|
23
|
-
rspec-support (3.8.0)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
bundler (~> 1.16)
|
30
|
-
karasi!
|
31
|
-
rake (~> 10.0)
|
32
|
-
rspec (~> 3.0)
|
33
|
-
|
34
|
-
BUNDLED WITH
|
35
|
-
1.16.2
|