component_library 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/library_controller.rb +2 -4
- data/app/models/library/component.rb +3 -2
- data/app/models/library/librarian.rb +4 -3
- data/app/views/library/_componentpattern.html.erb +1 -1
- data/app/views/library/index.html.erb +1 -1
- data/config/routes.rb +2 -2
- data/lib/component_library/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 227b79f02b500d4e1409b10eb766038b4e1dd8fb
|
4
|
+
data.tar.gz: 9edae1cfba31fd6cc0c56254de98f71231be8550
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24e931ef73a8b2c0d4e72dd34f9f081dc7f7d7e182974032d6ea7b442c512fee2aa5d17e238faecf5ef1fa84917c67e23bfac7592adba6c1d75787ca57fa5cd9
|
7
|
+
data.tar.gz: b7deb39a734ee6a7364c9f8c3116a29d83486cf1ea2ddf44092c1223fdc904785e6b3382f9a2b5ea57d6daaf950f3d173c5ff065af814cb6712ecbd57b9268db
|
@@ -6,15 +6,13 @@ class LibraryController < ApplicationController
|
|
6
6
|
|
7
7
|
def index
|
8
8
|
dir = Dir.glob("#{Rails.root}/app/views/#{@configuration[:root_directory]}/**/*.erb").sort
|
9
|
-
|
10
|
-
@library = Library::Librarian.new(dir, @configuration[:root_directory])
|
9
|
+
@library = Library::Librarian.new(dir, @configuration)
|
11
10
|
end
|
12
11
|
|
13
12
|
def show
|
14
13
|
suffix = params[:format] == 'erb' ? ".erb" : "/**/*.erb"
|
15
14
|
dir = Dir.glob("#{Rails.root}/app/views/#{@configuration[:root_directory]}/#{params[:path]}#{suffix}").sort
|
16
|
-
|
17
|
-
@library = Library::Librarian.new(dir, @configuration[:root_directory], params[:path])
|
15
|
+
@library = Library::Librarian.new(dir, @configuration, params[:path])
|
18
16
|
|
19
17
|
raise ActionController::RoutingError.new('Not Found') if @library.components.empty?
|
20
18
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module Library
|
2
2
|
class Component
|
3
|
-
def initialize(file, rootDirectory)
|
3
|
+
def initialize(file, rootDirectory, rootPath)
|
4
4
|
@file = file
|
5
5
|
@rootDirectory = rootDirectory
|
6
|
+
@rootPath = rootPath
|
6
7
|
end
|
7
8
|
|
8
9
|
def raw
|
@@ -35,7 +36,7 @@ module Library
|
|
35
36
|
while fileArray.length > 0 do
|
36
37
|
response.unshift prepareHash(fileArray)
|
37
38
|
end
|
38
|
-
h = {path: ".", name:
|
39
|
+
h = {path: ".", name: @rootPath}
|
39
40
|
response.unshift h
|
40
41
|
end
|
41
42
|
|
@@ -1,14 +1,15 @@
|
|
1
1
|
module Library
|
2
2
|
class Librarian
|
3
3
|
|
4
|
-
def initialize(files,
|
4
|
+
def initialize(files, configuration, title=nil)
|
5
5
|
@files = files
|
6
|
-
@rootDirectory =
|
6
|
+
@rootDirectory = configuration[:root_directory]
|
7
|
+
@rootPath = configuration[:root_path]
|
7
8
|
@title = title
|
8
9
|
end
|
9
10
|
|
10
11
|
def components
|
11
|
-
@files.map{ |file| Component.new(file, @rootDirectory) }
|
12
|
+
@files.map{ |file| Component.new(file, @rootDirectory, @rootPath) }
|
12
13
|
end
|
13
14
|
|
14
15
|
def title
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<% library.components.each do |component| %>
|
3
3
|
<p class="pattern--title">
|
4
4
|
<% component.paths.each do |path| %>
|
5
|
-
/<%= link_to path[:name],
|
5
|
+
/<%= link_to path[:name], component_path(@root_path, path[:path]) %>
|
6
6
|
<% end %>
|
7
7
|
</p>
|
8
8
|
<div class="pattern" id="<%= component.render.parameterize %>">
|
@@ -2,5 +2,5 @@
|
|
2
2
|
<% if @library.components.any? %>
|
3
3
|
<%= render partial: @component_template, locals: { library: @library } %>
|
4
4
|
<% else %>
|
5
|
-
<p>No html components found at <code>/app/
|
5
|
+
<p>No html.erb components found at <code>/app/views/<%= @configuration[:root_directory] %></code></p>
|
6
6
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
clc = ComponentLibrary.configuration
|
3
|
-
get ':root_path/', to: 'library#index', constraints: lambda { |request|
|
3
|
+
get ':root_path/', to: 'library#index', as: 'components', constraints: lambda { |request|
|
4
4
|
clc.root_paths.any? { |root_path| request.original_fullpath.include?(root_path)}
|
5
5
|
}
|
6
|
-
get ':root_path/*path', to: 'library#show', constraints: lambda { |request|
|
6
|
+
get ':root_path/*path', to: 'library#show', as: 'component', constraints: lambda { |request|
|
7
7
|
clc.root_paths.any? { |root_path| request.original_fullpath.include?(root_path) }
|
8
8
|
}
|
9
9
|
end
|