component_library 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f948028f3babe799c67e8dffd6789092339401db
4
- data.tar.gz: e2aab31127f0e2de4a06633b5c50fe31755f29e7
3
+ metadata.gz: 227b79f02b500d4e1409b10eb766038b4e1dd8fb
4
+ data.tar.gz: 9edae1cfba31fd6cc0c56254de98f71231be8550
5
5
  SHA512:
6
- metadata.gz: cbdef274f682d103d9c77c12e236fc9ced05fead2ca036d104de9659e8c4c9b976637bdbd6f30308d2054a55dbfc7ae856ae3ad685b3b725a96a49e05b1c9528
7
- data.tar.gz: da237b9fca36849ffb4f2e7c63d9371299dfa73993a6656ff1bd1f1d611ac32568b9b9f6aa8a524860376981bb18b56588b673d63ea1c5f4f2cddf732f9f3336
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: "components"}
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, rootDirectory, title=nil)
4
+ def initialize(files, configuration, title=nil)
5
5
  @files = files
6
- @rootDirectory = 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/view/<%= ComponentLibrary.configuration.root_directory %></code></p>
5
+ <p>No html.erb components found at <code>/app/views/<%= @configuration[:root_directory] %></code></p>
6
6
  <% end %>
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ComponentLibrary
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: component_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich Archer