padrino-contrib 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of padrino-contrib might be problematic. Click here for more details.

data/README.rdoc CHANGED
@@ -29,4 +29,4 @@ In your Padrino project edit:
29
29
  # app.rb
30
30
  class MyApp < Padrino::Application
31
31
  register Padrino::Contrib::ExceptionNotifier
32
- end
32
+ end
@@ -8,6 +8,15 @@ module Padrino
8
8
  module Helpers
9
9
  autoload :AssetsCompressor, 'padrino-contrib/helpers/assets_compressor.rb'
10
10
  autoload :JQuery, 'padrino-contrib/helpers/jquery.rb'
11
+ autoload :Flash, 'padrino-contrib/helpers/flash.rb'
11
12
  end # Helpers
12
13
  end # Contrib
13
- end # Padrino
14
+ end # Padrino
15
+
16
+ if defined?(ActiveRecord)
17
+ Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/active_record/**/*.rb')].each { |d| require d }
18
+ end
19
+
20
+ if defined?(MongoMapper)
21
+ Dir[File.join(File.expand_path('../', __FILE__), '/padrino-contrib/orm/mongo_mapper/**/*.rb')].each { |d| require d }
22
+ end
@@ -22,7 +22,7 @@ module Padrino
22
22
  # This reload the page changing the I18n.locale
23
23
  #
24
24
  def switch_to_lang(lang)
