cowtech-extensions 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/
2
+ .idea/
3
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the cowtech-extensions 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
+
1
7
  source "http://rubygems.org"
2
8
 
3
- gem "jeweler"
9
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,19 +1,18 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cowtech-extensions (1.4.2)
5
+ active_support
6
+
1
7
  GEM
2
8
  remote: http://rubygems.org/
3
9
  specs:
4
- git (1.2.5)
5
- jeweler (1.8.3)
6
- bundler (~> 1.0)
7
- git (>= 1.2.5)
8
- rake
9
- rdoc
10
- json (1.6.5)
11
- rake (0.9.2.2)
12
- rdoc (3.12)
13
- json (~> 1.4)
10
+ active_support (3.0.0)
11
+ activesupport (= 3.0.0)
12
+ activesupport (3.0.0)
14
13
 
15
14
  PLATFORMS
16
15
  ruby
17
16
 
18
17
  DEPENDENCIES
19
- jeweler
18
+ cowtech-extensions!
data/Rakefile CHANGED
@@ -1,18 +1,7 @@
1
- require "rubygems"
2
- require "jeweler"
3
- require "./lib/cowtech-extensions/version.rb"
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the cowtech-extensions 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
+ #
4
6
 
5
- Jeweler::Tasks.new do |gem|
6
- gem.name = "cowtech-extensions"
7
- gem.homepage = "http://github.com/ShogunPanda/cowtech-extensions"
8
- gem.license = "MIT"
9
- gem.summary = %Q{Several Ruby object enhancements.}
10
- gem.description = %Q{Several Ruby object enhancements.}
11
- gem.email = "shogun_panda@me.com"
12
- gem.authors = ["Shogun"]
13
- gem.version = Cowtech::Extensions::Version::STRING
14
- gem.add_dependency "actionpack"
15
- gem.required_ruby_version = '>= 1.9.2'
16
- end
17
-
18
- Jeweler::RubygemsDotOrgTasks.new
7
+ require "bundler/gem_tasks"
@@ -1,56 +1,22 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = "cowtech-extensions"
8
- s.version = "1.4.1"
3
+ require "./lib/cowtech-extensions/version"
9
4
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Shogun"]
12
- s.date = "2012-04-16"
13
- s.description = "Several Ruby object enhancements."
14
- s.email = "shogun_panda@me.com"
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- "Gemfile",
20
- "Gemfile.lock",
21
- "README.rdoc",
22
- "Rakefile",
23
- "cowtech-extensions.gemspec",
24
- "lib/cowtech-extensions.rb",
25
- "lib/cowtech-extensions/boolean.rb",
26
- "lib/cowtech-extensions/datetime.rb",
27
- "lib/cowtech-extensions/hash.rb",
28
- "lib/cowtech-extensions/math.rb",
29
- "lib/cowtech-extensions/object.rb",
30
- "lib/cowtech-extensions/pathname.rb",
31
- "lib/cowtech-extensions/string.rb",
32
- "lib/cowtech-extensions/version.rb"
33
- ]
34
- s.homepage = "http://github.com/ShogunPanda/cowtech-extensions"
35
- s.licenses = ["MIT"]
36
- s.require_paths = ["lib"]
37
- s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
38
- s.rubygems_version = "1.8.15"
39
- s.summary = "Several Ruby object enhancements."
5
+ Gem::Specification.new do |s|
6
+ s.name = "cowtech-extensions"
7
+ s.version = Cowtech::Extensions::Version::STRING
8
+ s.authors = ["Shogun"]
9
+ s.email = ["shogun_panda@me.com"]
10
+ s.homepage = "http://github.com/ShogunPanda/cowtech-extensions"
11
+ s.summary = %q{A Rails blog engine plugin.}
12
+ s.description = %q{A Rails blog engine plugin.}
40
13
 
41
- if s.respond_to? :specification_version then
42
- s.specification_version = 3
14
+ s.rubyforge_project = "cowtech-extensions"
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
43
19
 
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<jeweler>, [">= 0"])
46
- s.add_runtime_dependency(%q<actionpack>, [">= 0"])
47
- else
48
- s.add_dependency(%q<jeweler>, [">= 0"])
49
- s.add_dependency(%q<actionpack>, [">= 0"])
50
- end
51
- else
52
- s.add_dependency(%q<jeweler>, [">= 0"])
53
- s.add_dependency(%q<actionpack>, [">= 0"])
54
- end
20
+ s.required_ruby_version = ">= 1.9.2"
21
+ s.add_dependency "active_support"
55
22
  end
