Contents |
(Ruby support libraries that are packaged as Rails plugins (unfortunately), as well as some that are plain old gems...)
| Categories/Tags: | [dependency injection (category)]
|
|---|---|
| Project/Development: | http://rubyforge.org/projects/injection/
|
| Description: | Injection is a simple dependency injection plugin for rails which lets you inject objects into your controllers which have been declared in a YAML file.
|
...
Named Options| As listed in other directories: | http://rubyfurnace.com/plugins/named_options
|
|---|
def user(*args) options = NamedOptions.new(:name, :age, args) options[:name] # => “maiha” options[:age] # => 14 end
Lets you call it using ordered arguments or with a hash of arguments/options...
user(“maiha”, 14) user(:name => ‘maiha’, :age => 14) user(“maiha”, :age => 14)
http://rubyfurnace.com/plugins/sandboxed_methods
Avoid conflicting method and variable names between modules.
"We unconsciously prefer shorter names and tend to use well-conflictable method names such as ‘names’, ‘valid?’, ‘path’ for middle(internal) methods. Indeed it works sanely in your system, but how about outside of it?"
To use it, just change your module from this:
1 module Foo
2 def self.included(base)
3 base.__send__ :include, InstanceMethods
4 end
5
6 module InstanceMethods
...
16 end
17 end
to this:
1 module Foo
2 def self.included(base)
3 InstanceMethods.give(base, :foo) # 1) use 'give' class methods
4 end
5
6 class InstanceMethods < SandboxedMethods # 2) use SandboxedMethods class
...
16 end
17 end
It basically does this by prefixing each method with the name of the class ("class_name__method_name"?) and then delegating (?) all method calls...
http://wota.jp/svn/rails/plugins/trunk/sandboxed_methods/lib/sandboxed_methods.rb
def give(base, *methods)
target = (methods.last.is_a?(Hash) && methods.pop[:class]) ? (class<<base; self end) : base
methods = instance_methods - SandboxedMethods.instance_methods if methods.empty?
methods << {:to=>"(@_#{name.underscore.gsub('/', '__')} ||= #{self}.new(self))"}
target.delegate *methods
end
| Rating: | ↓ |
|---|---|
| Homepage: | [1] |
| Source code: | http://ar-code.svn.engineyard.com/plugins/relative_time_helpers/
|
http://ar-code.svn.engineyard.com/plugins/relative_time_helpers/init.rb
# Used for getting multifield attributes like those generated by a
# select_datetime into a new Time object. For example if you have
# following <tt>params={:meetup=>{:"time(1i)=>..."}}</tt> just do
# following:
#
# <tt>Time.parse_from_attributes(params[:meetup], :time)</tt>
def parse_from_attributes(attrs, field, method=:gm)
attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] }
attrs.any? ? Time.send(method, *attrs) : nil
end
Con: They foist their date format preferences on you (Nov 15th, rather than 15 November or 11-15):
http://ar-code.svn.engineyard.com/plugins/relative_time_helpers/test/relative_time_helpers_test.rb
def test_should_show_date_span_on_the_different_year
assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2007, 12, 16)])
assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2006, 11, 15)])
end
interpolated_time_formats| Homepage: | http://wiki.pluginaweek.org/Interpolated_time_formats |
|---|---|
| Source code: | http://svn.pluginaweek.org/trunk/plugins/ruby/time/interpolated_time_formats
|
| As listed in other directories: | http://rubyfurnace.com/plugins/interpolated_time_formats
|
http://wiki.pluginaweek.org/Interpolated_time_formats
Rather than requiring the addition of helper methods, this plugin proposes creating such strings with strftime. For example,
>> Time.parse('12/31/2006').strftime('#{day.ordinalize} of %B') => "31st of December"
http://users.webtest.wvu.edu/cbscharf/eztime/
puts d.eztime(":day :nmonth :year at :hour12::minute::second
:lmeridian")
=> 20 December 2003 at 5:30:00 pm
http://rubyfurnace.com/plugins/date_finder
Can find dates that match certain criteria. Eg: The next three Tuesdays:
DateFinderBase.weekly.day(:tuesday).find(:max => 3)The last Monday for the next three months:DateFinderBase.monthly.day(:monday).day_occurrence(:last).find(:max => 3)
Note: This appears to have nothing at all to do with ActiveRecord searching (kind of deceptive, if you ask me, since it's packaged as a Rails plugin). Rather, it actually returns Date instances as the results of its "searches".
http://rubyfurnace.com/plugins/object_id_session
A very simple plugin that allows to store ActiveRecord models over session using their IDs transparently.
session[:user] = User.find(id) # After this, your session will have :user => id and ?__user_object_id_session? => User.
[GnuPG (category)] plugin [API wrappers for command-line applications (category)]| Homepage: | http://www.ahgsoftware.com/pages/erb_buffer |
|---|---|
| Source code: | svn://ahgsoftware.com/gnupg/trunk
|
| As listed in other directories: | http://rubyfurnace.com/plugins/gnupg
|
passphrase = "uglydonkeys"
gnupg = GnuPG.new :binary=>"/opt/local/bin/gpg",
:workdir=>workdir,
:homedir_pub=>workdir,
:homedir_sec=>workdir,
:recipient=>"your uid"
plain_message = "my secret message"
encrypted_message = gnupg.encrypt(plain_message)
gnupg.load_key File.read("sec_key.asc")
decrypted_message = gnupg.decrypt(encrypted_message, passphrase)
gnupg.drop_key
http://railmail.nullstyle.com/
Advantages:
Problems:
Conclusion: Seems like overkill to me. Maybe some applications would have more need of e-mail logging, but I probably typically wouldn't.
http://weblog.rubyonrails.com/2005/11/11/why-engines-and-components-are-not-evil-but-distracting McNewby, 2005-11-16 05:50:
http://rubyfurnace.com/plugins/secure_action_plugin
| Description | [Oops! No type defined for attribute] |