Permalink
Browse files

Rails integration

  • Loading branch information...
1 parent 93dd1ca commit ef726a5cc5075689c6e6ddd4643b7b1b7a7c13fc @moonmaster9000 committed Apr 30, 2012
View
@@ -6,31 +6,31 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.3)
- actionpack (= 3.2.3)
- mail (~> 2.4.4)
- actionpack (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
+ mail (~> 2.4.0)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
- rack-cache (~> 1.2)
+ rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
- activemodel (3.2.3)
- activesupport (= 3.2.3)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
- activerecord (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- activesupport (3.2.3)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
@@ -55,17 +55,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.3)
- actionmailer (= 3.2.3)
- actionpack (= 3.2.3)
- activerecord (= 3.2.3)
- activeresource (= 3.2.3)
- activesupport (= 3.2.3)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
bundler (~> 1.0)
- railties (= 3.2.3)
- railties (3.2.3)
- actionpack (= 3.2.3)
- activesupport (= 3.2.3)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
@@ -97,5 +97,5 @@ PLATFORMS
DEPENDENCIES
frill!
- rails (~> 3.2.2)
+ rails (= 3.2.2)
rspec
@@ -0,0 +1,14 @@
+module ViewContextFrill
+ include Frill
+ first
+
+ def self.frill? object, controller
+ object.class_eval do
+ define_method :helper do
+ @frill_helper ||= controller.view_context
+ end
+ end
+
+ false
+ end
+end
View
@@ -6,6 +6,6 @@ Gem::Specification.new do |s|
s.files = Dir["lib/**/*"] << "VERSION" << "readme.markdown"
s.test_files = Dir["spec/**/*"]
- s.add_development_dependency "rails", "~> 3.2.2"
+ s.add_development_dependency "rails", "= 3.2.2"
s.add_development_dependency "rspec"
end
View
@@ -1 +1,2 @@
require 'frill/frill'
+require 'frill/engine' if defined? Rails
View
@@ -0,0 +1,26 @@
+require 'rails'
+
+module Frill
+ class Engine < Rails::Engine
+ config.autoload_paths << "app/frills"
+
+ initializer "frill.rails_integration" do
+ require 'frill/rails'
+ end
+
+ config.to_prepare do
+ if Rails.env.development? && !Rails.application.config.cache_classes
+ Frill.reset!
+
+ Frill::Engine.force_load Dir["#{Frill::Engine.root}/app/frills/*"]
+ Frill::Engine.force_load Dir["#{Rails.root}/app/frills/*"]
+ end
+ end
+
+ def self.force_load files
+ files.each do |f|
+ load f
+ end
+ end
+ end
+end
View
@@ -16,6 +16,8 @@ def self.decorate object, context
decorators.each do |d|
object.extend d if d.frill? object, context
end
+
+ object
end
module ClassMethods
View
@@ -0,0 +1,5 @@
+class ActionController::Base
+ def frill object
+ Frill.decorate object, self
+ end
+end
View
@@ -1,7 +1,5 @@
# Frill
- NOTE: THIS GEM IS NOT YET RELEASED
-
Simple decoration of objects for presentation. If you don't know what I'm talking
about, reading up on decorators and their role in MVC.
@@ -15,10 +13,6 @@ Throw this in your Gemfile:
gem "frill"
```
-If you're placing this in a Rails app, run the following command:
-
- $ rails g frill:install
-
## Usage
(For the purposes of this tutorial, I'm going to assume you're using
@@ -56,8 +50,6 @@ to `created_at`.
Next, let's create an `HtmlTimestampFrill` module:
```ruby
-require_relative 'timestamp_frill'
-
module HtmlTimestampFrill
include Frill
after TimestampFrill
@@ -113,21 +105,6 @@ simply call `Frill.decorate`:
Frill.decorate my_object, my_context
```
-If you want to replicate the `helper` behavior you get for free in a
-Rails app, consider how simple it was to make that `helper` method
-possible:
-
-```ruby
-module ActionViewFrill
- include Frill
- first
-
- def helper
- @helper ||= Object.new.extend ActionView::Helpers
- end
-end
-```
-
## License
MIT.
View
@@ -0,0 +1 @@
+--colour
View
@@ -1,8 +1,10 @@
-source 'http://rubygems.org'
+source 'https://rubygems.org'
+
+gem 'rails', '3.2.2'
-gem 'rails', '3.2.3'
gem 'frill', path: '../'
group :test do
- gem 'rspec-rails'
+ gem 'rspec-rails', '~> 2.8.0'
+ gem 'capybara'
end
@@ -4,49 +4,63 @@ PATH
frill (0.0.0)
GEM
- remote: http://rubygems.org/
+ remote: https://rubygems.org/
specs:
- actionmailer (3.2.3)
- actionpack (= 3.2.3)
- mail (~> 2.4.4)
- actionpack (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
+ mail (~> 2.4.0)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.1)
rack (~> 1.4.0)
- rack-cache (~> 1.2)
+ rack-cache (~> 1.1)
rack-test (~> 0.6.1)
sprockets (~> 2.1.2)
- activemodel (3.2.3)
- activesupport (= 3.2.3)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
builder (~> 3.0.0)
- activerecord (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.3)
- activemodel (= 3.2.3)
- activesupport (= 3.2.3)
- activesupport (3.2.3)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.2.7)
arel (3.0.2)
builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ childprocess (0.3.2)
+ ffi (~> 1.0.6)
diff-lcs (1.1.3)
erubis (2.7.0)
+ ffi (1.0.11)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
json (1.7.0)
+ libwebsocket (0.1.3)
+ addressable
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.3.4)
+ nokogiri (1.5.2)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -55,37 +69,44 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.3)
- actionmailer (= 3.2.3)
- actionpack (= 3.2.3)
- activerecord (= 3.2.3)
- activeresource (= 3.2.3)
- activesupport (= 3.2.3)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
bundler (~> 1.0)
- railties (= 3.2.3)
- railties (3.2.3)
- actionpack (= 3.2.3)
- activesupport (= 3.2.3)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
- rspec (2.9.0)
- rspec-core (~> 2.9.0)
- rspec-expectations (~> 2.9.0)
- rspec-mocks (~> 2.9.0)
- rspec-core (2.9.0)
- rspec-expectations (2.9.1)
- diff-lcs (~> 1.1.3)
- rspec-mocks (2.9.0)
- rspec-rails (2.9.0)
+ rspec (2.8.0)
+ rspec-core (~> 2.8.0)
+ rspec-expectations (~> 2.8.0)
+ rspec-mocks (~> 2.8.0)
+ rspec-core (2.8.0)
+ rspec-expectations (2.8.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.8.0)
+ rspec-rails (2.8.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
- rspec (~> 2.9.0)
+ rspec (~> 2.8.0)
+ rubyzip (0.9.8)
+ selenium-webdriver (2.21.2)
+ childprocess (>= 0.2.5)
+ ffi (~> 1.0)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
@@ -96,11 +117,14 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
+ capybara
frill!
- rails (= 3.2.3)
- rspec-rails
+ rails (= 3.2.2)
+ rspec-rails (~> 2.8.0)
@@ -1,15 +1 @@
-// This is a manifest file that'll be compiled into application.js, which will include all the files
-// listed below.
-//
-// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
-// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
-//
-// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
-// the compiled file.
-//
-// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
-// GO AFTER THE REQUIRES BELOW.
-//
-//= require jquery
-//= require jquery_ujs
//= require_tree .
Oops, something went wrong.

0 comments on commit ef726a5

Please sign in to comment.