25
- request.path_info.sub(/\/#{I18n.locale}/, "/#{lang}") if options.locales.include?(lang)
25
+ request.path_info.sub(/\/#{I18n.locale}/, "/#{lang}") if settings.locales.include?(lang)
26
26
  end
27
27
  end # Helpers
28
28
 
@@ -31,10 +31,10 @@ module Padrino
31
31
  app.extend ClassMethods
32
32
  app.set :locales, [:en]
33
33
  app.before do
34
- if request.path_info =~ /^\/(#{options.locales.join('|')})\b/
34
+ if request.path_info =~ /^\/(#{settings.locales.join('|')})\b/
35
35
  I18n.locale = $1.to_sym
36
36
  else
37
- I18n.locale = options.locales[0]
37
+ I18n.locale = settings.locales[0]
38
38
  not_found if request.path_info !~ /^\/?$/
39
39
  end
40
40
  end
@@ -20,11 +20,11 @@ module Padrino
20
20
  module ExceptionNotifier
21
21
 
22
22
  def self.registered(app)
23
- app.set :exceptions_subject, "Exception"
24
- app.set :exceptions_to, "errors@localhost.local"
25
- app.set :exceptions_from, "foo@bar.local"
26
- app.set :exceptions_layout, :layout
27
- app.set :redmine, {}
23
+ app.set :exceptions_subject, "Exception" unless app.respond_to?(:exceptions_subject)
24
+ app.set :exceptions_to, "errors@localhost.local" unless app.respond_to?(:exceptions_to)
25
+ app.set :exceptions_from, "foo@bar.local" unless app.respond_to?(:exceptions_from)
26
+ app.set :exceptions_layout, :layout unless app.respond_to?(:exceptions_layout)
27
+ app.set :redmine, {} unless app.respond_to?(:redmine)
28
28
  app.error 500 do
29
29
  boom = env['sinatra.error']
30
30
  body = ["#{boom.class} - #{boom.message}:", *boom.backtrace].join("\n ")
@@ -34,4 +34,4 @@ module Padrino
34
34
  end
35
35
  end # FlashSession
36
36
  end # Contrib
37
- end # Padrino
37
+ end # Padrino
@@ -148,4 +148,4 @@ module Padrino
148
148
  end # AssetsCompressor
149
149
  end # Helpers
150
150
  end # Contrib
151
- end # Padrino
151
+ end # Padrino
@@ -0,0 +1,32 @@
1
+ module Padrino
2
+ module Contrib
3
+ module Helpers
4
+ ##
5
+ # Dead simple version of rack-flash.
6
+ # You still use flash without session, but remember that
7
+ # they can't work after a redirect.
8
+ #
9
+ # ==== Usage:
10
+ #
11
+ # register Padrino::Contrib::Helpers::Flash
12
+ #
13
+ module Flash
14
+ def self.register(app)
15
+ app.before { @_flash, session[:_flash] = session[:_flash], nil if settings.sessions? && session[:_flash] }
16
+ app.helpers InstanceMethods
17
+ end
18
+
19
+ module InstanceMethods
20
+ def flash
21
+ @_flash ||= {}
22
+ end
23
+
24
+ def redirect(uri, *args)
25
+ session[:_flash] = @_flash if settings.sessions? && flash.present?
26
+ super(uri, *args)
27
+ end
28
+ end
29
+ end # Flash
30
+ end # Helpers
31
+ end # Contrib
32
+ end # Padrino
@@ -59,4 +59,4 @@ module Padrino
59
59
  end # JQuery
60
60
  end # Helpers
61
61
  end # Contrib
62
- end # Padrino
62
+ end # Padrino
@@ -38,7 +38,7 @@ module Padrino
38
38
  end
39
39
  end # InstanceMethods
40
40
  end # Permalink
41
- end # Ar
41
+ end # ActiveRecord
42
42
  end # Orm
43
43
  end # Contrib
44
44
  end # Padrino
@@ -56,7 +56,7 @@ module Padrino
56
56
  end
57
57
  end # InstanceMethods
58
58
  end # PemalinkI18n
59
- end # Ar
59
+ end # ActiveRecord
60
60
  end # Orm
61
61
  end # Contrib
62
62
  end # Padrino
@@ -1,5 +1,3 @@
1
- require 'RedCloth'
2
-
3
1
  module Padrino
4
2
  module Contrib
5
3
  module Orm
@@ -18,6 +16,7 @@ module Padrino
18
16
  module Textile
19
17
  module ClassMethods
20
18
  def has_textile(*fields)
19
+ require 'RedCloth'
21
20
  include InstanceMethods
22
21
  options = fields.extract_options!
23
22
  options.reverse_merge!(:internal_links => :blog)
@@ -52,8 +51,8 @@ module Padrino
52
51
  end
53
52
  end
54
53
  end # InstanceMethods
55
- end # Permalink
56
- end # Ar
54
+ end # Textile
55
+ end # ActiveRecord
57
56
  end # Orm
58
57
  end # Contrib
59
58
  end # Padrino
@@ -35,9 +35,9 @@ module Padrino
35
35
  super
36
36
  end
37
37
  end # InstanceMethods
38
- end # ArTranslate
39
- end # Ar
38
+ end # Translate
39
+ end # ActiveRecord
40
40
  end # Orm
41
41
  end # Contrib
42
42
  end # Padrino
43
- ::ActiveRecord::Base.extend(Padrino::Contrib::Orm::ActiveRecord::Translate::ClassMethods)
43
+ ::ActiveRecord::Base.extend(Padrino::Contrib::Orm::ActiveRecord::Translate::ClassMethods)
@@ -47,7 +47,7 @@ module Padrino
47
47
  end
48
48
  end # InstanceMethods
49
49
  end # Permalink
50
- end # Mm
50
+ end # MongoMapper
51
51
  end # Orm
52
52
  end # Contrib
53
53
  end # Padrino
@@ -32,7 +32,7 @@ module Padrino
32
32
  end
33
33
  end
34
34
  end # Permalink
35
- end # Mm
35
+ end # MongoMapper
36
36
  end # Orm
37
37
  end # Contrib
38
38
  end # Padrino
@@ -1,5 +1,5 @@
1
1
  module Padrino
2
2
  module Contrib
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -18,4 +18,4 @@ describe 'Autoload' do
18
18
 
19
19
  it(klass) { eval("#{klass}").should be_true }
20
20
  end
21
- end
21
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  require 'rubygems' unless defined?(Gem)
2
2
  require 'rspec' unless defined?(RSpec)
3
- require 'padrino-contrib'
3
+ require 'padrino-contrib'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-contrib
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 5
10
- version: 0.1.5
9
+ - 6
10
+ version: 0.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Davide D'Agostino
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-08-31 00:00:00 +02:00
20
+ date: 2011-09-26 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies: []
23
23
 
@@ -40,6 +40,7 @@ files:
40
40
  - lib/padrino-contrib/exception_notifier.rb
41
41
  - lib/padrino-contrib/flash_session.rb
42
42
  - lib/padrino-contrib/helpers/assets_compressor.rb
43
+ - lib/padrino-contrib/helpers/flash.rb
43
44
  - lib/padrino-contrib/helpers/jquery.rb
44
45
  - lib/padrino-contrib/orm/active_record/permalink.rb
45
46
  - lib/padrino-contrib/orm/active_record/permalink_i18n.rb