date_time_attribute 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjNiMzFiYjM3NzE2ZWNhY2U3Y2Y3MDIyMzFiZTUxYjc3M2ZiZmQyOQ==
4
+ YjliODc3YWY1MDc1ODQ2YWJiYzg4MWVjOWI1MTQ4ZjljNDk0MjhkYQ==
5
5
  data.tar.gz: !binary |-
6
- YWVkMjNhZDI2N2I0ZTU1ODkwMzZiYjRmNGRhYzJiZDNhZGIyODM4ZQ==
6
+ M2Y3YTJjZjc3OTA5MzZkNjZhYTZhMWNmZDE1Yjg0MDU4YjMyYzc4MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODIyMzliYTdlNWQ3YzgzM2VkNzQzNzllNjM4MDFmZmMxNjI2MTEyZTk4NjRj
10
- MDRhNGUzYmQxY2QwZDJmODBhZDBiNGFlNTY3ODZhYTQ1NGVhYmUxZWRlNmI3
11
- ZWI1Mjg1Y2JiOTc1M2Q1MjdiOTdlMjg3MGY5MGJkMmZlY2Q3OTc=
9
+ MDg2M2MyOTFkZWU3YTg2MzEzODQ5OWYzMWM0MmQ3ZmM5ZDJiNWVlMmMzNTdj
10
+ NmRhNDNiNDEyY2I5Nzc2NWNkNTJlMWYwZjhjZWM3MGVmN2E0ZDllMTU2YmNh
11
+ NjA1MjI4MDFiMzA0NGM0Y2ZlZjFkZTBmNTNlNzEzYTQxZWU5MTg=
12
12
  data.tar.gz: !binary |-
13
- OTMyNDgzZmMzMzU4NmUzZDYyZDk1YjAzZmE1MTIxNzc3NDUwMzJlNGJkMmVl
14
- NWMwN2Y5Y2E2MDM4NjIyZjBmMmE5NDY1M2M5MTMzYWNhMGFhNzJiM2NhMmJk
15
- MzdlMTMzMGEwZDE4ZTE2YmQ1ZTdlZTE3NGQ3NDI4NDdhZWZhNjc=
13
+ NWQxNzc1NDdiMTE1MWQ5MmYyN2ZlOWIzMWVmYmQyOWQwYTdhYTZjMmUzMTk3
14
+ ZDg3Njc5MTAwODE2ZTc0NmJiZGQ5MjA0MWIwZjAyNzliOTkyZDIyY2M2NTE2
15
+ OGY2ZTZkMDQ3YmM1M2I1YTU0NDc2NmRiMDJhOWYyYmUxMmJjMWI=
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/einzige/date_time_attribute.png?branch=master)](https://travis-ci.org/einzige/date_time_attribute)
4
4
  [![Dependency Status](https://gemnasium.com/einzige/date_time_attribute.png)](https://gemnasium.com/einzige/date_time_attribute)
5
5
 
6
- Splits DateTime attribute access into two Data, Time and TimeZone attributes. Compatible with ActiveRecord.
6
+ Splits DateTime attribute access into two Data, Time and TimeZone attributes. Compatible with ActiveRecorda as well as with Rails.
7
7
 
8
8
  ## Install
9
9
 
@@ -98,6 +98,32 @@ task.due_at_time_zone = 'Moscow'
98
98
  task.due_at # => Mon, 02 Dec 2013 02:00:00 MSK +04:00
99
99
  ```
100
100
 
101
+ ## Rails users
102
+
103
+ You don't need to set up anything, it just works out of the box through railtie
104
+
105
+ ```ruby
106
+ class MyModel < ActiveRecord::Base
107
+ date_time_attribute :created_at
108
+ end
109
+ ```
110
+
111
+ ## ActiveRecord users (no Rails)
112
+
113
+ In order to include globally in your models:
114
+
115
+ ```ruby
116
+ ActiveRecord::Base.send(:include, DateTimeAttribute)
117
+ ```
118
+
119
+ Then add attributes into your models:
120
+
121
+ ```ruby
122
+ class MyModel < ActiveRecord::Base
123
+ date_time_attribute :created_at, :updated_at # See more examples above
124
+ end
125
+ ```
126
+
101
127
  ## Using Chronic gem
102
128
 
103
129
  ```ruby
@@ -123,19 +149,3 @@ my_date_time = DateTimeAttribute::Container.new(Time.zone.now)
123
149
  my_date_time.date_time # => 2013-12-03 00:02:01 +0000
124
150
  ```
125
151
 
126
- ## ActiveRecord users
127
-
128
- If you are using Rails put in your initializers (eg `config/initializers/date_time_attribute.rb`):
129
-
130
- ```ruby
131
- ActiveRecord::Base.send(:include, DateTimeAttribute)
132
- ```
133
-
134
- Then add attributes into your models:
135
-
136
- ```ruby
137
- class MyModel < ActiveRecord::Base
138
- date_time_attribute :created_at, :updated_at # See more examples above
139
- end
140
- ```
141
-
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{date_time_attribute}
5
- s.version = "0.0.8"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.date = %q{2013-11-22}
8
8
  s.authors = ["Sergei Zinin"]
@@ -2,9 +2,10 @@ require 'rubygems'
2
2
  require 'active_support'
3
3
  require 'active_support/duration'
4
4
  require 'date_time_attribute/container'
5
+ require 'date_time_attribute/railtie' if defined?(Rails)
5
6
 
6
7
  module DateTimeAttribute
7
- VERSION = '0.0.8'
8
+ VERSION = '0.1.0'
8
9
 
9
10
  extend ActiveSupport::Concern
10
11
 
@@ -0,0 +1,10 @@
1
+ module DateTimeAttribute
2
+ class Railtie < Rails::Railtie
3
+ initializer 'date_time_attribute.initialize' do
4
+ ActiveSupport.on_load(:active_record) do
5
+ ActiveRecord::Base.send :include, DateTimeAttribute
6
+ end
7
+ end
8
+ end
9
+ end
10
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_time_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Zinin
@@ -70,6 +70,7 @@ files:
70
70
  - gemfiles/rails4.1.rc1
71
71
  - lib/date_time_attribute.rb
72
72
  - lib/date_time_attribute/container.rb
73
+ - lib/date_time_attribute/railtie.rb
73
74
  - spec/active_record_spec.rb
74
75
  - spec/date_time_attribute/container_spec.rb
75
76
  - spec/date_time_attribute_spec.rb