time_splitter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +18 -0
- data/README.md +13 -2
- data/lib/time_splitter/accessors.rb +0 -5
- data/lib/time_splitter/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4eeb1fc33ae43313893a99901f350a44039fe55
|
4
|
+
data.tar.gz: a98415d7d9391d9aa87e0639dc48bd45401d1967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b2c3e0372b6398df5f03a39ddc8457795fa07a903a72d6a1f163c568563f6a1b692ce37267a3b4f4fcaf32a67736514fc7fe43aaac46816309c4f55851b221
|
7
|
+
data.tar.gz: d4decaa99d60ea5f34013c98f065854f32f29fc7b168775168c12165b816fb40ae9a16852758ba4203a45d8d329f4f912f96a72cc4ef54c124d4c580ffa4ab97
|
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
TimeSplitter
|
2
2
|
============
|
3
3
|
[![Build Status](https://travis-ci.org/shekibobo/time_splitter.png)](https://travis-ci.org/shekibobo/time_splitter)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/time_splitter.png)](http://badge.fury.io/rb/time_splitter)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/shekibobo/time_splitter.png)](https://codeclimate.com/github/shekibobo/time_splitter)
|
4
6
|
|
5
|
-
Setting DateTimes can be a difficult or ugly thing, especially through a web form. Finding a good DatePicker or TimePicker is easy, but getting them to work on both can be difficult. TimeSplitter automatically generates accessors for `date`, `time`, `hour`, and `min` on
|
7
|
+
Setting DateTimes can be a difficult or ugly thing, especially through a web form. Finding a good DatePicker or TimePicker is easy, but getting them to work on both can be difficult. TimeSplitter automatically generates accessors for `date`, `time`, `hour`, and `min` on your datetime or time attributes, making it trivial to use different form inputs to set different parts of a datetime field.
|
6
8
|
|
7
9
|
This gem is based on [SplitDatetime](https://github.com/michihuber/split_datetime) by [Michi Huber](https://github.com/michihuber). TimeSplitter improves on the gem, updating for Rails 4, adding `time` accessors, and providing a safer and more consistent default setting.
|
8
10
|
|
9
|
-
##
|
11
|
+
## Install
|
12
|
+
|
13
|
+
### Standalone
|
14
|
+
|
15
|
+
`$ gem install time_splitter`
|
16
|
+
|
17
|
+
### Gemfile
|
18
|
+
|
10
19
|
In your `Gemfile`:
|
11
20
|
|
12
21
|
```ruby
|
@@ -36,6 +45,8 @@ In your view:
|
|
36
45
|
|
37
46
|
Add your js datepicker and you're good to go. (Of course, this also works with standard Rails form helpers).
|
38
47
|
|
48
|
+
If you are using Rails < 4.0 and/or are not using StrongParameters, you must add the `attr_accessor` for any of the split attributes you want to permit mass-assignment. TimeSplitter provides the methods that can be directly accessed, but will not automatically whitelist any of them for mass-assignment.
|
49
|
+
|
39
50
|
## Options
|
40
51
|
|
41
52
|
You can specify the date format for the view:
|
@@ -4,11 +4,6 @@ module TimeSplitter
|
|
4
4
|
opts = { format: "%F" }.merge!(attrs.extract_options!)
|
5
5
|
|
6
6
|
attrs.each do |attr|
|
7
|
-
attr_accessible "#{attr}_date",
|
8
|
-
"#{attr}_time",
|
9
|
-
"#{attr}_hour",
|
10
|
-
"#{attr}_min" if defined?(ActiveModel::MassAssignmentSecurity)
|
11
|
-
|
12
7
|
# Maps the setter for #{attr}_time to accept multipart-parameters for Time
|
13
8
|
composed_of "#{attr}_time".to_sym, class_name: 'DateTime' if self.respond_to?(:composed_of)
|
14
9
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_splitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michi Huber
|
@@ -48,6 +48,7 @@ executables: []
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
+
- .gitignore
|
51
52
|
- .travis.yml
|
52
53
|
- Gemfile
|
53
54
|
- LICENSE
|