ventouse 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +7 -0
- data/lib/ventouse.rb +41 -0
- data/lib/ventouse/ar_touch.rb +32 -0
- data/lib/ventouse/disable_transactions.rb +5 -0
- data/lib/ventouse/filter_prefix.rb +12 -0
- data/lib/ventouse/fix_partial_updates.rb +7 -0
- data/lib/ventouse/module_declarations.rb +33 -0
- data/lib/ventouse/mysql_compat.rb +1214 -0
- data/lib/ventouse/rename_type_column.rb +1 -0
- data/lib/ventouse/rescue_ext.rb +28 -0
- data/lib/ventouse/resource_as_root.rb +27 -0
- data/lib/ventouse/suppress_logging_for.rb +20 -0
- data/test/declarations_test.rb +77 -0
- metadata +80 -0
@@ -0,0 +1 @@
|
|
1
|
+
ActiveRecord::Base.inheritance_column = 'sti_type'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
3
|
+
module RescueExt
|
4
|
+
def rescue_all default = nil, silent = false
|
5
|
+
begin
|
6
|
+
return yield
|
7
|
+
rescue Exception => e
|
8
|
+
unless silent
|
9
|
+
Rails.logger.warn "Exception rescued:"
|
10
|
+
Rails.logger.warn e
|
11
|
+
if e.respond_to? :io
|
12
|
+
Rails.logger.warn "URI: '#{e.io.meta['location']}'"
|
13
|
+
end
|
14
|
+
Rails.logger.warn e.backtrace.join("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
return default
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def silently_rescue_all default = nil, &block
|
22
|
+
rescue_all default, true, &block
|
23
|
+
end
|
24
|
+
|
25
|
+
def timeout sec, default = nil
|
26
|
+
rescue_all(default) {Timeout.timeout(sec) { yield }}
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Fix routing to enable this:
|
2
|
+
#
|
3
|
+
# map.resources :organizations, :as => :root
|
4
|
+
#
|
5
|
+
# to produce this:
|
6
|
+
#
|
7
|
+
# organizations GET /
|
8
|
+
# new_organization GET /new
|
9
|
+
# edit_organization GET /:id/edit
|
10
|
+
# organization GET /:id
|
11
|
+
#
|
12
|
+
module ResourceAsRoot
|
13
|
+
module ResourcesHacks
|
14
|
+
def map_resource_routes map, resource, action, route_path, *args
|
15
|
+
route_path.gsub!(/\/\//, '/')
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def map_resource entities, options = {}, *args
|
20
|
+
options[:as] = '' if options[:as] == :root
|
21
|
+
super
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ActionController::Resources.send :include, ResourceAsRoot::ResourcesHacks
|
27
|
+
ActionController::Routing::RouteSet::Mapper.send :include, ResourceAsRoot::ResourcesHacks # Just cause it's too late
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActionController
|
2
|
+
class Base
|
3
|
+
def self.suppress_logging_for *actions
|
4
|
+
unless respond_to? :actions_without_logging
|
5
|
+
cattr_accessor :actions_without_logging
|
6
|
+
|
7
|
+
self.actions_without_logging = []
|
8
|
+
|
9
|
+
define_method :process do |request, *args|
|
10
|
+
if self.class.actions_without_logging.include?((request['action'] || 'index').to_sym)
|
11
|
+
logger.silence { super }
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
self.actions_without_logging.concat actions.flatten
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require File.dirname(__FILE__) + "/../lib/ventouse/module_declarations"
|
3
|
+
|
4
|
+
module SmokeExt
|
5
|
+
declarations do
|
6
|
+
self.class_var= "ok"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module SecondExt
|
11
|
+
declarations do
|
12
|
+
self.class_var= "ok2"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module MultipleDeclarationsModule
|
17
|
+
declarations do
|
18
|
+
self.class_var= "x"
|
19
|
+
end
|
20
|
+
|
21
|
+
declarations do
|
22
|
+
self.class_var+= "x"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module IncludedModule
|
27
|
+
declarations do
|
28
|
+
self.class_var+= "y"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module IncludingModule
|
33
|
+
declarations do
|
34
|
+
self.class_var= "x"
|
35
|
+
end
|
36
|
+
|
37
|
+
include IncludedModule
|
38
|
+
|
39
|
+
declarations do
|
40
|
+
self.class_var+= "z"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class SmokeExpandable
|
45
|
+
def self.class_var= var
|
46
|
+
@@class_var = var
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.class_var
|
50
|
+
@@class_var if defined? @@class_var
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class DeclarationsTest < Test::Unit::TestCase
|
55
|
+
def test_smoke
|
56
|
+
SmokeExpandable.send :include, SmokeExt
|
57
|
+
assert_equal "ok", SmokeExpandable.class_var
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_second_module
|
61
|
+
SmokeExpandable.send :include, SmokeExt
|
62
|
+
assert_equal "ok", SmokeExpandable.class_var
|
63
|
+
|
64
|
+
SmokeExpandable.send :include, SecondExt
|
65
|
+
assert_equal "ok2", SmokeExpandable.class_var
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_multiple_declarations
|
69
|
+
SmokeExpandable.send :include, MultipleDeclarationsModule
|
70
|
+
assert_equal "xx", SmokeExpandable.class_var
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_module_including
|
74
|
+
SmokeExpandable.send :include, IncludingModule
|
75
|
+
assert_equal "xyz", SmokeExpandable.class_var
|
76
|
+
end
|
77
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ventouse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilia Ablamonov
|
8
|
+
- Artem Orlov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-08-04 00:00:00 +04:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rails
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.3.2
|
25
|
+
version:
|
26
|
+
description: Various usefull ruby/rails shit
|
27
|
+
email: pro@grammable.com
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- README
|
36
|
+
- lib/ventouse/ar_touch.rb
|
37
|
+
- lib/ventouse/disable_transactions.rb
|
38
|
+
- lib/ventouse/filter_prefix.rb
|
39
|
+
- lib/ventouse/fix_partial_updates.rb
|
40
|
+
- lib/ventouse/module_declarations.rb
|
41
|
+
- lib/ventouse/mysql_compat.rb
|
42
|
+
- lib/ventouse/rename_type_column.rb
|
43
|
+
- lib/ventouse/rescue_ext.rb
|
44
|
+
- lib/ventouse/resource_as_root.rb
|
45
|
+
- lib/ventouse/suppress_logging_for.rb
|
46
|
+
- lib/ventouse.rb
|
47
|
+
- test/declarations_test.rb
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/programmable/ventouse
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --quiet
|
55
|
+
- --main=README
|
56
|
+
- --inline-source
|
57
|
+
- --charset=UTF-8
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.1
|
71
|
+
version:
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.3.5
|
76
|
+
signing_key:
|
77
|
+
specification_version: 2
|
78
|
+
summary: Various usefull ruby/rails shit.
|
79
|
+
test_files:
|
80
|
+
- test/declarations_test.rb
|