active_object 4.0.14 → 5.0.1

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.
@@ -1,121 +1,125 @@
1
- module ActiveObject::Time
2
- MINUTE ||= 60.0
3
- HOUR ||= MINUTE * 60.0
4
- DAY ||= HOUR * 24.0
5
- WEEK ||= DAY * 7.0
6
- YEAR ||= DAY * 365.25
7
- DECADE ||= YEAR * 10.0
8
- CENTURY ||= DECADE * 10.0
9
- MILLENNIUM ||= CENTURY * 10.0
10
-
11
- KEY_UNITS ||= {
12
- month: '%m', month_padded: '%m', month_unpadded: '%-m', month_blank: '%_m', month_name: '%B',
13
- month_name_abbr: '%b', month_year: '%m %Y', month_padded_year: '%m %Y',
14
- month_unpadded_year: '%-m %Y', month_blank_year: '%_m %Y', month_name_year: '%B %Y',
15
- month_name_abbr_year: '%b %Y', weekday: '%d', weekday_padded: '%d', weekday_unpadded: '%-d',
16
- weekday_blank: '%_d', weekday_name: '%A', weekday_name_abbr: '%a', yr: '%y', year_abbr: '%y',
17
- year: '%Y', hour: '%H', hour_padded: '%H', hour_blank: '%k', hour_imperical: '%I',
18
- hour_imperical_padded: '%I', hour_imperical_blank: '%l', ampm: '%P', meridian: '%P',
19
- minute: '%M', second: '%S', time_zone: '%z', time_zone_offset: '%:z', time_padded: '%H:%M',
20
- time_zone_offset_full: '%::z', time_zone_name: '%Z', date: '%B %-d, %Y', time_tzn: '%H:%M %Z',
21
- date_abbr: '%b %-d, %Y', date_iso: '%Y-%m-%d', datetime: '%B %-d, %Y %H:%M', time: '%H:%M',
22
- datetime_abbr: '%b %-d, %Y %H:%M', datetime_iso: '%Y-%m-%d %H:%M', time_imperical: '%I:%M %P',
23
- datetime_imperical: '%B %-d, %Y %I:%M %P', datetime_imperical_abbr: '%b %-d, %Y %I:%M %P',
24
- datetime_imperical_iso: '%Y-%m-%d %I:%M %P', datetime_tzn: '%B %-d, %Y %H:%M %Z',
25
- datetime_abbr_tzn: '%b %-d, %Y %H:%M %Z', datetime_iso_tzn: '%Y-%m-%d %H:%M %z',
26
- datetime_imperical_tzn: '%B %-d, %Y %I:%M %P %Z', day: '%B %-d', day_abbr: '%b %-d',
27
- datetime_imperical_abbr_tzn: '%b %-d, %Y %I:%M %P %Z', time_tz: '%H:%M %z', time_blank: '%k:%M',
28
- datetime_imperical_iso_tzn: '%Y-%m-%d %I:%M %P %z', day_iso: '%m-%d', daytime: '%B %-d %H:%M',
29
- daytime_abbr: '%b %-d %H:%M', daytime_iso: '%m-%d %H:%M', daytime_imperical: '%B %-d %I:%M %P',
30
- daytime_imperical_abbr: '%b %-d %I:%M %P', daytime_imperical_iso: '%m-%d %I:%M %P',
31
- time_imperical_padded: '%I:%M %P', time_imperical_blank: '%l:%M %P',
32
- time_imperical_tz: '%I:%M %P %z', time_imperical_tzn: '%I:%M %P %Z', sunday_week: '%U',
33
- monday_week: '%W', week_iso: '%V', week_year_iso: '%V-%G'
34
- }.freeze
35
- STRING_UNITS ||= {
36
- d: 'd', day: 'd', day_padded: 'd', dd: '-d', Day: '-d', day_unpadded: '-d', ddd: '_d', zz: ':z',
37
- DAY: '_d', day_blank: '_d', dddd: 'j', day_of_the_year: 'j', m: 'm', month: 'm', hhhh: 'l',
38
- month_padded: 'm', mm: '-m', Month: '-m', month_unpadded: '-m', mmm: '_m', MONTH: '_m',
39
- month_blank: '_m', mmmm: 'B', month_name: 'B', mmmmm: 'b', month_name_abbr: 'b', w: 'u', z: 'z',
40
- weekday: 'u', ww: 'w', weekday_offset: 'w', www: 'A', weekday_name: 'A', wwww: 'a', yyyy: 'Y',
41
- weekday_name_abbr: 'a', yy: 'y', yr: 'y', year: 'Y', h: 'H', hour: 'H', hour_padded: 'H',
42
- hh: 'k', HOUR: 'k', hour_blank: 'k', hhh: 'I', hour_imperical: 'I', hour_imperical_padded: 'I',
43
- HOUR_IMPERICAL: 'l', hour_imperical_blank: 'l', ampm: 'P', meridian: 'P', AMPM: 'p',
44
- MERIDIAN: 'p', n: 'M', minute: 'M', s: 'S', second: 'S', time_zone: 'z', time_zone_offset: ':z',
45
- zzz: '::z', time_zone_offset_full: '::z', zzzz: 'Z', time_zone_name: 'Z', swe: 'U',
46
- sunday_week: 'U', mwe: 'W', monday_week: 'W', we: 'V', week: 'V'
47
- }.freeze
48
-
49
- def count_centuries_since(time)
50
- count_seconds_since(time) / CENTURY
51
- end
52
-
53
- alias_method :count_centuries_until, :count_centuries_since
54
-
55
- def count_days_since(time)
56
- count_seconds_since(time) / DAY
57
- end
58
-
59
- alias_method :count_days_until, :count_days_since
60
-
61
- def count_decades_since(time)
62
- count_seconds_since(time) / DECADE
63
- end
64
-
65
- alias_method :count_decades_until, :count_decades_since
66
-
67
- def count_hours_since(time)
68
- count_seconds_since(time) / HOUR
69
- end
70
-
71
- alias_method :count_hours_until, :count_hours_since
72
-
73
- def count_milleniums_since(time)
74
- count_seconds_since(time) / MILLENNIUM
75
- end
76
-
77
- alias_method :count_milleniums_until, :count_milleniums_since
78
-
79
- def count_minutes_since(time)
80
- count_seconds_since(time) / MINUTE
81
- end
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveObject
4
+ module Time
5
+ MINUTE ||= 60.0
6
+ HOUR ||= MINUTE * 60.0
7
+ DAY ||= HOUR * 24.0
8
+ WEEK ||= DAY * 7.0
9
+ YEAR ||= DAY * 365.25
10
+ DECADE ||= YEAR * 10.0
11
+ CENTURY ||= DECADE * 10.0
12
+ MILLENNIUM ||= CENTURY * 10.0
13
+
14
+ KEY_UNITS ||= {
15
+ month: '%m', month_padded: '%m', month_unpadded: '%-m', month_blank: '%_m', month_name: '%B',
16
+ month_name_abbr: '%b', month_year: '%m %Y', month_padded_year: '%m %Y',
17
+ month_unpadded_year: '%-m %Y', month_blank_year: '%_m %Y', month_name_year: '%B %Y',
18
+ month_name_abbr_year: '%b %Y', weekday: '%d', weekday_padded: '%d', weekday_unpadded: '%-d',
19
+ weekday_blank: '%_d', weekday_name: '%A', weekday_name_abbr: '%a', yr: '%y', year_abbr: '%y',
20
+ year: '%Y', hour: '%H', hour_padded: '%H', hour_blank: '%k', hour_imperical: '%I',
21
+ hour_imperical_padded: '%I', hour_imperical_blank: '%l', ampm: '%P', meridian: '%P',
22
+ minute: '%M', second: '%S', time_zone: '%z', time_zone_offset: '%:z', time_padded: '%H:%M',
23
+ time_zone_offset_full: '%::z', time_zone_name: '%Z', date: '%B %-d, %Y', time_tzn: '%H:%M %Z',
24
+ date_abbr: '%b %-d, %Y', date_iso: '%Y-%m-%d', datetime: '%B %-d, %Y %H:%M', time: '%H:%M',
25
+ datetime_abbr: '%b %-d, %Y %H:%M', datetime_iso: '%Y-%m-%d %H:%M', time_imperical: '%I:%M %P',
26
+ datetime_imperical: '%B %-d, %Y %I:%M %P', datetime_imperical_abbr: '%b %-d, %Y %I:%M %P',
27
+ datetime_imperical_iso: '%Y-%m-%d %I:%M %P', datetime_tzn: '%B %-d, %Y %H:%M %Z',
28
+ datetime_abbr_tzn: '%b %-d, %Y %H:%M %Z', datetime_iso_tzn: '%Y-%m-%d %H:%M %z',
29
+ datetime_imperical_tzn: '%B %-d, %Y %I:%M %P %Z', day: '%B %-d', day_abbr: '%b %-d',
30
+ datetime_imperical_abbr_tzn: '%b %-d, %Y %I:%M %P %Z', time_tz: '%H:%M %z', time_blank: '%k:%M',
31
+ datetime_imperical_iso_tzn: '%Y-%m-%d %I:%M %P %z', day_iso: '%m-%d', daytime: '%B %-d %H:%M',
32
+ daytime_abbr: '%b %-d %H:%M', daytime_iso: '%m-%d %H:%M', daytime_imperical: '%B %-d %I:%M %P',
33
+ daytime_imperical_abbr: '%b %-d %I:%M %P', daytime_imperical_iso: '%m-%d %I:%M %P',
34
+ time_imperical_padded: '%I:%M %P', time_imperical_blank: '%l:%M %P',
35
+ time_imperical_tz: '%I:%M %P %z', time_imperical_tzn: '%I:%M %P %Z', sunday_week: '%U',
36
+ monday_week: '%W', week_iso: '%V', week_year_iso: '%V-%G'
37
+ }.freeze
38
+ STRING_UNITS ||= {
39
+ d: 'd', day: 'd', day_padded: 'd', dd: '-d', Day: '-d', day_unpadded: '-d', ddd: '_d', zz: ':z',
40
+ DAY: '_d', day_blank: '_d', dddd: 'j', day_of_the_year: 'j', m: 'm', month: 'm', hhhh: 'l',
41
+ month_padded: 'm', mm: '-m', Month: '-m', month_unpadded: '-m', mmm: '_m', MONTH: '_m',
42
+ month_blank: '_m', mmmm: 'B', month_name: 'B', mmmmm: 'b', month_name_abbr: 'b', w: 'u', z: 'z',
43
+ weekday: 'u', ww: 'w', weekday_offset: 'w', www: 'A', weekday_name: 'A', wwww: 'a', yyyy: 'Y',
44
+ weekday_name_abbr: 'a', yy: 'y', yr: 'y', year: 'Y', h: 'H', hour: 'H', hour_padded: 'H',
45
+ hh: 'k', HOUR: 'k', hour_blank: 'k', hhh: 'I', hour_imperical: 'I', hour_imperical_padded: 'I',
46
+ HOUR_IMPERICAL: 'l', hour_imperical_blank: 'l', ampm: 'P', meridian: 'P', AMPM: 'p',
47
+ MERIDIAN: 'p', n: 'M', minute: 'M', s: 'S', second: 'S', time_zone: 'z', time_zone_offset: ':z',
48
+ zzz: '::z', time_zone_offset_full: '::z', zzzz: 'Z', time_zone_name: 'Z', swe: 'U',
49
+ sunday_week: 'U', mwe: 'W', monday_week: 'W', we: 'V', week: 'V'
50
+ }.freeze
51
+
52
+ def count_centuries_since(time)
53
+ count_seconds_since(time) / CENTURY
54
+ end
55
+
56
+ alias_method :count_centuries_until, :count_centuries_since
57
+
58
+ def count_days_since(time)
59
+ count_seconds_since(time) / DAY
60
+ end
61
+
62
+ alias_method :count_days_until, :count_days_since
63
+
64
+ def count_decades_since(time)
65
+ count_seconds_since(time) / DECADE
66
+ end
67
+
68
+ alias_method :count_decades_until, :count_decades_since
69
+
70
+ def count_hours_since(time)
71
+ count_seconds_since(time) / HOUR
72
+ end
73
+
74
+ alias_method :count_hours_until, :count_hours_since
75
+
76
+ def count_milleniums_since(time)
77
+ count_seconds_since(time) / MILLENNIUM
78
+ end
79
+
80
+ alias_method :count_milleniums_until, :count_milleniums_since
81
+
82
+ def count_minutes_since(time)
83
+ count_seconds_since(time) / MINUTE
84
+ end
85
+
86
+ alias_method :count_minutes_until, :count_minutes_since
87
+
88
+ def count_seconds_since(time)
89
+ time = time.to_time if time.respond_to?(:to_time)
90
+ (to_f - time.to_f).abs
91
+ end
92
+
93
+ alias_method :count_seconds_until, :count_seconds_since
94
+
95
+ def count_weeks_since(time)
96
+ count_seconds_since(time) / WEEK
97
+ end
98
+
99
+ alias_method :count_weeks_until, :count_weeks_since
100
+
101
+ def count_years_since(time)
102
+ count_seconds_since(time) / YEAR
103
+ end
104
+
105
+ alias_method :count_years_until, :count_years_since
106
+
107
+ def format(string)
108
+ delimiters = string.scan(/\W+/)
109
+ formatters = string.scan(/[a-z0-9_]+/i)
110
+
111
+ string = formatters.map { |unit| "%#{STRING_UNITS.fetch(unit.to_sym)}#{delimiters.shift}" }
112
+
113
+ strftime(string.join)
114
+ end
115
+
116
+ def to_format(key = :datetime_iso)
117
+ strftime(KEY_UNITS.fetch(key.to_sym))
118
+ end
119
+
120
+ alias_method :stamp, :to_format
82
121
 
