g5_component_garden 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +5 -0
- data/README.md +98 -0
- data/Rakefile +1 -0
- data/app/controllers/components_controller.rb +12 -0
- data/app/decorators/component_decorator.rb +17 -0
- data/app/views/components/_component.html.erb +104 -0
- data/app/views/components/index.html.erb +3 -0
- data/app/views/components/show.html.erb +1 -0
- data/config/routes.rb +5 -0
- data/g5_component_garden.gemspec +28 -0
- data/lib/g5_component_garden.rb +104 -0
- data/lib/g5_component_garden/engine.rb +4 -0
- data/lib/g5_component_garden/version.rb +3 -0
- data/spec/decorators/component_decorator_spec.rb +28 -0
- data/spec/dummy/config/application.rb +18 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/lib/g5_component_garden_spec.rb +201 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/support/components/name-of-component/edit.html +1 -0
- data/spec/support/components/name-of-component/images/test.png +0 -0
- data/spec/support/components/name-of-component/images/thumbnail.png +0 -0
- data/spec/support/components/name-of-component/index.html +45 -0
- data/spec/support/components/name-of-component/javascripts/name-of-component.js +0 -0
- data/spec/support/components/name-of-component/show.html +1 -0
- data/spec/support/components/name-of-component/stylesheets/name-of-component.css +0 -0
- data/spec/support/components/name-of-component/stylesheets/name-of-other-component.css +0 -0
- metadata +239 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# G5 Component Garden
|
2
|
+
|
3
|
+
Generates components from static files and provides routes for Gardens.
|
4
|
+
|
5
|
+
|
6
|
+
## Current Version
|
7
|
+
|
8
|
+
0.2.1
|
9
|
+
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
* ["rails", "~> 3.2.0"](http://rubygems.org/gems/rails)
|
14
|
+
* ["microformats2", "2.0.0.pre4"](https://github.com/g5/microformats2)
|
15
|
+
|
16
|
+
|
17
|
+
### Gemfile
|
18
|
+
|
19
|
+
Add these lines to your application's Gemfile.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
source "https://gems.gemfury.com/88yeKzEGfizstwBaXVqj/"
|
23
|
+
|
24
|
+
gem "g5_component_garden"
|
25
|
+
```
|
26
|
+
|
27
|
+
### From Gemfury Command line
|
28
|
+
|
29
|
+
Add the Source URL to your .gemrc with this command:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
gem sources -a https://gems.gemfury.com/88yeKzEGfizstwBaXVqj/
|
33
|
+
gem install g5_component_garden
|
34
|
+
```
|
35
|
+
|
36
|
+
Or use it a single install:
|
37
|
+
|
38
|
+
```
|
39
|
+
gem install g5_component_garden --source https://gems.gemfury.com/88yeKzEGfizstwBaXVqj/
|
40
|
+
```
|
41
|
+
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
Assuming you have the correct file structure, defined over here: [https://gist.github.com/d42addbb2550fef37d6e](https://gist.github.com/d42addbb2550fef37d6e)
|
46
|
+
You get these routes and views for free:
|
47
|
+
```bash
|
48
|
+
components GET /components(.:format) components#index
|
49
|
+
component GET /components/:slug(.:format) components#show
|
50
|
+
root / components#index
|
51
|
+
```
|
52
|
+
|
53
|
+
If you want to do more with the components:
|
54
|
+
```ruby
|
55
|
+
G5ComponentGarden.all #=> Array of G5HentryConsumer::HG5Component
|
56
|
+
G5ComponentGarden.find("name-of-component") #=> instance of G5HentryConsumer::HG5Component
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
## Authors
|
61
|
+
|
62
|
+
* Jessica Lynn Suttles / [@jlsuttles](https://github.com/jlsuttles)
|
63
|
+
* Bookis Smuin / [@bookis](https://github.com/bookis)
|
64
|
+
* Chris Stringer / [@jcstringer](https://github.com/jcstringer)
|
65
|
+
* Michael Mitchell / [@variousred](https://github.com/variousred)
|
66
|
+
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it
|
71
|
+
2. Get it running
|
72
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
4. Write your code and **specs**
|
74
|
+
5. Commit your changes (`git commit -am 'Add some feature'`)
|
75
|
+
6. Push to the branch (`git push origin my-new-feature`)
|
76
|
+
7. Create new Pull Request
|
77
|
+
|
78
|
+
If you find bugs, have feature requests or questions, please
|
79
|
+
[file an issue](https://github.com/g5search/g5_component_garden/issues).
|
80
|
+
|
81
|
+
|
82
|
+
## Specs
|
83
|
+
|
84
|
+
```bash
|
85
|
+
rspec spec
|
86
|
+
```
|
87
|
+
|
88
|
+
|
89
|
+
## Releases
|
90
|
+
|
91
|
+
```bash
|
92
|
+
vi lib/g5_component_garden/version.rb # change version
|
93
|
+
vi README.md # change version
|
94
|
+
git add . && git commit -m "bumps version" && git push
|
95
|
+
git tag -a -m "Version v0.0.0" v0.0.0 && git push --tags
|
96
|
+
rake build
|
97
|
+
fury push pkg/g5_component_garden-0.0.0.pkg
|
98
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ComponentsController < ::ApplicationController
|
2
|
+
def index
|
3
|
+
@components = G5ComponentGarden.all.map do |component|
|
4
|
+
ComponentDecorator.new(component, view_context)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
component = G5ComponentGarden.find(params[:slug])
|
10
|
+
@component = ComponentDecorator.new(component, view_context)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class ComponentDecorator < SimpleDelegator
|
2
|
+
def initialize(component, view_context)
|
3
|
+
super(component)
|
4
|
+
@view_context = view_context
|
5
|
+
end
|
6
|
+
|
7
|
+
def resource_link(args={})
|
8
|
+
url = args[:url]
|
9
|
+
url ||= [_h.root_url, args[:uri]].join('')
|
10
|
+
_h.link_to(url, url, args[:html])
|
11
|
+
end
|
12
|
+
|
13
|
+
def _h
|
14
|
+
@view_context
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
<div class="h-g5-component well">
|
2
|
+
<header>
|
3
|
+
<dl>
|
4
|
+
<dt>Name</dt>
|
5
|
+
<dd>
|
6
|
+
<span class="p-name"><%= component.name %></span>
|
7
|
+
</dd>
|
8
|
+
<dt>UID</dt>
|
9
|
+
<dd>
|
10
|
+
<%= component.resource_link({url: component_url(component.g5_uid),
|
11
|
+
html: {class: "u-url u-uid", rel: "bookmark"}}) %>
|
12
|
+
</dd>
|
13
|
+
<dt>Thumbnail</dt>
|
14
|
+
<dd>
|
15
|
+
<%= component.resource_link({uri: component.photo, html: {class: "u-photo u-url"}}) %>
|
16
|
+
</dd>
|
17
|
+
<dt>Summary</dt>
|
18
|
+
<dd>
|
19
|
+
<span class="p-summary"><%= component.summary %></span>
|
20
|
+
</dd>
|
21
|
+
<% if component.respond_to?(:colors) %>
|
22
|
+
<dt>Colors</dt>
|
23
|
+
<% component.colors.each do |color| %>
|
24
|
+
<dd>
|
25
|
+
<span class="p-g5-color"><%= color %></span>
|
26
|
+
</dd>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<% if component.respond_to?(:images) %>
|
30
|
+
<dt>Images</dt>
|
31
|
+
<% component.images.each do |image| %>
|
32
|
+
<dd>
|
33
|
+
<%= component.resource_link({uri: image, html: {class: "u-g5-image u-url"}}) %>
|
34
|
+
</dd>
|
35
|
+
<% end %>
|
36
|
+
<% end %>
|
37
|
+
<% if component.respond_to?(:g5_javascripts) %>
|
38
|
+
<dt>Javascripts</dt>
|
39
|
+
<% component.g5_javascripts.each do |javascript| %>
|
40
|
+
<dd>
|
41
|
+
<%= component.resource_link({uri: javascript, html: {class: "u-g5-javascript u-url"}}) %>
|
42
|
+
</dd>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
<% if component.respond_to?(:g5_stylesheets) %>
|
46
|
+
<dt>Styleheets</dt>
|
47
|
+
<% component.g5_stylesheets.each do |stylesheet| %>
|
48
|
+
<dd>
|
49
|
+
<%= component.resource_link({uri: stylesheet, html: {class: "u-g5-stylesheet u-url"}}) %>
|
50
|
+
</dd>
|
51
|
+
<% end %>
|
52
|
+
<% end %>
|
53
|
+
<% if component.respond_to?(:g5_edit_template) %>
|
54
|
+
<dt>Edit Template</dt>
|
55
|
+
<dd>
|
56
|
+
<%= component.resource_link({uri: component.g5_edit_template, html: {class: "u-g5-edit_template u-url"}}) %>
|
57
|
+
</dd>
|
58
|
+
<% end %>
|
59
|
+
<% if component.respond_to?(:g5_show_template) %>
|
60
|
+
<dt>Show Template</dt>
|
61
|
+
<dd>
|
62
|
+
<%= component.resource_link({uri: component.g5_show_template, html: {class: "u-g5-show_template u-url"}}) %>
|
63
|
+
</dd>
|
64
|
+
<% end %>
|
65
|
+
<% if component.respond_to?(:g5_property_groups) %>
|
66
|
+
<dt>Property Group</dt>
|
67
|
+
<% component.g5_property_groups.each do |property_group| %>
|
68
|
+
<% property_group = property_group.format %>
|
69
|
+
<dd>
|
70
|
+
<dl class="e-g5-property-group h-g5-property-group">
|
71
|
+
<dt>Name</dt>
|
72
|
+
<dd class="p-name"><%= property_group.name %></dd>
|
73
|
+
<dt>Type</dt>
|
74
|
+
<% property_group.categories.each do |category| %>
|
75
|
+
<dd class="p-category"><%= category %></dd>
|
76
|
+
<% end %>
|
77
|
+
<dt>Properties</dt>
|
78
|
+
<% property_group.g5_properties.each do |property| %>
|
79
|
+
<% property = property.format %>
|
80
|
+
<dd class="e-g5-property h-g5-property">
|
81
|
+
<dl>
|
82
|
+
<dt>Name</dt>
|
83
|
+
<dd class="p-g5-name"><%= property.g5_name %></dd>
|
84
|
+
<% if property.respond_to?(:g5_editable)%>
|
85
|
+
<dt>Editable</dt>
|
86
|
+
<dd class="p-g5-editable"><%= property.g5_editable %></dd>
|
87
|
+
<% end %>
|
88
|
+
<% if property.respond_to?(:g5_default_value)%>
|
89
|
+
<dt>Default Value</dt>
|
90
|
+
<dd class="p-g5-default-value"><%= property.g5_default_value %></dd>
|
91
|
+
<% end %>
|
92
|
+
</dl>
|
93
|
+
</dd>
|
94
|
+
<% end %>
|
95
|
+
</dl>
|
96
|
+
</dd>
|
97
|
+
<% end %>
|
98
|
+
<% end %>
|
99
|
+
|
100
|
+
</dl>
|
101
|
+
</header>
|
102
|
+
|
103
|
+
<%= content_tag :pre, component.content, class: "e-content" %>
|
104
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render partial: "component", locals: { component: @component } %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/g5_component_garden/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jessica Lynn Suttles"]
|
6
|
+
gem.email = ["jlsuttles@gmail.com"]
|
7
|
+
gem.description = %q{Rails engine for G5 Component Gardens}
|
8
|
+
gem.summary = %q{Rails engine for G5 Component Gardens}
|
9
|
+
gem.homepage = "https://github.com/g5search/g5_component_garden"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "g5_component_garden"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = G5ComponentGarden::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "rails", "~> 3.2.13"
|
19
|
+
gem.add_dependency "microformats2", "2.0.0.pre4"
|
20
|
+
|
21
|
+
gem.add_development_dependency "sqlite3", "~> 1.3.6"
|
22
|
+
gem.add_development_dependency "simplecov", "~> 0.7.1"
|
23
|
+
gem.add_development_dependency "gemfury", "~> 0.4.10"
|
24
|
+
gem.add_development_dependency "rspec", "~> 2.11.0"
|
25
|
+
gem.add_development_dependency "guard-rspec", "~> 2.1.0"
|
26
|
+
gem.add_development_dependency "rb-fsevent", "~> 0.9.2"
|
27
|
+
gem.add_development_dependency "debugger", "~> 1.2.1"
|
28
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "microformats2"
|
3
|
+
require "g5_component_garden/version"
|
4
|
+
require "g5_component_garden/engine"
|
5
|
+
|
6
|
+
module G5ComponentGarden
|
7
|
+
COMPONENT_PATH = "public/static/components/"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def all
|
11
|
+
# each directory in public/components is a component
|
12
|
+
components = file_paths(COMPONENT_PATH, "*")
|
13
|
+
# parse from directory each one and return them as an Array
|
14
|
+
components.map do |component_directory|
|
15
|
+
parse_from_directory(component_directory)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def find(slug)
|
20
|
+
# look for directory in public/components with name slug
|
21
|
+
component = file_paths(COMPONENT_PATH, slug).first
|
22
|
+
# parse from directory
|
23
|
+
parse_from_directory(component)
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_from_directory(directory)
|
27
|
+
# assign name, summary, and preview from index.html
|
28
|
+
component = Microformats2.parse(File.join(directory, "index.html")).g5_components.first
|
29
|
+
relative_directory = get_directory(directory)
|
30
|
+
|
31
|
+
# assign uid as slug from directory name for now
|
32
|
+
uid = directory.split("/").last
|
33
|
+
component.add_property("u-g5-uid", uid)
|
34
|
+
|
35
|
+
thumbnail_path = "#{relative_directory}/images/thumbnail.png"
|
36
|
+
component.add_property("u-photo", thumbnail_path)
|
37
|
+
|
38
|
+
component.add_property("u-g5-edit_template", edit_path(relative_directory))
|
39
|
+
component.add_property("u-g5-show_template", show_path(relative_directory))
|
40
|
+
|
41
|
+
e_content = merge_edit_and_show_markup(directory)
|
42
|
+
component.add_property("e-content", e_content)
|
43
|
+
|
44
|
+
assemble_component_assets(component, directory)
|
45
|
+
end
|
46
|
+
|
47
|
+
def edit_path(directory)
|
48
|
+
"#{directory}/edit.html"
|
49
|
+
end
|
50
|
+
|
51
|
+
def show_path(directory)
|
52
|
+
"#{directory}/show.html"
|
53
|
+
end
|
54
|
+
|
55
|
+
def assemble_component_assets(component, directory)
|
56
|
+
component_assets = file_basenames(directory, "*").select{ |f| ['stylesheets', 'images', 'javascripts'].include?(f) }
|
57
|
+
component_assets.each do |component_asset|
|
58
|
+
folder = component_asset.singularize
|
59
|
+
file_paths_without_public(directory, component_asset, "*").each do |file|
|
60
|
+
component.add_property("u-g5-#{folder}", file)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
component
|
64
|
+
end
|
65
|
+
|
66
|
+
def file_basenames(*path)
|
67
|
+
Dir[File.join(path)].map { |d| File.basename(d) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def file_paths(*path)
|
71
|
+
Dir[File.join(path)].map { |d| File.path(d) }
|
72
|
+
end
|
73
|
+
|
74
|
+
def file_paths_without_public(*path)
|
75
|
+
Dir[File.join(path)].map { |d| File.path(d).split("/")[1..-1].join("/") }
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_directory(directory)
|
79
|
+
directory.split("/")[1..-1].join("/")
|
80
|
+
end
|
81
|
+
|
82
|
+
def merge_edit_and_show_markup(directory)
|
83
|
+
markup = ""
|
84
|
+
markup << %{
|
85
|
+
<!-- BEGIN EDIT FORM MARKUP -->
|
86
|
+
#{get_html(edit_path(directory))}
|
87
|
+
<!-- END EDIT FORM MARKUP -->
|
88
|
+
} if File.exist?(edit_path(directory))
|
89
|
+
|
90
|
+
markup << %{
|
91
|
+
<!-- BEGIN SHOW MARKUP -->
|
92
|
+
#{get_html(show_path(directory))}
|
93
|
+
<!-- END SHOW MARKUP -->
|
94
|
+
} if File.exist?(show_path(directory))
|
95
|
+
|
96
|
+
markup
|
97
|
+
end
|
98
|
+
|
99
|
+
def get_html(file)
|
100
|
+
open(file).read
|
101
|
+
end
|
102
|
+
|
103
|
+
end # class << self
|
104
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ComponentDecorator do
|
4
|
+
before do
|
5
|
+
@view_context = mock(:view_context)
|
6
|
+
@view_context.stub(:root_url).and_return("http://dummy.com/")
|
7
|
+
@view_context.stub(:link_to) {|link| link}
|
8
|
+
@component = mock(:component)
|
9
|
+
@component.stub(:some_method).and_return(:result)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:decorator) {ComponentDecorator.new(@component, @view_context)}
|
13
|
+
|
14
|
+
it "should delegate methods to super" do
|
15
|
+
decorator.some_method.should == :result
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#resource_link" do
|
19
|
+
it "build a link to the full url" do
|
20
|
+
link = decorator.resource_link(url: "http://dummy.com/identifier")
|
21
|
+
link.should == "http://dummy.com/identifier"
|
22
|
+
end
|
23
|
+
it "should build a link given just the uid" do
|
24
|
+
link = decorator.resource_link(uri: "identifier")
|
25
|
+
link.should == "http://dummy.com/identifier"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
Bundler.require(*Rails.groups)
|
12
|
+
require "g5_component_garden"
|
13
|
+
|
14
|
+
module Dummy
|
15
|
+
class Application < Rails::Application
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,201 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'g5_component_garden'
|
3
|
+
|
4
|
+
describe G5ComponentGarden do
|
5
|
+
before :each do
|
6
|
+
stub_const("G5ComponentGarden::COMPONENT_PATH", "spec/support/components")
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "all" do
|
10
|
+
let(:components) { G5ComponentGarden.all }
|
11
|
+
|
12
|
+
it "returns an Array" do
|
13
|
+
components.should be_an_instance_of Array
|
14
|
+
end
|
15
|
+
it "returns an Array of components" do
|
16
|
+
components.first.should be_an_instance_of HG5Component
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "find" do
|
21
|
+
let(:component) { G5ComponentGarden.find("name-of-component") }
|
22
|
+
|
23
|
+
it "returns a component" do
|
24
|
+
component.should be_an_instance_of HG5Component
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#uid" do
|
28
|
+
it "is an Url Property" do
|
29
|
+
component.g5_uid.should be_an_instance_of Microformats2::Property::Url
|
30
|
+
end
|
31
|
+
|
32
|
+
it "contains the uid" do
|
33
|
+
component.g5_uid.to_s.should == "name-of-component"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "#name" do
|
38
|
+
it "is a Text Property" do
|
39
|
+
component.name.should be_an_instance_of Microformats2::Property::Text
|
40
|
+
end
|
41
|
+
|
42
|
+
it "contains the name" do
|
43
|
+
component.name.to_s.should == "Name of Component"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#photo" do
|
48
|
+
it "is a Url Property" do
|
49
|
+
component.photo.should be_an_instance_of Microformats2::Property::Url
|
50
|
+
end
|
51
|
+
|
52
|
+
it "contains the photo" do
|
53
|
+
component.photo.to_s.should == "support/components/name-of-component/images/thumbnail.png"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#photos" do
|
58
|
+
it "is an Array" do
|
59
|
+
component.photos.should be_an_instance_of Array
|
60
|
+
end
|
61
|
+
|
62
|
+
it "contains the photo" do
|
63
|
+
component.photos.first.to_s.should == "support/components/name-of-component/images/thumbnail.png"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "#summary" do
|
68
|
+
it "is a Text Property" do
|
69
|
+
component.summary.should be_an_instance_of Microformats2::Property::Text
|
70
|
+
end
|
71
|
+
|
72
|
+
it "contains the summary" do
|
73
|
+
component.summary.to_s.should == "What this component does/looks like"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#content" do
|
78
|
+
it "is an Embedded Property" do
|
79
|
+
component.content.should be_an_instance_of Microformats2::Property::Embedded
|
80
|
+
end
|
81
|
+
|
82
|
+
context "edit" do
|
83
|
+
it "contains the edit form markup" do
|
84
|
+
component.content.to_s.should include "Edit HTML goes here"
|
85
|
+
end
|
86
|
+
|
87
|
+
it "functions without any edit HTML" do
|
88
|
+
G5ComponentGarden.stub(:edit_path => "/path/to/some/non/existant/file.html")
|
89
|
+
component.content.to_s.should_not include "Edit HTML goes here"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "show" do
|
94
|
+
it "contains the show markup" do
|
95
|
+
component.content.to_s.should include "Show HTML goes here"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "functions without any show HTML" do
|
99
|
+
G5ComponentGarden.stub(:show_path => "/path/to/some/non/existant/file.html")
|
100
|
+
component.content.to_s.should_not include "Show HTML goes here"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "#images" do
|
106
|
+
it "is an Array" do
|
107
|
+
component.g5_images.should be_an_instance_of Array
|
108
|
+
end
|
109
|
+
|
110
|
+
it "contains images" do
|
111
|
+
component.g5_images.map(&:to_s).should include("support/components/name-of-component/images/test.png")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "#javascript with a single file" do
|
116
|
+
it "is a Url Property" do
|
117
|
+
component.g5_javascript.should be_an_instance_of Microformats2::Property::Url
|
118
|
+
end
|
119
|
+
|
120
|
+
it "contains the javascript" do
|
121
|
+
component.g5_javascript.to_s.should == "support/components/name-of-component/javascripts/name-of-component.js"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe "#stylesheets with multiple files" do
|
126
|
+
it "is an Array" do
|
127
|
+
component.g5_stylesheets.should be_an_instance_of Array
|
128
|
+
end
|
129
|
+
|
130
|
+
it "contains the stylesheets" do
|
131
|
+
component.g5_stylesheets.map(&:to_s).should include "support/components/name-of-component/stylesheets/name-of-component.css"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe "#edit" do
|
136
|
+
it "is a Url Property" do
|
137
|
+
component.g5_edit_template.should be_an_instance_of Microformats2::Property::Url
|
138
|
+
end
|
139
|
+
|
140
|
+
it "contains the edit path" do
|
141
|
+
component.g5_edit_template.to_s.should eq "support/components/name-of-component/edit.html"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "#show" do
|
146
|
+
it "is a Url Property" do
|
147
|
+
component.g5_show_template.should be_an_instance_of Microformats2::Property::Url
|
148
|
+
end
|
149
|
+
|
150
|
+
it "contains the show path" do
|
151
|
+
component.g5_show_template.to_s.should eq "support/components/name-of-component/show.html"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe "#property groups" do
|
156
|
+
subject { component.g5_property_groups }
|
157
|
+
|
158
|
+
it "is an Array" do
|
159
|
+
subject.should be_an_instance_of Array
|
160
|
+
end
|
161
|
+
|
162
|
+
it "contains Embedded Properties" do
|
163
|
+
subject.first.should be_an_instance_of Microformats2::Property::Embedded
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "categories" do
|
167
|
+
subject { component.g5_property_groups.first.format.categories }
|
168
|
+
|
169
|
+
it "is an Array" do
|
170
|
+
subject.should be_an_instance_of Array
|
171
|
+
end
|
172
|
+
|
173
|
+
it "contains the category" do
|
174
|
+
subject.first.to_s.should == "Instance"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "g5_properties" do
|
179
|
+
it "is an Array" do
|
180
|
+
component.g5_property_groups.first.format.g5_properties.should be_an_instance_of Array
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "property attributes" do
|
184
|
+
subject { component.g5_property_groups.first.format.g5_properties.first.format }
|
185
|
+
|
186
|
+
it "contains the attribute" do
|
187
|
+
subject.g5_name.to_s.should == "username"
|
188
|
+
end
|
189
|
+
|
190
|
+
it "is editable" do
|
191
|
+
subject.g5_editable.should be_true
|
192
|
+
end
|
193
|
+
|
194
|
+
it "has a default value" do
|
195
|
+
subject.g5_default_value.to_s.should == "Twitter Feed"
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Edit HTML goes here
|
File without changes
|
File without changes
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<div class="h-g5-component">
|
2
|
+
<header>
|
3
|
+
<dl>
|
4
|
+
<dt>Name</dt>
|
5
|
+
<dd>
|
6
|
+
<span class="p-name">Name of Component</span>
|
7
|
+
</dd>
|
8
|
+
<dt>Summary</dt>
|
9
|
+
<dd>
|
10
|
+
<span class="p-summary">What this component does/looks like</span>
|
11
|
+
</dd>
|
12
|
+
<dt>Property Group</dt>
|
13
|
+
<dd>
|
14
|
+
<dl class="h-g5-property-group e-g5-property-group">
|
15
|
+
<dt>Name</dt>
|
16
|
+
<dd class="p-name">Feed</dd>
|
17
|
+
<dt>Category</dt>
|
18
|
+
<dd class="p-category">Instance</dd>
|
19
|
+
<dt>Properties</dt>
|
20
|
+
<dd class="h-g5-property e-g5-property">
|
21
|
+
<dl>
|
22
|
+
<dt>Username</dt>
|
23
|
+
<dd class="p-g5-name">username</dd>
|
24
|
+
<dt>Editable</dt>
|
25
|
+
<dd class="p-g5-editable">true</dd>
|
26
|
+
<dt>Default Value</dt>
|
27
|
+
<dd class="p-g5-default-value">Twitter Feed</dd>
|
28
|
+
</dl>
|
29
|
+
</dd>
|
30
|
+
<dd class="h-g5-property e-g5-property">
|
31
|
+
<dl>
|
32
|
+
<dt>Some other property</dt>
|
33
|
+
<dd class="p-g5-name">some property</dd>
|
34
|
+
<dt>Editable</dt>
|
35
|
+
<dd class="p-g5-editable">false</dd>
|
36
|
+
<dt>Default Value</dt>
|
37
|
+
<dd class="p-g5-default-value">Some default value</dd>
|
38
|
+
</dl>
|
39
|
+
</dd>
|
40
|
+
</dl>
|
41
|
+
</dd> <!-- END e-g5-properties -->
|
42
|
+
|
43
|
+
</dl>
|
44
|
+
</header>
|
45
|
+
</div>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Show HTML goes here
|
File without changes
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: g5_component_garden
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jessica Lynn Suttles
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.13
|
20
|
+
none: false
|
21
|
+
prerelease: false
|
22
|
+
name: rails
|
23
|
+
requirement: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.2.13
|
28
|
+
none: false
|
29
|
+
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - '='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.0.0.pre4
|
36
|
+
none: false
|
37
|
+
prerelease: false
|
38
|
+
name: microformats2
|
39
|
+
requirement: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.0.0.pre4
|
44
|
+
none: false
|
45
|
+
type: :runtime
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ~>
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.3.6
|
52
|
+
none: false
|
53
|
+
prerelease: false
|
54
|
+
name: sqlite3
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.3.6
|
60
|
+
none: false
|
61
|
+
type: :development
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 0.7.1
|
68
|
+
none: false
|
69
|
+
prerelease: false
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.1
|
76
|
+
none: false
|
77
|
+
type: :development
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.4.10
|
84
|
+
none: false
|
85
|
+
prerelease: false
|
86
|
+
name: gemfury
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ~>
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.4.10
|
92
|
+
none: false
|
93
|
+
type: :development
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ~>
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 2.11.0
|
100
|
+
none: false
|
101
|
+
prerelease: false
|
102
|
+
name: rspec
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ~>
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: 2.11.0
|
108
|
+
none: false
|
109
|
+
type: :development
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
version_requirements: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ~>
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: 2.1.0
|
116
|
+
none: false
|
117
|
+
prerelease: false
|
118
|
+
name: guard-rspec
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 2.1.0
|
124
|
+
none: false
|
125
|
+
type: :development
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.9.2
|
132
|
+
none: false
|
133
|
+
prerelease: false
|
134
|
+
name: rb-fsevent
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ~>
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: 0.9.2
|
140
|
+
none: false
|
141
|
+
type: :development
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
version_requirements: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ~>
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 1.2.1
|
148
|
+
none: false
|
149
|
+
prerelease: false
|
150
|
+
name: debugger
|
151
|
+
requirement: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ~>
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: 1.2.1
|
156
|
+
none: false
|
157
|
+
type: :development
|
158
|
+
description: Rails engine for G5 Component Gardens
|
159
|
+
email:
|
160
|
+
- jlsuttles@gmail.com
|
161
|
+
executables: []
|
162
|
+
extensions: []
|
163
|
+
extra_rdoc_files: []
|
164
|
+
files:
|
165
|
+
- .gitignore
|
166
|
+
- Gemfile
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- app/controllers/components_controller.rb
|
170
|
+
- app/decorators/component_decorator.rb
|
171
|
+
- app/views/components/_component.html.erb
|
172
|
+
- app/views/components/index.html.erb
|
173
|
+
- app/views/components/show.html.erb
|
174
|
+
- config/routes.rb
|
175
|
+
- g5_component_garden.gemspec
|
176
|
+
- lib/g5_component_garden.rb
|
177
|
+
- lib/g5_component_garden/engine.rb
|
178
|
+
- lib/g5_component_garden/version.rb
|
179
|
+
- spec/decorators/component_decorator_spec.rb
|
180
|
+
- spec/dummy/config/application.rb
|
181
|
+
- spec/dummy/config/boot.rb
|
182
|
+
- spec/dummy/config/environment.rb
|
183
|
+
- spec/dummy/config/routes.rb
|
184
|
+
- spec/lib/g5_component_garden_spec.rb
|
185
|
+
- spec/spec_helper.rb
|
186
|
+
- spec/support/components/name-of-component/edit.html
|
187
|
+
- spec/support/components/name-of-component/images/test.png
|
188
|
+
- spec/support/components/name-of-component/images/thumbnail.png
|
189
|
+
- spec/support/components/name-of-component/index.html
|
190
|
+
- spec/support/components/name-of-component/javascripts/name-of-component.js
|
191
|
+
- spec/support/components/name-of-component/show.html
|
192
|
+
- spec/support/components/name-of-component/stylesheets/name-of-component.css
|
193
|
+
- spec/support/components/name-of-component/stylesheets/name-of-other-component.css
|
194
|
+
homepage: https://github.com/g5search/g5_component_garden
|
195
|
+
licenses: []
|
196
|
+
post_install_message:
|
197
|
+
rdoc_options: []
|
198
|
+
require_paths:
|
199
|
+
- lib
|
200
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - ! '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
segments:
|
206
|
+
- 0
|
207
|
+
hash: 657193415753197041
|
208
|
+
none: false
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
segments:
|
215
|
+
- 0
|
216
|
+
hash: 657193415753197041
|
217
|
+
none: false
|
218
|
+
requirements: []
|
219
|
+
rubyforge_project:
|
220
|
+
rubygems_version: 1.8.24
|
221
|
+
signing_key:
|
222
|
+
specification_version: 3
|
223
|
+
summary: Rails engine for G5 Component Gardens
|
224
|
+
test_files:
|
225
|
+
- spec/decorators/component_decorator_spec.rb
|
226
|
+
- spec/dummy/config/application.rb
|
227
|
+
- spec/dummy/config/boot.rb
|
228
|
+
- spec/dummy/config/environment.rb
|
229
|
+
- spec/dummy/config/routes.rb
|
230
|
+
- spec/lib/g5_component_garden_spec.rb
|
231
|
+
- spec/spec_helper.rb
|
232
|
+
- spec/support/components/name-of-component/edit.html
|
233
|
+
- spec/support/components/name-of-component/images/test.png
|
234
|
+
- spec/support/components/name-of-component/images/thumbnail.png
|
235
|
+
- spec/support/components/name-of-component/index.html
|
236
|
+
- spec/support/components/name-of-component/javascripts/name-of-component.js
|
237
|
+
- spec/support/components/name-of-component/show.html
|
238
|
+
- spec/support/components/name-of-component/stylesheets/name-of-component.css
|
239
|
+
- spec/support/components/name-of-component/stylesheets/name-of-other-component.css
|