active_object 2.3.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2328a0445ce30462a324b76b837c44b0a1acc3b8
4
- data.tar.gz: 0829cad78f360aa10b7138f4f33b04cbd3ace852
3
+ metadata.gz: 62f60060b5fe65de31fdf1458f844ca30449f238
4
+ data.tar.gz: b250d0f529558f2a8f3587f64c45518b8c4dac50
5
5
  SHA512:
6
- metadata.gz: 59a21514f21c8b8be2a495c6651bdf95669e176bd386065124e08b3b51defa1960094f4882352c9d7cffb52c76a942c1982d61fe57d757687950469775a5fc82
7
- data.tar.gz: b651f4a4d3a201f348afce2aa6609a2689b7807260eeda22a110865efe161092a134f705935cf1fcb0b84658380d06caed818f42b7b9795cfcac801b22a47b19
6
+ metadata.gz: b5d9eb11fa150a505a773b33908c15588fe6edf34ad6840c1e109a086e5fa89b52a20a3adcdf66a266d1902879dc1b2064eaac196ff450fb925c2075b299bf00
7
+ data.tar.gz: 97cfea106f651c78915959675a1b61a845e9073b0fe4ea4f661ab1ad90360f421277133fce5b0118460348c676ce14ab4d90c3f78d701a56c640b22a9526bfa8
data/README.md CHANGED
@@ -1767,6 +1767,11 @@ Time.now.stamp(:datetime) #=> "January 09, 2014 02:31 pm"
1767
1767
  | Month - digits blank-padded | `:month_blank` | %a | ( 1..12) |
1768
1768
  | Month - name | `:month_name` | %A | January |
1769
1769
  | Month - name abbreviated | `:month_name_abbr` | %a | Jan |
1770
+ | Month - digits zero-padded | `:month_year` or `:month_padded_year` | %A | (01..12) 2015 |
1771
+ | Month - digits unpadded | `:month_unpadded_year` | %a | (1..12) 2015 |
1772
+ | Month - digits blank-padded | `:month_blank_year` | %a | ( 1..12) 2015 |
1773
+ | Month - name | `:month_name_year` | %A | January 2015 |
1774
+ | Month - name abbreviated | `:month_name_abbr_year` | %a | Jan 2015 |
1770
1775
  | Weekday - digits zero-padded | `:weekday_padded` | %A | (01..31) |
1771
1776
  | Weekday - digits unpadded | `:weekday_unpadded` | %a | (1..31) |
1772
1777
  | Weekday - digits blank-padded | `:weekday_blank` | %a | ( 1..31) |
@@ -3,13 +3,13 @@ class Array
3
3
  def after(value)
4
4
  return(nil) unless include?(value)
5
5
 
6
- self[(index(value).to_i + 1) % size]
6
+ self[(index(value).to_i + 1) % length]
7
7
  end
8
8
 
9
9
  def before(value)
10
10
  return(nil) unless include?(value)
11
11
 
12
- self[(index(value).to_i - 1) % size]
12
+ self[(index(value).to_i - 1) % length]
13
13
  end
14
14
 
15
15
  def delete_first
@@ -43,23 +43,23 @@ class Array
43
43
 
44
44
  unless defined?(Rails)
45
45
  def from(position)
46
- self[position, size] || []
46
+ self[position, length] || []
47
47
  end
48
48
  end
49
49
 
50
50
  def groups(number)
51
51
  return([]) if number <= 0
52
52
 
53
- n, r = size.divmod(number)
53
+ n, r = length.divmod(number)
54
54
  collection = (0..(n - 1)).collect { |i| self[(i * number), number] }
55
55
  r > 0 ? collection << self[-r, r] : collection
56
56
  end
57
57
 
58
58
  unless defined?(Rails)
59
59
  def in_groups(number, fill_with=nil)
60
- collection_size = size
61
- division = collection_size.div(number)
62
- modulo = collection_size % number
60
+ collection_length = length
61
+ division = collection_length.div(number)
62
+ modulo = collection_length % number
63
63
 
64
64
  collection = []
65
65
  start = 0
@@ -78,13 +78,13 @@ class Array
78
78
  def in_groups_of(number, fill_with=nil)
79
79
  if number.to_i <= 0
80
80
  raise ArgumentError,
81
- "Group size must be a positive integer, was #{number.inspect}"
81
+ "Group length must be a positive integer, was #{number.inspect}"
82
82
  end
83
83
 
84
84
  if fill_with == false
85
85
  collection = self
86
86
  else
87
- padding = (number - size % number) % number
87
+ padding = (number - length % number) % number
88
88
  collection = dup.concat(Array.new(padding, fill_with))
89
89
  end
90
90
 
@@ -110,7 +110,7 @@ class Array
110
110
  end
111
111
 