83
- alias_method :count_minutes_until, :count_minutes_since
84
-
85
- def count_seconds_since(time)
86
- time = time.to_time if time.respond_to?(:to_time)
87
- (to_f - time.to_f).abs
88
- end
89
-
90
- alias_method :count_seconds_until, :count_seconds_since
91
-
92
- def count_weeks_since(time)
93
- count_seconds_since(time) / WEEK
94
- end
95
-
96
- alias_method :count_weeks_until, :count_weeks_since
97
-
98
- def count_years_since(time)
99
- count_seconds_since(time) / YEAR
100
- end
101
-
102
- alias_method :count_years_until, :count_years_since
103
-
104
- def format(string)
105
- delimiters = string.scan(/\W+/)
106
- formatters = string.scan(/[a-z0-9_]+/i)
107
-
108
- string = formatters.map { |unit| "%#{STRING_UNITS.fetch(unit.to_sym)}#{delimiters.shift}" }
109
-
110
- strftime(string.join)
111
122
  end
112
-
113
- def to_format(key = :datetime_iso)
114
- strftime(KEY_UNITS.fetch(key.to_sym))
115
- end
116
-
117
- alias_method :stamp, :to_format
118
-
119
123
  end
120
124
 
121
- Time.include(ActiveObject::Time) if ActiveObject::Settings.config.autoload_time
125
+ Time.include(ActiveObject::Time) if ActiveObject.configuration.autoload_time
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveObject
2
- VERSION = '4.0.14'.freeze
4
+ VERSION ||= '5.0.1'
3
5
  end
