cowtech-rails 1.9.5.3 → 1.9.6.0

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.
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the cowtech-rails gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ module SubdomainFu
8
+ def self.override_only_path?
9
+ true
10
+ end
11
+ end
12
+
13
+ module Cowtech
14
+ module RubyOnRails
15
+ module Extensions
16
+ module AR
17
+ extend ActiveSupport::Concern
18
+
19
+ module ClassMethods
20
+ if defined?(Rails) then
21
+ def table_prefix
22
+ p = ActiveRecord::Base.configurations[Rails.env]["table_prefix"]
23
+ !p.blank? ? p + "_" : ""
24
+ end
25
+
26
+ def table_suffix
27
+ p = ActiveRecord::Base.configurations[Rails.env]["table_suffix"]
28
+ !p.blank? ? p + "_" : ""
29
+ end
30
+ end
31
+
32
+ def set_table_name(value = nil, &block)
33
+ define_attr_method :table_name, "#{ActiveRecord::Base.table_prefix}#{value}#{ActiveRecord::Base.table_suffix}", &block
34
+ end
35
+
36
+ def find_or_create(oid, attributes = nil)
37
+ begin
38
+ self.find(oid)
39
+ rescue ActiveRecord::RecordNotFound
40
+ self.new(attributes)
41
+ end
42
+ end
43
+
44
+ def safe_find(oid)
45
+ begin
46
+ rv = self.find(oid)
47
+ rescue ActiveRecord::RecordNotFound
48
+ nil
49
+ end
50
+ end
51
+
52
+ def random
53
+ c = self.count
54
+ c != 0 ? self.find(:first, :offset => rand(c)) : nil
55
+ end
56
+
57
+ def per_page
58
+ 25
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -4,12 +4,6 @@
4
4
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
5
  #
6
6
 
7
- module SubdomainFu
8
- def self.override_only_path?
9
- true
10
- end
11
- end
12
-
13
7
  # To enable real SSL
14
8
  if defined?(Mail) then
15
9
  class Mail::SMTP
@@ -68,4 +62,8 @@ if defined?(Mail) then
68
62
  self
69
63
  end
70
64
  end
65
+ end
66
+
67
+ class ActiveRecord::Base
68
+ include Cowtech::Rails::Extensions::AR
71
69
  end
@@ -9,8 +9,8 @@ module Cowtech
9
9
  module Version
10
10
  MAJOR = 1
11
11
  MINOR = 9
12
- PATCH = 5
13
- BUILD = 3
12
+ PATCH = 6
13
+ BUILD = 0
14
14
 
15
15
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
16
16
  end
data/lib/cowtech.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  dir = File.dirname(__FILE__)
8
8
 
9
9
  require 'cowtech-extensions'
10
- require "cowtech-extensions/activerecord"
10
+ require 'cowtech/extensions'
11
11
  require 'cowtech/monkey_patches'
12
12
  #require dir + '/../app/models/e_mail'
13
13
  #require dir + '/../app/models/model_base'
@@ -18,4 +18,3 @@ module Cowtech
18
18
  end
19
19
 
20
20
  Cowtech::Extensions.load!
21
- Cowtech::Extensions.load!(["activerecord"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cowtech-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.5.3
4
+ version: 1.9.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-30 00:00:00.000000000Z
12
+ date: 2011-08-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cowtech-extensions
16
- requirement: &70207449337880 !ruby/object:Gem::Requirement
16
+ requirement: &70260196884320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70207449337880
24
+ version_requirements: *70260196884320
25
25
  description: A general purpose Rails utility plugin.
26
26
  email: shogun_panda@me.com
27
27
  executables: []
@@ -37,6 +37,7 @@ files:
37
37
  - app/models/cowtech/ruby_on_rails/models/e_mail.rb
38
38
  - app/models/cowtech/ruby_on_rails/models/model_base.rb
39
39
  - lib/cowtech.rb
40
+ - lib/cowtech/extensions.rb
40
41
  - lib/cowtech/monkey_patches.rb
41
42
  - lib/cowtech/version.rb
42
43
  - rails/init.rb