112
112
  def sample!
113
- delete_at(Random.rand(size - 1))
113
+ delete_at(Random.rand(length - 1))
114
114
  end
115
115
 
116
116
  unless defined?(Rails)
@@ -128,7 +128,7 @@ class Array
128
128
  arr.shift
129
129
  results << []
130
130
  else
131
- results.last.concat(arr.shift(arr.size))
131
+ results.last.concat(arr.shift(arr.length))
132
132
  end
133
133
  end
134
134
  results
@@ -161,7 +161,7 @@ class Array
161
161
  }
162
162
  options = default_connectors.merge!(options)
163
163
 
164
- case size
164
+ case length
165
165
  when 0
166
166
  ''
167
167
  when 1
@@ -62,6 +62,12 @@ class Date
62
62
  month_blank: '%_m',
63
63
  month_name: '%B',
64
64
  month_name_abbr: '%b',
65
+ month_year: '%m %y',
66
+ month_padded_year: '%m %y',
67
+ month_unpadded_year: '%-m %y',
68
+ month_blank_year: '%_m %y',
69
+ month_name_year: '%B %y',
70
+ month_name_abbr_year: '%b %y',
65
71
  weekday: '%d',
66
72
  weekday_padded: '%d',
67
73
  weekday_unpadded: '%-d',
@@ -31,11 +31,11 @@ module Enumerable
31
31
  end
32
32
 
33
33
  def drop_last(n)
34
- collection_size = to_a.size
34
+ collection_length = to_a.length
35
35
 
36
- return(self) if n > collection_size
36
+ return(self) if n > collection_length
37
37
 
38
- self[0...(collection_size - n)]
38
+ self[0...(collection_length - n)]
39
39
  end
40
40
 
41
41
  def drop_last_if
@@ -96,40 +96,40 @@ module Enumerable
96
96
  end
97
97
 
98
98
  def max(identity=0)
99
- size > 0 ? sort.last : identity
99
+ self.length > 0 ? sort.last : identity
100
100
  end
101
101
 
102
102
  def min(identity=0)
103
- size > 0 ? sort.first : identity
103
+ self.length > 0 ? sort.first : identity
104
104
  end
105
105
 
106
106
  def mean(identity=0)
107
- return(identity) unless size > 0
107
+ return(identity) unless length > 0
108
108
 
109
- collection_size = size
110
- sum.to_f / collection_size.to_f
109
+ collection_length = length
110
+ sum.to_f / collection_length.to_f
111
111
  end
112
112
 
113
113
  def median(identity=0)
114
- collection_size = size.to_f
114
+ collection_length = length.to_f
115
115
  collection_sorted = sort
116
116
 
117
- return(identity) unless collection_size > 0
117
+ return(identity) unless collection_length > 0
118
118
 
119
- if (collection_size % 2).zero?
120
- (collection_sorted[(collection_size / 2.0) -1.0] + collection_sorted[collection_size / 2.0]) / 2.0
119
+ if (collection_length % 2).zero?
120
+ (collection_sorted[(collection_length / 2.0) -1.0] + collection_sorted[collection_length / 2.0]) / 2.0
121
121
  else
122
- collection_sorted[collection_size / 2.0]
122
+ collection_sorted[collection_length / 2.0]
123
123
  end
124
124
  end
125
125
 
126
126
  def mode(identity=0)
127
- return(identity) unless size > 0
127
+ return(identity) unless length > 0
128
128
 
129
129
  frequency_distribution = inject(Hash.new(0)) { |h, v| h[v] += 1; h }
130
130
  frequency_top_two = frequency_distribution.sort { |k, v| v[1] <=> k[1] }.take(2)
131
131
 
132
- if frequency_top_two.size == 1
132
+ if frequency_top_two.length == 1
133
133
  frequency_top_two.first.first
134
134
  elsif frequency_top_two.first.last == frequency_top_two.last.last
135
135
  nil
@@ -147,7 +147,7 @@ module Enumerable
147
147
  end
148
148
 
149
149
  def range(identity=0)
150
- return(identity) unless size > 0
150
+ return(identity) unless length > 0
151
151
 
152
152
  collection_sorted = sort
153
153
  collection_sorted.last - collection_sorted.first
@@ -160,7 +160,7 @@ module Enumerable
160
160
  end
161
161
 
162
162
  def standard_deviation(identity=0)
163
- return(identity) if size < 2
163
+ return(identity) if length < 2
164
164
 
165
165
  Math.sqrt(variance)
166
166
  end
@@ -176,11 +176,11 @@ module Enumerable
176
176
  end
177
177
 
178
178
  def take_last(n)
179
- collection_size = to_a.size
179
+ collection_length = to_a.length
180
180
 
181
- return(self) if n > collection_size
181
+ return(self) if n > collection_length
182
182
 
