pg_decorator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
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('AppToRuleWorld')
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.starts_with? Rails.root.to_s
32
- last_line = last_line[Rails.root.to_s.length..-1]
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
@@ -1,3 +1,3 @@
1
1
  module PgDecorator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-20 00:00:00.000000000 Z
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: -3810251013660995226
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: -3810251013660995226
70
+ hash: -2000640059584004228
71
71
  requirements: []
72
72
  rubyforge_project:
73
73
  rubygems_version: 1.8.24