pg_decorator 0.0.2 → 0.0.3
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.md +2 -2
- data/lib/pg_decorator/decorator.rb +2 -2
- data/lib/pg_decorator/injector.rb +3 -1
- data/lib/pg_decorator/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -32,11 +32,11 @@ in your ruby script add following:
|
|
32
32
|
|
33
33
|
require 'rubygems'
|
34
34
|
require 'pg_decorator'
|
35
|
-
PgDecorator::Injector.inject('AppToRuleWorld')
|
35
|
+
PgDecorator::Injector.inject('AppToRuleWorld', '/home/ruby/world_ruler)
|
36
36
|
|
37
37
|
If you use Rails then you could create config/initializers/pg_decorator
|
38
38
|
|
39
|
-
PgDecorator::Injector.inject(
|
39
|
+
PgDecorator::Injector.inject(Rails.application.class.to_s.split("::").first, Rails.root.to_s)
|
40
40
|
|
41
41
|
## Contributing
|
42
42
|
|
@@ -28,8 +28,8 @@ module PgDecorator
|
|
28
28
|
def decorate_sql(sql)
|
29
29
|
last_line = caller.detect{|l| l !~ /\.?(rvm|gem|vendor|rbenv|pg_decorator)/ }
|
30
30
|
if last_line
|
31
|
-
if last_line.
|
32
|
-
last_line = last_line[
|
31
|
+
if last_line.start_with? app_root
|
32
|
+
last_line = last_line[app_root.length..-1]
|
33
33
|
end
|
34
34
|
"/* #{ escape_string(app_name) } #{escape_comment(last_line)} */\n#{sql}"
|
35
35
|
else
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module PgDecorator
|
2
2
|
class Injector
|
3
|
-
def self.inject(custom_app_name='Ruby pg app')
|
3
|
+
def self.inject(custom_app_name='Ruby pg app', custom_app_root=null)
|
4
|
+
custom_app_root ||= Dir.pwd
|
4
5
|
require 'pg' unless defined?( PG )
|
5
6
|
require_relative 'decorator'
|
6
7
|
PG::Connection.module_eval do
|
7
8
|
define_method(:app_name) { custom_app_name }
|
9
|
+
define_method(:app_root) { custom_app_root}
|
8
10
|
include PgDecorator::Decorator
|
9
11
|
end
|
10
12
|
true
|
data/lib/pg_decorator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -58,7 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
segments:
|
60
60
|
- 0
|
61
|
-
hash: -
|
61
|
+
hash: -2000640059584004228
|
62
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
63
|
none: false
|
64
64
|
requirements:
|
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
version: '0'
|
68
68
|
segments:
|
69
69
|
- 0
|
70
|
-
hash: -
|
70
|
+
hash: -2000640059584004228
|
71
71
|
requirements: []
|
72
72
|
rubyforge_project:
|
73
73
|
rubygems_version: 1.8.24
|