voidtools 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -1,14 +1,30 @@
1
- = Voidrails
1
+ # Voidtools
2
+ #### growing toolset for Rails 3 dm+jquery+haml+warden setup flavored with:
2
3
 
3
- == growing toolset for Rails 3 dm+jquery+haml+warden setup flavored with:
4
+ ---
4
5
 
5
- === DataMapper
6
- - error_messages_for
6
+ ### DataMapper
7
+ - `error_messages_for`
7
8
 
8
- === Haml
9
- -
9
+ ### Haml
10
+ - soon...
10
11
 
11
- === Warden, Devise
12
- -
12
+ ### Warden, Devise
13
+ - soon...
13
14
 
14
- ruby 1.9 required
15
+ note: ruby 1.9 required
16
+
17
+ ## DataMapper
18
+ ### error_messages_for
19
+
20
+ in your form view:
21
+
22
+ `error_messages_for :resource`
23
+
24
+ or
25
+
26
+ `error_messages_for @resource`
27
+
28
+ ### Build & install
29
+
30
+ gem build voidtools.gemspec; gem install voidtools-0.1.2.gem
@@ -2,24 +2,32 @@ module Voidtools
2
2
 
3
3
  # namespace our plugin and inherit from Rails::Railtie
4
4
  # to get our plugin into the initialization process
5
- class Railtie < Rails::Railtie
5
+ if defined?(Rails)
6
+ class Railtie < Rails::Railtie
6
7
 
7
- # configure our plugin on boot. other extension points such
8
- # as configuration, rake tasks, etc, are also available
9
- initializer "voidtools.initialize" do |app|
8
+ # configure our plugin on boot. other extension points such
9
+ # as configuration, rake tasks, etc, are also available
10
+ initializer "voidtools.initialize" do |app|
10
11
 
11
- # subscribe to all rails notifications: controllers, AR, etc.
12
- # ActiveSupport::Notifications.subscribe do |*args|
13
- # event = ActiveSupport::Notifications::Event.new(*args)
14
- # puts "Voidrails - got notification: #{event.inspect}"
15
- # end
16
- # ActiveSupport.on_load(:action_view) do
17
- # # module ApplicationHelper
18
- # # include FormHelpers
19
- # # end
20
- # end
21
- require 'voidtools/datamapper/form_helpers'
12
+ # subscribe to all rails notifications: controllers, AR, etc.
13
+ # ActiveSupport::Notifications.subscribe do |*args|
14
+ # event = ActiveSupport::Notifications::Event.new(*args)
15
+ # puts "Voidrails - got notification: #{event.inspect}"
16
+ # end
17
+ require 'voidtools/dm/form_helpers'
18
+ ActiveSupport.on_load(:action_view) do
19
+ module ApplicationHelper
20
+ include Voidtools::FormHelpers
21
+ end
22
+ end
23
+ # require 'voidtools/dm/name_url'
24
+ # require 'voidtools/dm/paginable'
25
+ end
22
26
  end
23
27
  end
24
28
 
29
+ if defined?(Sinatra)
30
+ path = File.expand_path "../", __FILE__
31
+ require "#{path}/voidtools/sinatra/sinatra"
32
+ end
25
33
  end
@@ -0,0 +1,16 @@
1
+ module Voidtools
2
+ module NameUrl
3
+ def generate_name_url
4
+ nurl = name.gsub(/\./, '').gsub(/'|"/, ' ').gsub(/\s+/, '_').gsub(/_-_/, '_').downcase
5
+ update(name_url: nurl)
6
+ end
7
+ end
8
+
9
+ class NameUrler
10
+ def self.generate(klass, options={})
11
+ klass.all(options).each do |model|
12
+ model.generate_name_url
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,26 @@
1
+ module Voidtools
2
+
3
+ module Paginable
4
+
5
+ PER_PAGE = 70
6
+
7
+ def self.included(base)
8
+ base.send :extend, ClassMethods
9
+ end
10
+
11
+ module ClassMethods
12
+ def paginate(options)
13
+ page = options[:page].to_i
14
+ options.delete :page
15
+ all( options.merge(limit: PER_PAGE, offset: PER_PAGE*page) )
16
+ end
17
+
18
+ def pages
19
+ all.count/PER_PAGE
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,2 @@
1
+ path = File.expand_path "../", __FILE__
2
+ require "#{path}/view_helpers"
@@ -0,0 +1,15 @@
1
+ module Voidtools
2
+ module Sinatra
3
+ module ViewHelpers
4
+ def link_to(label, path)
5
+ haml_tag :a, { href: path } do
6
+ haml_concat label
7
+ end
8
+ end
9
+
10
+ def image_tag(url, options={})
11
+ haml_tag :img, options.merge(src: url)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module Voidtools
2
- VERSION = "0.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -4,8 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- version: "0.1"
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
9
10
  platform: ruby
10
11
  authors:
11
12
  - Francesco 'makevoid' Canessa
@@ -13,11 +14,11 @@ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
16
 
16
- date: 2010-08-09 00:00:00 +02:00
17
+ date: 2010-12-23 00:00:00 +01:00
17
18
  default_executable:
18
19
  dependencies: []
19
20
 
20
- description: "growing toolset for Rails 3 setup with helpers for: datamapper, jquery, haml and warden"
21
+ description: "custom rails3 toolset setup with helpers for: datamapper, jquery, haml and warden"
21
22
  email: makevoid@gmail.com
22
23
  executables: []
23
24
 
@@ -27,7 +28,11 @@ extra_rdoc_files: []
27
28
 
28
29
  files:
29
30
  - Readme.md
30
- - lib/voidtools/datamapper/form_helpers.rb
31
+ - lib/voidtools/dm/form_helpers.rb
32
+ - lib/voidtools/dm/name_url.rb
33
+ - lib/voidtools/dm/paginable.rb
34
+ - lib/voidtools/sinatra/sinatra.rb
35
+ - lib/voidtools/sinatra/view_helpers.rb
31
36
  - lib/voidtools/version.rb
32
37
  - lib/voidtools.rb
33
38
  has_rdoc: true
@@ -61,6 +66,6 @@ rubyforge_project: voidtools
61
66
  rubygems_version: 1.3.7
62
67
  signing_key:
63
68
  specification_version: 3
64
- summary: growing toolset for Rails 3 dm+jquery+haml+warden setup
69
+ summary: custom rails3 toolset - for dm+jquery+haml+warden setup
65
70
  test_files: []
66
71