meta_types 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +184 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/meta_types/application.js +15 -0
- data/app/assets/stylesheets/meta_types/application.css +13 -0
- data/app/controllers/meta_types/application_controller.rb +4 -0
- data/app/helpers/meta_types/application_helper.rb +4 -0
- data/app/models/meta_type.rb +36 -0
- data/app/models/meta_type_member.rb +29 -0
- data/app/models/meta_type_property.rb +74 -0
- data/app/views/layouts/meta_types/application.html.erb +14 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20120507130230_create_hstore.rb +9 -0
- data/db/migrate/20120507130237_meta_type.rb +19 -0
- data/db/migrate/20120507130255_meta_type_property.rb +23 -0
- data/db/migrate/20120507130303_meta_type_member.rb +18 -0
- data/lib/meta_types.rb +9 -0
- data/lib/meta_types/active_record.rb +48 -0
- data/lib/meta_types/engine.rb +5 -0
- data/lib/meta_types/meta_properties.rb +93 -0
- data/lib/meta_types/meta_property.rb +27 -0
- data/lib/meta_types/meta_property_type.rb +59 -0
- data/lib/meta_types/version.rb +3 -0
- data/lib/tasks/meta_types_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/stylesheets/application.scss +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/dashboard_controller.rb +3 -0
- data/test/dummy/app/controllers/meta_type_properties_controller.rb +7 -0
- data/test/dummy/app/controllers/meta_types_controller.rb +7 -0
- data/test/dummy/app/controllers/things_controller.rb +34 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/thing.rb +6 -0
- data/test/dummy/app/views/dashboard/index.html.erb +14 -0
- data/test/dummy/app/views/layouts/application.html.erb +58 -0
- data/test/dummy/app/views/meta_type_properties/_meta_type_property.html.erb +10 -0
- data/test/dummy/app/views/meta_type_properties/edit.html.erb +5 -0
- data/test/dummy/app/views/meta_type_properties/index.html.erb +9 -0
- data/test/dummy/app/views/meta_type_properties/new.html.erb +5 -0
- data/test/dummy/app/views/meta_types/_meta_type.html.erb +6 -0
- data/test/dummy/app/views/meta_types/edit.html.erb +5 -0
- data/test/dummy/app/views/meta_types/index.html.erb +9 -0
- data/test/dummy/app/views/meta_types/new.html.erb +5 -0
- data/test/dummy/app/views/things/_thing.html.erb +10 -0
- data/test/dummy/app/views/things/edit.html.erb +5 -0
- data/test/dummy/app/views/things/index.html.erb +9 -0
- data/test/dummy/app/views/things/new.html.erb +12 -0
- data/test/dummy/app/views/things/show.html.erb +10 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +58 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/simple_form.rb +178 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/locales/simple_form.en.yml +26 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/db/migrate/20120507130230_create_hstore.rb +9 -0
- data/test/dummy/db/migrate/20120507130237_meta_type.rb +19 -0
- data/test/dummy/db/migrate/20120507130255_meta_type_property.rb +23 -0
- data/test/dummy/db/migrate/20120507130303_meta_type_member.rb +18 -0
- data/test/dummy/db/migrate/20120508143058_create_things.rb +14 -0
- data/test/dummy/db/seeds.rb +28 -0
- data/test/dummy/db/structure.sql +309 -0
- data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/test/dummy/log/development.log +8958 -0
- data/test/dummy/log/test.log +5559 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C7F/AF0/sprockets%2F1f64b7e05e310702c90b98e4816685a2 +0 -0
- data/test/dummy/tmp/cache/assets/C94/420/sprockets%2F639d84895339654f12ac2bde8292d447 +0 -0
- data/test/dummy/tmp/cache/assets/CB1/FD0/sprockets%2F6e1bd95023705b5529e7ccc754a02867 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CFF/E00/sprockets%2F352bab412d75fa19d0a07504553b59df +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D49/8D0/sprockets%2F92613a75279536c4bcf4f3ba6cfde494 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D59/6F0/sprockets%2F7c015202319d3bb46ea41d4ff9b5ac0d +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D9F/640/sprockets%2Fbbc63c99f5e0eef2a890442ea3431dd7 +0 -0
- data/test/dummy/tmp/cache/assets/DB1/370/sprockets%2F18d79bbfdd80aa3bde79ab687266d992 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E02/0E0/sprockets%2Fa8f15cbf61c3d8edb5a99dbafd690721 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/meta_types_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/meta_types/meta_type_test.rb +181 -0
- metadata +257 -0
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
16
|
+
// require twitter/bootstrap
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*= require twitter/bootstrap
|
14
|
+
*/
|
15
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class ThingsController < ApplicationController
|
2
|
+
def index
|
3
|
+
@things = Thing.all
|
4
|
+
end
|
5
|
+
|
6
|
+
def show
|
7
|
+
@thing = Thing.find(params[:id])
|
8
|
+
end
|
9
|
+
alias_method :edit, :show
|
10
|
+
|
11
|
+
def new
|
12
|
+
if params[:meta_type]
|
13
|
+
@thing = Thing.new(meta_type: MetaType[params[:meta_type]])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@thing = Thing.new(params[:thing])
|
19
|
+
if @thing.save
|
20
|
+
redirect_to things_path()
|
21
|
+
else
|
22
|
+
render :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
@thing = Thing.find(params[:id])
|
28
|
+
if @thing.update_attributes(params[:thing])
|
29
|
+
redirect_to thing_path(@thing)
|
30
|
+
else
|
31
|
+
render :edit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div class="hero-unit">
|
2
|
+
<h1><tt>meta_types</tt> gem</h1>
|
3
|
+
<br/>
|
4
|
+
<p>This is a gem to save the world ;)</p>
|
5
|
+
<p>It's supposed to allow easy creation of user-configurable models through postgres hstore.</p>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<p>This is really just a very minimalistic demo app.</p>
|
9
|
+
|
10
|
+
<ul>
|
11
|
+
<li><%= link_to "Meta Types", meta_types_path() %></li>
|
12
|
+
<li><%= link_to "Meta Type Properties", meta_type_properties_path() %></li>
|
13
|
+
<li><%= link_to "Things", things_path() %></li>
|
14
|
+
</ul>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>meta_types gem, from metaminded (by coincidence)</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<meta name="description" content="">
|
8
|
+
<meta name="author" content="">
|
9
|
+
|
10
|
+
<%= stylesheet_link_tag "application", :media => "all" %>
|
11
|
+
<%= javascript_include_tag "application" %>
|
12
|
+
<%= csrf_meta_tags %>
|
13
|
+
<style>
|
14
|
+
body {
|
15
|
+
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
16
|
+
}
|
17
|
+
</style>
|
18
|
+
</head>
|
19
|
+
|
20
|
+
<body>
|
21
|
+
|
22
|
+
<div class="navbar navbar-fixed-top">
|
23
|
+
<div class="navbar-inner">
|
24
|
+
<div class="container">
|
25
|
+
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
26
|
+
<span class="icon-bar"></span>
|
27
|
+
<span class="icon-bar"></span>
|
28
|
+
<span class="icon-bar"></span>
|
29
|
+
</a>
|
30
|
+
<a class="brand" href="#">Meta Types</a>
|
31
|
+
<div class="nav-collapse">
|
32
|
+
<ul class="nav">
|
33
|
+
<li><a href="/">Home</a></li>
|
34
|
+
<li><a href="/things">Things</a></li>
|
35
|
+
<li><a href="/meta_types">MetaTypes</a></li>
|
36
|
+
<li><a href="/meta_type_properties">MetaTypeProperties</a></li>
|
37
|
+
</ul>
|
38
|
+
</div><!--/.nav-collapse -->
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div class="container">
|
44
|
+
|
45
|
+
<%= yield %>
|
46
|
+
|
47
|
+
<hr/>
|
48
|
+
<footer>
|
49
|
+
<p>
|
50
|
+
© <a href="http://metaminded.com">metaminded UG</a> 2012
|
51
|
+
—
|
52
|
+
<a href="https://github.com/metaminded/meta_types"><tt>meta_types</tt> on GitHub</a>
|
53
|
+
</p>
|
54
|
+
</footer>
|
55
|
+
</div> <!-- /container -->
|
56
|
+
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= simple_form_for @meta_type_property, :html => {:class => 'form-horizontal' } do |f| %>
|
2
|
+
<%= f.input :label %>
|
3
|
+
<%= f.input :sid %>
|
4
|
+
<%= f.input :default_value %>
|
5
|
+
<%= f.input :required %>
|
6
|
+
<%= f.input :dimension %>
|
7
|
+
<%= f.input :choices, hint: 'separate the individual options with ||'%>
|
8
|
+
<%= f.input :property_type_sid, collection: MetaTypes::MetaPropertyType.sids %>
|
9
|
+
<%= f.submit %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1>MetaTypeProperties</h1>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<% @meta_type_properties.each do |meta_type_property| %>
|
5
|
+
<li><%= link_to meta_type_property.name, edit_meta_type_property_path(meta_type_property) %></li>
|
6
|
+
<% end %>
|
7
|
+
</ul>
|
8
|
+
|
9
|
+
<%= link_to "New MetaTypeProperty", new_meta_type_property_path() %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= simple_form_for @thing, :html => {:class => 'form-horizontal' } do |f| %>
|
2
|
+
<%= f.input :meta_type_id, as: :hidden %>
|
3
|
+
<%= f.input :name %>
|
4
|
+
<%= f.fields_for :properties do |ff| %>
|
5
|
+
<% @thing.properties.each do |prop| %>
|
6
|
+
<%= ff.input prop.sid, collection: prop.choices, label: prop.label %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<%= f.submit %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<h1>New Thing</h1>
|
2
|
+
|
3
|
+
<% if @thing %>
|
4
|
+
<%= render :partial => 'thing' %>
|
5
|
+
<% else %>
|
6
|
+
<%= form_tag({}, method: :get) do %>
|
7
|
+
<%= select_tag :meta_type, options_from_collection_for_select(MetaType.all, :sid, :title )%>
|
8
|
+
<%= submit_tag :OK %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
<%= link_to "Abort", things_path() %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h1>Thing <i><%= @thing.name %></i></h1>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<li><b>Name:</b> <%= @thing.name %></li>
|
5
|
+
<% @thing.properties.each do |prop| %>
|
6
|
+
<li><b><%= prop.label %>:</b> <%= prop.value %> (i.e., <%= @thing.properties.send prop.sid %>)
|
7
|
+
<% end %>
|
8
|
+
</ul>
|
9
|
+
|
10
|
+
<%= link_to 'Edit', edit_thing_path(@thing) %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require
|
6
|
+
require "meta_types"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
15
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
16
|
+
|
17
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
18
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
19
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
20
|
+
|
21
|
+
# Activate observers that should always be running.
|
22
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
23
|
+
|
24
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
25
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
26
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
27
|
+
|
28
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
29
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
30
|
+
# config.i18n.default_locale = :de
|
31
|
+
|
32
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
33
|
+
config.encoding = "utf-8"
|
34
|
+
|
35
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
36
|
+
config.filter_parameters += [:password]
|
37
|
+
|
38
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
39
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
40
|
+
# like if you have constraints or database-specific column types
|
41
|
+
config.active_record.schema_format = :sql
|
42
|
+
|
43
|
+
# Enforce whitelist mode for mass assignment.
|
44
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
45
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
46
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
47
|
+
config.active_record.whitelist_attributes = true
|
48
|
+
|
49
|
+
# Enable the asset pipeline
|
50
|
+
config.assets.enabled = true
|
51
|
+
|
52
|
+
# Version of your assets, change this if you want to expire all your assets
|
53
|
+
config.assets.version = '1.0'
|
54
|
+
|
55
|
+
config.assets.initialize_on_precompile = false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# foo
|
2
|
+
|
3
|
+
development:
|
4
|
+
adapter: postgresql
|
5
|
+
encoding: unicode
|
6
|
+
database: meta_types_dev
|
7
|
+
pool: 5
|
8
|
+
username: hornp
|
9
|
+
password:
|
10
|
+
|
11
|
+
test:
|
12
|
+
adapter: postgresql
|
13
|
+
encoding: unicode
|
14
|
+
database: meta_types_test
|
15
|
+
pool: 5
|
16
|
+
username: hornp
|
17
|
+
password:
|
18
|
+
|
19
|
+
production:
|
20
|
+
adapter: postgresql
|
21
|
+
encoding: unicode
|
22
|
+
database: meta_types_prod
|
23
|
+
pool: 5
|
24
|
+
username: hornp
|
25
|
+
password:
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
32
|
+
# Do not compress assets
|
33
|
+
config.assets.compress = false
|
34
|
+
|
35
|
+
# Expands the lines which load the assets
|
36
|
+
config.assets.debug = true
|
37
|
+
end
|