kelredd-useful 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ module Useful
2
+ module RailsExtensions
3
+ module EnvironmentTests
4
+
5
+ module ClassMethods
6
+
7
+ def production?
8
+ RAILS_ENV == 'production'
9
+ end
10
+
11
+ def development?
12
+ RAILS_ENV == 'development'
13
+ end
14
+
15
+ end
16
+
17
+ module InstanceMethods
18
+
19
+ def production?
20
+ self.class.production?
21
+ end
22
+
23
+ def development?
24
+ self.class.development?
25
+ end
26
+
27
+ end
28
+
29
+ def self.included(receiver)
30
+ receiver.extend ClassMethods
31
+ receiver.send :include, InstanceMethods
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+
38
+ module ActiveRecord
39
+ class Base
40
+ include Useful::RailsExtensions::EnvironmentTests
41
+ end
42
+ class Observer
43
+ include Useful::RailsExtensions::EnvironmentTests
44
+ end
45
+ end
46
+ module ActionController
47
+ class Base
48
+ include Useful::RailsExtensions::EnvironmentTests
49
+ end
50
+ end
51
+ module ActionView
52
+ class Base
53
+ include Useful::RailsExtensions::EnvironmentTests
54
+ end
55
+ end
56
+ module ActionMailer
57
+ class Base
58
+ include Useful::RailsExtensions::EnvironmentTests
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ Dir[File.join(File.dirname(__FILE__), "rails_extensions" ,"*.rb")].each do |file|
2
+ require file
3
+ end
@@ -5,6 +5,7 @@ module Useful
5
5
  def to_affirmative
6
6
  "No"
7
7
  end
8
+ alias :to_casual_s :to_affirmative
8
9
 
9
10
  def to_i
10
11
  0
@@ -42,7 +42,7 @@ module Useful
42
42
  # Determines if a value exists for the provided key(s). Allows searching in nested hashes
43
43
  def check_value?(*keys)
44
44
  val = self[keys.first] || self[keys.first.to_s]
45
- val = self[keys.first.to_s.intern] unless val || keys.first.kind_of?(Symbol)
45
+ val = self[keys.first.to_s.intern] unless val || keys.first.to_s.empty? || keys.first.kind_of?(Symbol)
46
46
  return val.check_value?(*keys[1..-1]) if val.kind_of?(Hash) && keys.length > 1
47
47
  return true if val && !val.empty?
48
48
  false
@@ -5,6 +5,7 @@ module Useful
5
5
  def to_affirmative
6
6
  "Yes"
7
7
  end
8
+ alias :to_casual_s :to_affirmative
8
9
 
9
10
  def to_i
10
11
  1
@@ -3,7 +3,7 @@ module Useful
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- TINY = 2
6
+ TINY = 3
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kelredd-useful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelredd
@@ -25,6 +25,9 @@ files:
25
25
  - README.rdoc
26
26
  - Rakefile
27
27
  - lib/useful
28
+ - lib/useful/rails_extensions
29
+ - lib/useful/rails_extensions/environment_tests.rb
30
+ - lib/useful/rails_extensions.rb
28
31
  - lib/useful/ruby_extensions
29
32
  - lib/useful/ruby_extensions/array.rb
30
33
  - lib/useful/ruby_extensions/date.rb