active_object 3.1.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
1
  module ActiveObject::Time
2
-
3
2
  MINUTE = 60.0
4
3
  HOUR = MINUTE * 60.0
5
4
  DAY = HOUR * 24.0
@@ -10,49 +9,41 @@ module ActiveObject::Time
10
9
  MILLENNIUM = CENTURY * 10.0
11
10
 
12
11
  KEY_UNITS = {
13
- month: "%m", month_padded: "%m", month_unpadded: "%-m", month_blank: "%_m",
14
- month_name: "%B", month_name_abbr: "%b", month_year: "%m %Y",
15
- month_padded_year: "%m %Y", month_unpadded_year: "%-m %Y",
16
- month_blank_year: "%_m %Y", month_name_year: "%B %Y",
17
- month_name_abbr_year: "%b %Y", weekday: "%d", weekday_padded: "%d",
18
- weekday_unpadded: "%-d", weekday_blank: "%_d", weekday_name: "%A",
19
- weekday_name_abbr: "%a", yr: "%y", year_abbr: "%y", year: "%Y", hour: "%H",
20
- hour_padded: "%H", hour_blank: "%k", hour_imperical: "%I",
21
- hour_imperical_padded: "%I", hour_imperical_blank: "%l", ampm: "%P",
22
- meridian: "%P", minute: "%M", second: "%S", time_zone: "%z",
23
- time_zone_offset: "%:z", time_zone_offset_full: "%::z", time_zone_name: "%Z",
24
- date: "%B %-d, %Y", date_abbr:"%b %-d, %Y", date_iso: "%Y-%m-%d",
25
- datetime: "%B %-d, %Y %H:%M", datetime_abbr: "%b %-d, %Y %H:%M",
26
- datetime_iso: "%Y-%m-%d %H:%M", datetime_imperical: "%B %-d, %Y %I:%M %P",
27
- datetime_imperical_abbr: "%b %-d, %Y %I:%M %P", datetime_imperical_iso: "%Y-%m-%d %I:%M %P",
28
- datetime_tzn: "%B %-d, %Y %H:%M %Z", datetime_abbr_tzn: "%b %-d, %Y %H:%M %Z",
29
- datetime_iso_tzn: "%Y-%m-%d %H:%M %z", datetime_imperical_tzn: "%B %-d, %Y %I:%M %P %Z",
30
- datetime_imperical_abbr_tzn: "%b %-d, %Y %I:%M %P %Z", datetime_imperical_iso_tzn: "%Y-%m-%d %I:%M %P %z",
31
- day: "%B %-d", day_abbr: "%b %-d", day_iso: "%m-%d", daytime: "%B %-d %H:%M",
32
- daytime_abbr: "%b %-d %H:%M", daytime_iso: "%m-%d %H:%M",
33
- daytime_imperical: "%B %-d %I:%M %P", daytime_imperical_abbr: "%b %-d %I:%M %P",
34
- daytime_imperical_iso: "%m-%d %I:%M %P", time: "%H:%M", time_padded: "%H:%M",
35
- time_blank: "%k:%M", time_tz: "%H:%M %z", time_tzn: "%H:%M %Z",
36
- time_imperical: "%I:%M %P", time_imperical_padded: "%I:%M %P",
37
- time_imperical_blank: "%l:%M %P", time_imperical_tz: "%I:%M %P %z",
38
- time_imperical_tzn: "%I:%M %P %Z"
39
- }
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'
33
+ }.freeze
40
34
  STRING_UNITS = {
41
- d: "d", day: "d", day_padded: "d", dd: "-d", Day: "-d", day_unpadded: "-d",
42
- ddd: "_d", DAY: "_d", day_blank: "_d", dddd: "j", day_of_the_year: "j",
43
- m: "m", month: "m", month_padded: "m", mm: "-m", Month: "-m",
44
- month_unpadded: "-m", mmm: "_m", MONTH: "_m", month_blank: "_m", mmmm: "B",
45
- month_name: "B", mmmmm: "b", month_name_abbr: "b", w: "u", weekday: "u",
46
- ww: "w", weekday_offset: "w", www: "A", weekday_name: "A", wwww: "a",
47
- weekday_name_abbr: "a", wwwww: "W", week: "W", wwwwww: "U", week_offset: "U",
48
- yy: "y", yr: "y", yyyy: "Y", year: "Y", h: "H", hour: "H", hour_padded: "H",
49
- hh: "k", HOUR: "k", hour_blank: "k", hhh: "I", hour_imperical: "I",
50
- hour_imperical_padded: "I", hhhh: "l", HOUR_IMPERICAL: "l",
51
- hour_imperical_blank: "l", ampm: "P", meridian: "P", AMPM: "p",
52
- MERIDIAN: "p", n: "M", minute: "M", s: "S", second: "S", z: "z",
53
- time_zone: "z", zz: ":z", time_zone_offset: ":z", zzz: "::z",
54
- time_zone_offset_full: "::z", zzzz: "Z", time_zone_name: "Z"
55
- }
35
+ d: 'd', day: 'd', day_padded: 'd', dd: '-d', Day: '-d', day_unpadded: '-d', ddd: '_d', zz: ':z',
36
+ DAY: '_d', day_blank: '_d', dddd: 'j', day_of_the_year: 'j', m: 'm', month: 'm', hhhh: 'l',
37
+ month_padded: 'm', mm: '-m', Month: '-m', month_unpadded: '-m', mmm: '_m', MONTH: '_m',
38
+ month_blank: '_m', mmmm: 'B', month_name: 'B', mmmmm: 'b', month_name_abbr: 'b', w: 'u', z: 'z',
39
+ weekday: 'u', ww: 'w', weekday_offset: 'w', www: 'A', weekday_name: 'A', wwww: 'a', yyyy: 'Y',
40
+ weekday_name_abbr: 'a', wwwww: 'W', week: 'W', wwwwww: 'U', week_offset: 'U', yy: 'y', yr: 'y',
41
+ year: 'Y', h: 'H', hour: 'H', hour_padded: 'H', hh: 'k', HOUR: 'k', hour_blank: 'k', hhh: 'I',
42
+ hour_imperical: 'I', hour_imperical_padded: 'I', HOUR_IMPERICAL: 'l', hour_imperical_blank: 'l',
43
+ ampm: 'P', meridian: 'P', AMPM: 'p', MERIDIAN: 'p', n: 'M', minute: 'M', s: 'S', second: 'S',
44
+ time_zone: 'z', time_zone_offset: ':z', zzz: '::z', time_zone_offset_full: '::z', zzzz: 'Z',
45
+ time_zone_name: 'Z'
46
+ }.freeze
56
47
 