183
- self[(collection_size - n)..-1]
183
+ self[(collection_length - n)..-1]
184
184
  end
185
185
 
186
186
  def take_last_if
@@ -192,12 +192,12 @@ module Enumerable
192
192
  end
193
193
 
194
194
  def variance(identity=0)
195
- collection_size = size
195
+ collection_length = length
196
196
 
197
- return(identity) if collection_size <= 1
197
+ return(identity) if collection_length <= 1
198
198
 
199
199
  sum = inject(0.0) { |s,v| s + (v - mean) ** 2.0 }
200
- sum.to_f / (collection_size.to_f - 1.0)
200
+ sum.to_f / (collection_length.to_f - 1.0)
201
201
  end
202
202
 
203
203
  end
@@ -108,7 +108,7 @@ class Hash
108
108
 
109
109
  def sample_key
110
110
  hash_keys = keys
111
- hash_keys.at(Random.rand(hash_keys.size - 1))
111
+ hash_keys.at(Random.rand(hash_keys.length - 1))
112
112
  end
113
113
 
114
114
  def sample_key!
@@ -128,7 +128,7 @@ class Hash
128
128
  end
129
129
 
130
130
  def shuffle
131
- Hash[to_a.sample(size)]
131
+ Hash[to_a.sample(length)]
132
132
  end
133
133
 
134
134
  def shuffle!
@@ -308,9 +308,9 @@ class Numeric
308
308
  string = to_s
309
309
 
310
310
  string << separator unless string.include?(separator)
311
- ljust_count = string.split(separator).first.size
311
+ ljust_count = string.split(separator).first.length
312
312
  ljust_count += (string.count(separator) + precision) if precision > 0
313
- num_count = string.size
313
+ num_count = string.length
314
314
  ljust_count >= num_count ? string.ljust(ljust_count, pad_number.to_s) : string[0..(ljust_count - 1)]
315
315
  end
316
316
 
@@ -464,7 +464,7 @@ class Numeric
464
464
  end
465
465
 
466
466
  def to_nearest_value(values=[])
467
- return(self) if values.size.zero?
467
+ return(self) if values.length.zero?
468
468
 
469
469
  value = values.first
470
470
  difference = (self - value).abs
@@ -100,7 +100,7 @@ class String
100
100
  end
101
101
 
102
102
  def ellipsize(ellipsize_at, options={})
103
- return(self)if size <= ellipsize_at
103
+ return(self)if length <= ellipsize_at
104
104
 
105
105
  separator = options.fetch(:separator, '...'.freeze)
106
106
  offset = options.fetch(:offset, 4)
@@ -118,7 +118,7 @@ class String
118
118
  def first(limit=1)
119
119
  return(''.freeze) if limit.zero?
120
120
 
121
- limit >= size ? self.dup : to(limit - 1)
121
+ limit >= length ? self.dup : to(limit - 1)
122
122
  end
123
123
  end
124
124
 
@@ -163,7 +163,7 @@ class String
163
163
  def last(limit=1)
164
164
  return(''.freeze) if limit.zero?
165
165
 
166
- limit >= size ? self.dup : from(-limit)
166
+ limit >= length ? self.dup : from(-limit)
167
167
  end
168
168
  end
169
169
 
@@ -305,10 +305,10 @@ class String
305
305
 
306
306
  unless defined?(Rails)
307
307
  def truncate(truncate_at, options={})
308
- return(dup) unless size > truncate_at
308
+ return(dup) unless length > truncate_at
309
309
 
310
310
  omission = options.fetch(:omission, '...'.freeze)
311
- size_with_room_for_omission = truncate_at - omission.size
311
+ size_with_room_for_omission = truncate_at - omission.length
312
312
 
313
313
  stop = if options.fetch(:separator, false)
314
314
  rindex(options.fetch(:separator, ''.freeze), size_with_room_for_omission) || size_with_room_for_omission
@@ -86,6 +86,12 @@ class Time
86
86
  month_blank: '%_m',
87
87
  month_name: '%B',
88
88
  month_name_abbr: '%b',
89
+ month_year: '%m %y',
90
+ month_padded_year: '%m %y',
91
+ month_unpadded_year: '%-m %y',
92
+ month_blank_year: '%_m %y',
93
+ month_name_year: '%B %y',
94
+ month_name_abbr_year: '%b %y',
89
95
  weekday: '%d',
90
96
  weekday_padded: '%d',
91
97
  weekday_unpadded: '%-d',
@@ -1,3 +1,3 @@
1
1
  module ActiveObject
2
- VERSION = "2.3.0"
2
+ VERSION = "2.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-17 00:00:00.000000000 Z
11
+ date: 2015-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.8
121
+ rubygems_version: 2.5.0
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Gem for commonly used ruby object helpers.