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 +8 -8
- data/README.md +27 -17
- data/date_time_attribute.gemspec +1 -1
- data/lib/date_time_attribute.rb +2 -1
- data/lib/date_time_attribute/railtie.rb +10 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjliODc3YWY1MDc1ODQ2YWJiYzg4MWVjOWI1MTQ4ZjljNDk0MjhkYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2Y3YTJjZjc3OTA5MzZkNjZhYTZhMWNmZDE1Yjg0MDU4YjMyYzc4MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDg2M2MyOTFkZWU3YTg2MzEzODQ5OWYzMWM0MmQ3ZmM5ZDJiNWVlMmMzNTdj
|
10
|
+
NmRhNDNiNDEyY2I5Nzc2NWNkNTJlMWYwZjhjZWM3MGVmN2E0ZDllMTU2YmNh
|
11
|
+
NjA1MjI4MDFiMzA0NGM0Y2ZlZjFkZTBmNTNlNzEzYTQxZWU5MTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
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
|
-
|
data/date_time_attribute.gemspec
CHANGED
data/lib/date_time_attribute.rb
CHANGED
@@ -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
|
+
VERSION = '0.1.0'
|
8
9
|
|
9
10
|
extend ActiveSupport::Concern
|
10
11
|
|
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
|
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
|