data/lib/active_object.rb CHANGED
@@ -1,4 +1,6 @@
1
- %w[version settings array date enumerable hash integer numeric object range string time]
1
+ # frozen_string_literal: true
2
+
3
+ %w[version configuration array date enumerable hash integer numeric object range string time]
2
4
  .each do |file_name|
3
5
  require "active_object/#{file_name}"
4
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails/generators'
2
4
 
3
5
  class ActiveObject::InstallGenerator < Rails::Generators::Base
@@ -1,4 +1,6 @@
1
- ActiveObject::Settings.configure do |config|
1
+ # frozen_string_literal: true
2
+
3
+ ActiveObject.configure do |config|
2
4
  config.autoload_array = true
3
5
  config.autoload_date = true
4
6
  config.autoload_enumerable = true
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.14
4
+ version: 5.0.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: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: dry-configurable
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +24,6 @@ dependencies:
38
24
  - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: coveralls
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: rake
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -144,7 +116,6 @@ extensions: []
144
116
  extra_rdoc_files: []
145
117
  files:
146
118
  - ".DS_Store"
147
- - ".coveralls.yml"
148
119
  - ".fasterer.yml"
149
120
  - ".gitignore"
150
121
  - ".reek"
@@ -164,6 +135,7 @@ files:
164
135
  - lib/active_object.rb