56
-
@@ -9,14 +9,12 @@ module Cowtech
9
9
  module Boolean
10
10
  extend ActiveSupport::Concern
11
11
 
12
- module InstanceMethods
13
- def to_i
14
- (self == true) ? 1 : 0
15
- end
12
+ def to_i
13
+ (self == true) ? 1 : 0
14
+ end
16
15
 
17
- def value
18
- self
19
- end
16
+ def value
17
+ self
20
18
  end
21
19
  end
22
20
  end
@@ -94,39 +94,37 @@ module Cowtech
94
94
  end
95
95
  end
96
96
 
97
- module InstanceMethods
98
- def lstrftime(format = nil)
99
- format = self.class.custom_format($1) if format =~ /^custom::(.+)/
100
- format ||= self.class.custom_format("update")
101
- unlocal = self.strftime(format)
102
-
103
- { "%a" => "short_days", "%A" => "days", "%b" => "short_months", "%B" => "months" }.each_pair do |specifier, method|
104
- if format.include?(specifier) then
105
- from = self.class.send("default_localized_" + method)
106
- to = self.class.send("localized_" + method)
107
- unlocal.gsub!(/(#{from.join("|")})/i) { |s| to[from.index($1)] }
108
- end
97
+ def lstrftime(format = nil)
98
+ format = self.class.custom_format($1) if format =~ /^custom::(.+)/
99
+ format ||= self.class.custom_format("update")
100
+ unlocal = self.strftime(format)
101
+
102
+ { "%a" => "short_days", "%A" => "days", "%b" => "short_months", "%B" => "months" }.each_pair do |specifier, method|
103
+ if format.include?(specifier) then
104
+ from = self.class.send("default_localized_" + method)
105
+ to = self.class.send("localized_" + method)
106
+ unlocal.gsub!(/(#{from.join("|")})/i) { |s| to[from.index($1)] }
109
107
  end
110
-
111
- unlocal
112
108
  end
113
109
 
114
- def local_lstrftime(format = nil)
115
- (self.respond_to?(:in_time_zone) ? self.in_time_zone : self).lstrftime(format)
116
- end
110
+ unlocal
111
+ end
117
112
 
118
- def padded_month
119
- self.month.to_s.rjust(2, "0")
120
- end
113
+ def local_lstrftime(format = nil)
114
+ (self.respond_to?(:in_time_zone) ? self.in_time_zone : self).lstrftime(format)
115
+ end
121
116
 
122
- def in_months
123
- ((self.year - 1) % 2000) * 12 + self.month
124
- end
117
+ def padded_month
118
+ self.month.to_s.rjust(2, "0")
119
+ end
125
120
 
126
- def utc_time
127
- ua = (self.respond_to?(:utc) ? self : self.to_datetime).utc
128
- ::Time.utc(ua.year, ua.month, ua.day, ua.hour, ua.min, ua.sec)
129
- end
121
+ def in_months
122
+ ((self.year - 1) % 2000) * 12 + self.month
123
+ end
124
+
125
+ def utc_time
126
+ ua = (self.respond_to?(:utc) ? self : self.to_datetime).utc
127
+ ::Time.utc(ua.year, ua.month, ua.day, ua.hour, ua.min, ua.sec)
130
128
  end
131
129
  end
132
130
  end
@@ -9,14 +9,12 @@ module Cowtech
9
9
  module Hash
10
10
  extend ActiveSupport::Concern
11
11
 
12
- module InstanceMethods
13
- def method_missing(method, *args, &block)
14
- (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? (self[method.to_sym] || self[method.to_s]) : super(method, *args, &block)
15
- end
12
+ def method_missing(method, *args, &block)
13
+ (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? (self[method.to_sym] || self[method.to_s]) : super(method, *args, &block)
14
+ end
16
15
 
17
- def respond_to?(method)
18
- (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? true : super(method)
19
- end
16
+ def respond_to?(method)
17
+ (self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? true : super(method)
20
18
  end
21
19
  end
22
20
  end
@@ -13,67 +13,65 @@ module Cowtech
13
13
  include ActionView::Helpers::NumberHelper
14
14
  extend ActiveSupport::Concern
15
15
 
16
- module InstanceMethods
17
- def is_number?
18
- self.is_float?
19
- end
20
-
21
- def is_integer?
22
- self.is_a?(Integer) || /^([+-]?)(\d+)$/.match(self.ensure_string.strip)
23
- end
16
+ def is_number?
17
+ self.is_float?
18
+ end
24
19
 
25
- def is_float?
26
- self.is_a?(Float) || /^([+-]?)(\d+)([.,]\d+)?$/.match(self.ensure_string.strip)
27
- end
20
+ def is_integer?
21
+ self.is_a?(Integer) || /^([+-]?)(\d+)$/.match(self.ensure_string.strip)
22
+ end
28
23
 
29
- def is_boolean?
30
- self.is_a?(TrueClass) || self.is_a?(FalseClass) || self.is_a?(NilClass) || /^(1|0|true|false|yes|no|t|f|y|n)$/i.match(self.ensure_string.strip)
31
- end
24
+ def is_float?
25
+ self.is_a?(Float) || /^([+-]?)(\d+)([.,]\d+)?$/.match(self.ensure_string.strip)
26
+ end
32
27
 
33
- def ensure_array
34
- self.is_a?(Array) ? self : [self]
35
- end
28
+ def is_boolean?
29
+ self.is_a?(TrueClass) || self.is_a?(FalseClass) || self.is_a?(NilClass) || /^(1|0|true|false|yes|no|t|f|y|n)$/i.match(self.ensure_string.strip)
30
+ end
36
31
 
37
- def ensure_string
38
- self.present? ? self.to_s : ""
39
- end
32
+ def ensure_array
33
+ self.is_a?(Array) ? self : [self]
34
+ end
40
35
 
41
- def to_float
42
- self.is_float? ? Kernel.Float(self.respond_to?(:gsub) ? self.gsub(",", ".") : self) : 0.0
43
- end
36
+ def ensure_string
37
+ self.present? ? self.to_s : ""
38
+ end
44
39
 
45
- def to_integer
46
- self.is_integer? ? Kernel.Integer(self, self.is_a?(String) ? 10 : 0) : 0
47
- end
40
+ def to_float
41
+ self.is_float? ? Kernel.Float(self.respond_to?(:gsub) ? self.gsub(",", ".") : self) : 0.0
42
+ end
48
43
 
49
- def to_boolean
50
- (self.is_a?(TrueClass) || /^(1|on|true|yes|t|y)$/i.match(self.ensure_string.strip)) ? true : false
51
- end
44
+ def to_integer
45
+ self.is_integer? ? Kernel.Integer(self, self.is_a?(String) ? 10 : 0) : 0
46
+ end
52
47
 
53
- def round_to_precision(prec = 2)
54
- number_with_precision(self, precision: prec)
55
- end
48
+ def to_boolean
49
+ (self.is_a?(TrueClass) || /^(1|on|true|yes|t|y)$/i.match(self.ensure_string.strip)) ? true : false
50
+ end
56
51
 
57
- def format_number(prec = 2, decimal_separator = ",", add_string = "€", k_separator = ".")
58
- number_to_currency(self, {precision: prec, separator: decimal_separator, delimiter: k_separator, format: add_string.blank? ? "%n" : "%n %u", unit: add_string.blank? ? "" : add_string.strip})
59
- end
52
+ def round_to_precision(prec = 2)
53
+ number_with_precision(self, precision: prec)
54
+ end
60
55
 
61
- def format_boolean
62
- self.to_boolean ? "Yes" : "No"
63
- end
56
+ def format_number(prec = 2, decimal_separator = ",", add_string = "€", k_separator = ".")
57
+ number_to_currency(self, {precision: prec, separator: decimal_separator, delimiter: k_separator, format: add_string.blank? ? "%n" : "%n %u", unit: add_string.blank? ? "" : add_string.strip})
58
+ end
64
59
 
65
- def debug_dump(format = :yaml, must_raise = true)
66
- rv = ""
60
+ def format_boolean
61
+ self.to_boolean ? "Yes" : "No"
62
+ end
67
63
 
68
- begin
69
- rv = self.send("to_#{format}")
70
- rescue
71
- rv = self.inspect
72
- end
64
+ def debug_dump(format = :yaml, must_raise = true)
65
+ rv = ""
73
66
 
74
- rv = "DEBUG DUMP:\n#{rv}"
75
- must_raise ? raise(rv) : rv
67
+ begin
68
+ rv = self.send("to_#{format}")
69
+ rescue
70
+ rv = self.inspect
76
71
  end
72
+
73
+ rv = "DEBUG DUMP:\n#{rv}"
74
+ must_raise ? raise(rv) : rv
77
75
  end
78
76
  end
79
77
  end
@@ -9,10 +9,8 @@ module Cowtech
9
9
  module Pathname
10
10
  extend ActiveSupport::Concern
11
11
 
12
- module InstanceMethods
13
- def components
14
- self.each_filename.collect { |p| p }
15
- end
12
+ def components
13
+ self.each_filename.collect { |p| p }
16
14
  end
17
15
  end
18
16
  end
@@ -11,22 +11,20 @@ module Cowtech
11
11
  module String
12
12
  extend ActiveSupport::Concern
13
13
 
14
- module InstanceMethods
15
- def remove_accents
16
- self.mb_chars.normalize(:kd).gsub(/[^\-x00-\x7F]/n, "").to_s
17
- end
14
+ def remove_accents
15
+ self.mb_chars.normalize(:kd).gsub(/[^\-x00-\x7F]/n, "").to_s
16
+ end
18
17
 
19
- def untitleize
20
- self.downcase.gsub(" ", "-")
21
- end
18
+ def untitleize
19
+ self.downcase.gsub(" ", "-")
20
+ end
22
21
 
23
- def replace_ampersands
24
- self.gsub(/&amp;(\S+);/, "&\\1;")
25
- end
22
+ def replace_ampersands
23
+ self.gsub(/&amp;(\S+);/, "&\\1;")
24
+ end
26
25
 
27
- def value
28
- self
29
- end
26
+ def value
27
+ self
30
28
  end
31
29
  end
32
30
  end
@@ -11,7 +11,7 @@ module Cowtech
11
11
  module Version
12
12
  MAJOR = 1
13
13
  MINOR = 4
14
- PATCH = 1
14
+ PATCH = 2
15
15
 
16
16
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cowtech-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
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: 2012-04-16 00:00:00.000000000Z
12
+ date: 2012-04-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: jeweler
16
- requirement: &70233329303800 !ruby/object:Gem::Requirement
15
+ name: active_support
16
+ requirement: &70323887130940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,25 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70233329303800
25
- - !ruby/object:Gem::Dependency
26
- name: actionpack
27
- requirement: &70233329302880 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
33
- type: :runtime
34
- prerelease: false
35
- version_requirements: *70233329302880
36
- description: Several Ruby object enhancements.
37
- email: shogun_panda@me.com
24
+ version_requirements: *70323887130940
25
+ description: A Rails blog engine plugin.
26
+ email:
27
+ - shogun_panda@me.com
38
28
  executables: []
39
29
  extensions: []
40
- extra_rdoc_files:
41
- - README.rdoc
30
+ extra_rdoc_files: []
42
31
  files:
32
+ - .gitignore
43
33
  - Gemfile
44
34
  - Gemfile.lock
45
35
  - README.rdoc
@@ -55,8 +45,7 @@ files:
55
45
  - lib/cowtech-extensions/string.rb
56
46
  - lib/cowtech-extensions/version.rb
57
47
  homepage: http://github.com/ShogunPanda/cowtech-extensions
58
- licenses:
59
- - MIT
48
+ licenses: []
60
49
  post_install_message:
61
50
  rdoc_options: []
62
51
  require_paths:
@@ -74,9 +63,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
63
  - !ruby/object:Gem::Version
75
64
  version: '0'
76
65
  requirements: []
77
- rubyforge_project:
66
+ rubyforge_project: cowtech-extensions
78
67
  rubygems_version: 1.8.15
79
68
  signing_key:
80
69
  specification_version: 3
81
- summary: Several Ruby object enhancements.
70
+ summary: A Rails blog engine plugin.
82
71
  test_files: []