57
48
  def count_centuries_since(time)
58
49
  count_seconds_since(time) / CENTURY
@@ -113,14 +104,12 @@ module ActiveObject::Time
113
104
  delimiters = string.scan(/\W+/)
114
105
  formatters = string.scan(/[a-z0-9_]+/i)
115
106
 
116
- string = formatters.map do |unit|
117
- "%#{STRING_UNITS.fetch(unit.to_sym)}#{delimiters.shift || ''}"
118
- end
107
+ string = formatters.map { |unit| "%#{STRING_UNITS.fetch(unit.to_sym)}#{delimiters.shift}" }
119
108
 
120
109
  strftime(string.join)
121
110
  end
122
111
 
123
- def to_format(key=:datetime_iso)
112
+ def to_format(key = :datetime_iso)
124
113
  strftime(KEY_UNITS.fetch(key.to_sym))
125
114
  end
126
115
 
@@ -128,4 +117,4 @@ module ActiveObject::Time
128
117
 
129
118
  end
130
119
 
131
- Time.send(:include, ActiveObject::Time) if ActiveObject.configuration.autoload_time
120
+ Time.send(:include, ActiveObject::Time) if ActiveObject::Settings.config.autoload_time
@@ -1,3 +1,3 @@
1
1
  module ActiveObject
2
- VERSION = "3.1.0"
2
+ VERSION = '4.0.0'.freeze
3
3
  end
@@ -1,12 +1,10 @@
1
- require "rails/generators"
1
+ require 'rails/generators'
2
2
 
3
- module ActiveObject
4
- class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path("../templates", __FILE__)
6
-
7
- def copy_initializer_file
8
- copy_file("install.rb", "config/initializers/active_object.rb")
9
- end
3
+ class ActiveObject::InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
10
5
 
6
+ def copy_initializer_file
7
+ copy_file('install.rb', 'config/initializers/active_object.rb')
11
8
  end
9
+
12
10
  end
@@ -1,4 +1,4 @@
1
- ActiveObject.configure do |config|
1
+ ActiveObject::Settings.configure do |config|
2
2
  config.autoload_array = true
3
3
  config.autoload_date = true
4
4
  config.autoload_enumerable = true
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: 3.1.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Gomez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fasterer
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: reek
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  description: Class extensions of commonly used ruby object helpers.
84
126
  email:
85
127
  - j.gomez@drexed.com
@@ -87,9 +129,13 @@ executables: []
87
129
  extensions: []
88
130
  extra_rdoc_files: []
89
131
  files:
132
+ - ".DS_Store"
90
133
  - ".coveralls.yml"
134
+ - ".fasterer.yml"
91
135
  - ".gitignore"
136
+ - ".reek"
92
137
  - ".rspec"
138
+ - ".rubocop.yml"
93
139
  - ".travis.yml"
94
140
  - CODE_OF_CONDUCT.md
95
141
  - Gemfile
@@ -100,9 +146,10 @@ files:
100
146
  - bin/console
101
147
  - bin/rake
102
148
  - bin/setup
149
+ - lib/.DS_Store
103
150
  - lib/active_object.rb
151
+ - lib/active_object/.DS_Store
104
152
  - lib/active_object/array.rb
105
- - lib/active_object/configuration.rb
106
153
  - lib/active_object/date.rb
107
154
  - lib/active_object/enumerable.rb
108
155
  - lib/active_object/hash.rb
@@ -110,6 +157,7 @@ files:
110
157
  - lib/active_object/numeric.rb
111
158
  - lib/active_object/object.rb
112
159
  - lib/active_object/range.rb
160
+ - lib/active_object/settings.rb
113
161
  - lib/active_object/string.rb
114
162
  - lib/active_object/time.rb
115
163
  - lib/active_object/version.rb
@@ -1,21 +0,0 @@
1
- class ActiveObject::Configuration
2
-
3
- attr_accessor :autoload_array, :autoload_date, :autoload_enumerable,
4
- :autoload_hash, :autoload_integer, :autoload_numeric,
5
- :autoload_object, :autoload_range, :autoload_string,
6
- :autoload_time
7
-
8
- def initialize
9
- @autoload_array = true
10
- @autoload_date = true
11
- @autoload_enumerable = true
12
- @autoload_hash = true
13
- @autoload_integer = true
14
- @autoload_numeric = true
15
- @autoload_object = true
16
- @autoload_range = true
17
- @autoload_string = true
18
- @autoload_time = true
19
- end
20
-
21
- end