chronorails 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +49 -1
- data/lib/chronorails/version.rb +1 -1
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -2,4 +2,52 @@
|
|
2
2
|
|
3
3
|
Chronorails handles adding virtual attributes to your models (with suitable validations, etc) allowing you to set date and duration fields with natural language text.
|
4
4
|
|
5
|
-
|
5
|
+
== Installation
|
6
|
+
|
7
|
+
gem install chronorails
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
For a hypothetical Rails model:
|
12
|
+
|
13
|
+
class RomanticMeeting < ActiveRecord::Base
|
14
|
+
attr_accessible :length, :start # Integer and DateTime DB fields, respectively
|
15
|
+
|
16
|
+
include Chronorails::ChronicAccessors
|
17
|
+
chronic_field :start, :required => true
|
18
|
+
chronic_duration_field :length
|
19
|
+
end
|
20
|
+
|
21
|
+
...include the accessors module, and configure Chronorails to start wrap your attributes with either Chronic or Chronic Duration virtual attributes.
|
22
|
+
|
23
|
+
Then in your form:
|
24
|
+
|
25
|
+
<%= f.text_field :chronic_start %>
|
26
|
+
<%= f.text_field :chronic_duration_length %>
|
27
|
+
|
28
|
+
...you can use the virtual attributes for your fields, entering natural language date and duration information that will be parsed into the regular fields (or will generate validation errors).
|
29
|
+
|
30
|
+
The 'required' option prevents setting the attributes with blank values; the 'validates' option controls the generation of validators (defaults to true) and the 'accessible' option controls the generation of Rails 3 'attr_accessible' calls (also defaults to true.)
|
31
|
+
|
32
|
+
== Testing
|
33
|
+
|
34
|
+
git clone git@github.com:simonhildebrandt/chronorails.git
|
35
|
+
cd chronorails
|
36
|
+
bundle install
|
37
|
+
cd spec/dummy
|
38
|
+
rake db:create
|
39
|
+
rake db:migrate
|
40
|
+
rake db:test:prepare
|
41
|
+
cd -
|
42
|
+
bundle exec rspec spec
|
43
|
+
|
44
|
+
== Contribute
|
45
|
+
|
46
|
+
* Fork
|
47
|
+
* Hack
|
48
|
+
* Test
|
49
|
+
* Pull request :)
|
50
|
+
|
51
|
+
== License
|
52
|
+
|
53
|
+
Copyright © 20013 Simon Hildebrandt, released under the MIT license
|
data/lib/chronorails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronorails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -109,7 +109,8 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- README.rdoc
|
111
111
|
homepage: https://github.com/simonhildebrandt/chronorails
|
112
|
-
licenses:
|
112
|
+
licenses:
|
113
|
+
- MIT
|
113
114
|
post_install_message:
|
114
115
|
rdoc_options: []
|
115
116
|
require_paths:
|