165
136
  - lib/active_object/.DS_Store
166
137
  - lib/active_object/array.rb
138
+ - lib/active_object/configuration.rb
167
139
  - lib/active_object/date.rb
168
140
  - lib/active_object/enumerable.rb
169
141
  - lib/active_object/hash.rb
@@ -171,7 +143,6 @@ files:
171
143
  - lib/active_object/numeric.rb
172
144
  - lib/active_object/object.rb
173
145
  - lib/active_object/range.rb
174
- - lib/active_object/settings.rb
175
146
  - lib/active_object/string.rb
176
147
  - lib/active_object/time.rb
177
148
  - lib/active_object/version.rb
@@ -197,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
168
  version: '0'
198
169
  requirements: []
199
170
  rubyforge_project:
200
- rubygems_version: 2.6.12
171
+ rubygems_version: 2.6.13
201
172
  signing_key:
202
173
  specification_version: 4
203
174
  summary: Gem for commonly used ruby object helpers.
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
@@ -1,17 +0,0 @@
1
- require 'dry-configurable'
2
-
3
- class ActiveObject::Settings
4
- extend Dry::Configurable
5
-
6
- setting :autoload_array, true
7
- setting :autoload_date, true
8
- setting :autoload_enumerable, true
9
- setting :autoload_hash, true
10
- setting :autoload_integer, true
11
- setting :autoload_numeric, true
12
- setting :autoload_object, true
13
- setting :autoload_range, true
14
- setting :autoload_string, true
15
- setting :autoload_time, true
16
-
17
- end