public
Description: LINKS TO Merb plugins that make the transition from Rails a little bit easier
Clone URL: git://github.com/ivey/merb-for-rails.git
Search Repo:
ivey (author)
Tue May 06 19:20:21 -0700 2008
commit  e858e78edc03a2e938986470327e4c6bb5abf1e5
tree    ab616a9646aa3505273d8f164501ea808482522b
parent  828a54eace9e0f2ead15093f3a3b49863baef97d
...
1
...
 
0
@@ -1,2 +1 @@
0
-See individual plugins for License and Copyright information.
0
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+Moved to separate repos
0
+
0
+http://github.com/ivey/merb_has_flash
0
+http://github.com/ivey/merb_has_rails_plugins
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,72 +1 @@
0
-require "rake/gempackagetask"
0
-require 'fileutils'
0
-include FileUtils
0
-
0
-gems = %w[merb_has_flash merb_has_rails_plugins]
0
-
0
-spec = Gem::Specification.new do |s|
0
- s.name = "merb_for_rails"
0
- s.version = "0.9.0"
0
- s.platform = Gem::Platform::RUBY
0
- s.author = "Michael D. Ivey"
0
- s.email = "ivey@gweezlebur.com"
0
- s.homepage = "http://rubyforge.org/projects/merb-plugins/"
0
- s.summary = "A collection of Merb plugins to make the transition from Rails a little easier"
0
- s.description = s.summary
0
- s.files = %w( LICENSE README Rakefile )
0
- s.add_dependency "merb-core", ">= 0.9.0"
0
- gems.each do |gem|
0
- s.add_dependency gem, [">= 0.9", "<= 1.0"]
0
- end
0
-end
0
-
0
-windows = (PLATFORM =~ /win32|cygwin/) rescue nil
0
-
0
-SUDO = windows ? "" : "sudo"
0
-
0
-# desc "Installs Merb More."
0
-# task :default => :install
0
-
0
-Rake::GemPackageTask.new(spec) do |package|
0
- package.gem_spec = spec
0
-end
0
-
0
-desc "Install it all"
0
-task :install => [:install_gems, :package] do
0
- sh %{#{SUDO} gem install pkg/merb_has_rails_plugins-0.9.0.gem}
0
-end
0
-
0
-desc "Build the sub-gems"
0
-task :build_gems do
0
- gems.each do |dir|
0
- sh %{cd #{dir}; rake package}
0
- end
0
-end
0
-
0
-desc "Install the sub-gems"
0
-task :install_gems do
0
- gems.each do |dir|
0
- sh %{cd #{dir}; #{SUDO} rake install}
0
- end
0
-end
0
-
0
-desc "Uninstall the sub-gems"
0
-task :uninstall_gems do
0
- gems.each do |sub_gem|
0
- sh %{#{SUDO} gem uninstall #{sub_gem}}
0
- end
0
-end
0
-
0
-desc "Bundle up all the merb-more gems"
0
-task :bundle => [:package, :build_gems] do
0
- mkdir "bundle"
0
- cp "pkg/merb-#{Merb::MORE_VERSION}.gem", "bundle"
0
- cp "pkg/merb-more-#{Merb::MORE_VERSION}.gem", "bundle"
0
- gems.each do |gem|
0
- File.open("#{gem}/Rakefile") do |rakefile|
0
- rakefile.read.detect {|l| l =~ /^VERSION\s*=\s*"(.*)"$/ }
0
- sh %{cp #{gem}/pkg/#{gem}-#{$1}.gem bundle/}
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,24 +1 @@
0
-Original code Copyright (c) 2007 Michael D. Ivey
0
-
0
-Most of this code is based on the Flash code in Rails/ActionPack:
0
-Copyright (c) 2004-2006 David Heinemeier Hansson
0
-
0
-Permission is hereby granted, free of charge, to any person obtaining
0
-a copy of this software and associated documentation files (the
0
-"Software"), to deal in the Software without restriction, including
0
-without limitation the rights to use, copy, modify, merge, publish,
0
-distribute, sublicense, and/or sell copies of the Software, and to
0
-permit persons to whom the Software is furnished to do so, subject to
0
-the following conditions:
0
-
0
-The above copyright notice and this permission notice shall be
0
-included in all copies or substantial portions of the Software.
0
-
0
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,15 +1 @@
0
-merb_has_flash
0
-=================
0
-
0
-A plugin for the Merb framework that provides Rails-style flash.
0
-
0
-Most of the code is taken directly from Rails, which is
0
-Copyright (c) 2004-2006 David Heinemeier Hansson.
0
-This plugin is released under the same terms as Rails itself.
0
-
0
-Hacked together by Michael Ivey <ivey@gweezlebur.com> ... send bug
0
-reports and patches to him.
0
-
0
-Contributors:
0
-Tim Kofol
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,40 +1 @@
0
-require 'rubygems'
0
-require 'rake/gempackagetask'
0
-
0
-PLUGIN = "merb_has_flash"
0
-NAME = "merb_has_flash"
0
-VERSION = "0.9.2"
0
-AUTHOR = "Michael Ivey"
0
-EMAIL = "ivey@gweezlebur.com"
0
-HOMEPAGE = "http://merb-plugins.rubyforge.org/merb_has_flash/"
0
-SUMMARY = "Merb plugin that provides a Rails-style flash"
0
-
0
-spec = Gem::Specification.new do |s|
0
- s.name = NAME
0
- s.version = VERSION
0
- s.platform = Gem::Platform::RUBY
0
- s.has_rdoc = true
0
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
0
- s.summary = SUMMARY
0
- s.description = s.summary
0
- s.author = AUTHOR
0
- s.email = EMAIL
0
- s.homepage = HOMEPAGE
0
- s.add_dependency('merb-core', '>= 0.9.2')
0
- s.require_path = 'lib'
0
- s.autorequire = PLUGIN
0
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
0
-end
0
-
0
-Rake::GemPackageTask.new(spec) do |pkg|
0
- pkg.gem_spec = spec
0
-end
0
-
0
-task :install => [:package] do
0
- sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
0
-end
0
-
0
-task :release => :package do
0
- sh %{rubyforge add_release merb-plugins merb_has_flash #{VERSION} pkg/#{NAME}-#{VERSION}.gem}
0
-end
...
1
2
3
4
5
...
 
 
 
 
 
0
@@ -1,6 +1 @@
0
-TODO:
0
-Fix LICENSE with your name
0
-Fix Rakefile with your name and contact info
0
-Add your code to lib/merb_has_flash.rb
0
-Add your Merb rake tasks to lib/merb_has_flash/merbtasks.rb
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,40 +1 @@
0
-unless defined?(Merb::Plugins)
0
- raise %q{merb_has_flash says, "Something's not right, bub. You should run me inside Merb, or at least cheat and define a Merb::Plugins constant."}
0
-end
0
-
0
-require 'merb_has_flash/flash_hash'
0
-
0
-require 'merb_has_flash/controller_extension'
0
-Merb::Controller.send :include, MerbHasFlash::ControllerExtension
0
-
0
-require 'merb_has_flash/helper'
0
-Merb::RenderMixin.send :include, MerbHasFlash::FlashHelperMixin
0
-
0
-module MerbHasFlash
0
- # The flash provides a way to pass temporary objects between actions. Anything you place in the flash will be exposed
0
- # to the very next action and then cleared out. This is a great way of doing notices and alerts, such as a create action
0
- # that sets <tt>flash[:notice] = "Successfully created"</tt> before redirecting to a display action that can then expose
0
- # the flash to its template. Actually, that exposure is automatically done. Example:
0
- #
0
- # class WeblogController < Merb::Controller
0
- # def create
0
- # # save post
0
- # flash[:notice] = "Successfully created post"
0
- # redirect_to :action => "display", :params => { :id => post.id }
0
- # end
0
- #
0
- # def display
0
- # # doesn't need to assign the flash notice to the template, that's done automatically
0
- # render
0
- # end
0
- # end
0
- #
0
- # display.html.erb
0
- # <% if flash[:notice] %><div class="notice"><%= flash[:notice] %></div><% end %>
0
- #
0
- # This example just places a string in the flash, but you can put any object in there. And of course, you can put as many
0
- # as you like at a time too. Just remember: They'll be gone by the time the next action has been performed.
0
- #
0
- # See docs on the FlashHash class for more details about the flash.
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,39 +1 @@
0
-module MerbHasFlash
0
- module ControllerExtension
0
- def self.included(base)
0
- base.send :include, InstanceMethods
0
-
0
- base.class_eval {
0
- after :sweep_flash
0
- }
0
- end
0
-
0
- module InstanceMethods
0
- # Access the contents of the flash. Use <tt>flash["notice"]</tt> to read a notice you put there or
0
- # <tt>flash["notice"] = "hello"</tt> to put a new one.
0
- # Note that if sessions are disabled only flash.now will work.
0
- def flash(refresh = false) #:doc:
0
- if !defined?(@_flash) || refresh
0
- @_flash =
0
- if session.is_a?(Hash)
0
- # don't put flash in session if disabled
0
- FlashHash.new
0
- else
0
- # otherwise, session is a CGI::Session or a TestSession
0
- # so make sure it gets retrieved from/saved to session storage after request processing
0
- session["flash"] ||= FlashHash.new
0
- end
0
- end
0
-
0
- @_flash
0
- end
0
-
0
- protected
0
- def sweep_flash
0
- flash.sweep if request.session
0
- session["flash"] = flash
0
- end
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,102 +1 @@
0
-module MerbHasFlash
0
- class FlashNow #:nodoc:
0
- def initialize(flash)
0
- @flash = flash
0
- end
0
-
0
- def []=(k, v)
0
- @flash[k] = v
0
- @flash.discard(k)
0
- v
0
- end
0
-
0
- def [](k)
0
- @flash[k]
0
- end
0
- end
0
-
0
- class FlashHash < Hash
0
- def initialize #:nodoc:
0
- super
0
- @used = {}
0
- end
0
-
0
- def []=(k, v) #:nodoc:
0
- keep(k)
0
- super
0
- end
0
-
0
- def update(h) #:nodoc:
0
- h.keys.each{ |k| discard(k) }
0
- super
0
- end
0
-
0
- alias :merge! :update
0
-
0
- def replace(h) #:nodoc:
0
- @used = {}
0
- super
0
- end
0
-
0
- # Sets a flash that will not be available to the next action, only to the current.
0
- #
0
- # flash.now[:message] = "Hello current action"
0
- #
0
- # This method enables you to use the flash as a central messaging system in your app.
0
- # When you need to pass an object to the next action, you use the standard flash assign (<tt>[]=</tt>).
0
- # When you need to pass an object to the current action, you use <tt>now</tt>, and your object will
0
- # vanish when the current action is done.
0
- #
0
- # Entries set via <tt>now</tt> are accessed the same way as standard entries: <tt>flash['my-key']</tt>.
0
- def now
0
- FlashNow.new self
0
- end
0
-
0
- # Keeps either the entire current flash or a specific flash entry available for the next action:
0
- #
0
- # flash.keep # keeps the entire flash
0
- # flash.keep(:notice) # keeps only the "notice" entry, the rest of the flash is discarded
0
- def keep(k = nil)
0
- use(k, false)
0
- end
0
-
0
- # Marks the entire flash or a single flash entry to be discarded by the end of the current action
0
- #
0
- # flash.keep # keep entire flash available for the next action
0
- # flash.discard(:warning) # discard the "warning" entry (it'll still be available for the current action)
0
- def discard(k = nil)
0
- use(k)
0
- end
0
-
0
- # Mark for removal entries that were kept, and delete unkept ones.
0
- #
0
- # This method is called automatically by filters, so you generally don't need to care about it.
0
- def sweep #:nodoc:
0
- keys.each do |k|
0
- unless @used[k]
0
- use(k)
0
- else
0
- delete(k)
0
- @used.delete(k)
0
- end
0
- end
0
-
0
- (@used.keys - keys).each{|k| @used.delete k } # clean up after keys that could have been left over by calling reject! or shift on the flash
0
- end
0
-
0
- private
0
- # Used internally by the <tt>keep</tt> and <tt>discard</tt> methods
0
- # use() # marks the entire flash as used
0
- # use('msg') # marks the "msg" entry as used
0
- # use(nil, false) # marks the entire flash as unused (keeps it around for one more action)
0
- # use('msg', false) # marks the "msg" entry as unused (keeps it around for one more action)
0
- def use(k=nil, v=true)
0
- unless k.nil?
0
- @used[k] = v
0
- else
0
- keys.each{|key| use key, v }
0
- end
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
...
 
 
 
 
 
 
 
0
@@ -1,8 +1 @@
0
-module MerbHasFlash
0
- module FlashHelperMixin
0
- def flash
0
- @web_controller.flash
0
- end
0
- end
0
-end
...
1
2
3
4
5
6
7
...
 
 
 
 
 
 
 
0
@@ -1,8 +1 @@
0
-require File.dirname(__FILE__) + '/../spec_helper'
0
-
0
-describe "merb_has_flash Controller Extension" do
0
- it "should copy-and-paste from rails" do
0
-
0
- end
0
-end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,25 +1 @@
0
-require File.dirname(__FILE__) + '/../spec_helper'
0
-require 'merb_has_flash/flash_hash'
0
-
0
-describe "merb_has_flash FlashHash" do
0
- before(:each) do
0
- @hash = MerbHasFlash::FlashHash.new
0
- end
0
-
0
- it "should be a kind of Hash" do
0
- @hash.should be_a_kind_of(Hash)
0
- end
0
-
0
- it "should initialize an empty @used hash" do
0
- @hash.instance_variable_get(:@used).should == {}
0
- end
0
-
0
- it "should have more specs" do
0
-
0
- end
0
-
0
- it "should copy-and-paste most of this from Rails" do
0
-
0
- end
0
-end
...
1
2
...
 
 
0
@@ -1,3 +1 @@
0
-$TESTING=true
0
-$:.push File.join(File.dirname(__FILE__), '..', 'lib')
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,21 +1 @@
0
-Copyright (c) 2007 Michael D. Ivey
0
-
0
-Permission is hereby granted, free of charge, to any person obtaining
0
-a copy of this software and associated documentation files (the
0
-"Software"), to deal in the Software without restriction, including
0
-without limitation the rights to use, copy, modify, merge, publish,
0
-distribute, sublicense, and/or sell copies of the Software, and to
0
-permit persons to whom the Software is furnished to do so, subject to
0
-the following conditions:
0
-
0
-The above copyright notice and this permission notice shall be
0
-included in all copies or substantial portions of the Software.
0
-
0
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...
1
2
3
4
5
6
7
8
...
 
 
 
 
 
 
 
 
0
@@ -1,9 +1 @@
0
-merb_has_rails_plugins
0
-=================
0
-
0
-A plugin for the Merb framework that provides autoloading of Rails
0
-plugins from plugins/ dir.
0
-
0
-Please send bug reports to Michael Ivey directly for the time being:
0
- ivey@gweezlebur.com or ivey on #merb
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,40 +1 @@
0
-require 'rubygems'
0
-require 'rake/gempackagetask'
0
-
0
-PLUGIN = "merb_has_rails_plugins"
0
-NAME = "merb_has_rails_plugins"
0
-VERSION = "0.1.0"
0
-AUTHOR = "Michael D. Ivey"
0
-EMAIL = "ivey@gweezlebur.com"
0
-HOMEPAGE = "http://merb-plugins.rubyforge.org/merb_has_rails_plugins/"
0
-SUMMARY = "Merb plugin that provides autoloading of Rails plugins from plugins/ dir"
0
-
0
-spec = Gem::Specification.new do |s|
0
- s.name = NAME
0
- s.version = VERSION
0
- s.platform = Gem::Platform::RUBY
0
- s.has_rdoc = true
0
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
0
- s.summary = SUMMARY
0
- s.description = s.summary
0
- s.author = AUTHOR
0
- s.email = EMAIL
0
- s.homepage = HOMEPAGE
0
- s.add_dependency('merb', '>= 0.5.0')
0
- s.require_path = 'lib'
0
- s.autorequire = PLUGIN
0
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
0
-end
0
-
0
-Rake::GemPackageTask.new(spec) do |pkg|
0
- pkg.gem_spec = spec
0
-end
0
-
0
-task :install => [:package] do
0
- sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
0
-end
0
-
0
-task :release => :package do
0
- sh %{rubyforge add_release merb-plugins #{PLUGIN} #{VERSION} pkg/#{NAME}-#{VERSION}.gem}
0
-end
...
1
2
3
4
5
...
 
 
 
 
 
0
@@ -1,6 +1 @@
0
-TODO:
0
-Fix LICENSE with your name
0
-Fix Rakefile with your name and contact info
0
-Add your code to lib/merb_has_rails_plugins.rb
0
-Add your Merb rake tasks to lib/merb_has_rails_plugins/merbtasks.rb
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
@@ -1,18 +1 @@
0
-# make sure we're running inside Merb
0
-if defined?(Merb::Plugins)
0
- puts "Loading Rails plugins from plugins/"
0
- Dir["#{Merb.root}/plugins/*"].each do |dir|
0
- plugin_init = dir / 'init.rb'
0
- plugin_lib = dir / 'lib'
0
-
0
- if File.directory?(plugin_lib)
0
- if defined?(ActiveSupport)
0
- Dependencies.load_paths << plugin_lib
0
- Dependencies.load_once_paths << plugin_lib
0
- end
0
- $LOAD_PATH << plugin_lib
0
- end
0
- require plugin_init if File.exist?(plugin_init)
0
- end
0
-end

Comments

    No one has commented yet.