chronicle 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -21
- data/chronicle.gemspec +2 -2
- data/lib/chronicle.rb +16 -5
- data/lib/chronicle/version.rb +1 -1
- data/spec/chronicle_spec.rb +3 -3
- metadata +13 -15
data/README.md
CHANGED
@@ -1,34 +1,29 @@
|
|
1
1
|
Chronicle
|
2
2
|
=========
|
3
3
|
|
4
|
-
Chronicle groups collections of
|
5
|
-
It uses [Chronic](https://github.com/mojombo/chronic/) to parse natural language
|
4
|
+
Chronicle groups collections of ruby objects into time periods.
|
5
|
+
It uses [Chronic](https://github.com/mojombo/chronic/) to parse natural language date strings
|
6
6
|
and [ActiveSupport::OrderedHash](http://apidock.com/rails/ActiveSupport/OrderedHash)
|
7
|
-
to
|
7
|
+
to preserve the hash order.
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
# Before
|
11
|
-
[
|
12
|
-
|
13
|
-
|
14
|
-
object_3,
|
15
|
-
object_4,
|
16
|
-
object_5,
|
17
|
-
object_6,
|
18
|
-
object_7,
|
19
|
-
object_8
|
20
|
-
]
|
21
|
-
|
22
|
-
# After...
|
10
|
+
# Before:
|
11
|
+
[obj_1, obj_2, obj_3, obj_4, obj_5, obj_6, obj_7, obj_8, obj_9, obj_10]
|
12
|
+
|
13
|
+
# After:
|
23
14
|
{
|
24
|
-
"just now": [
|
25
|
-
"two hours ago": [
|
26
|
-
"yesterday": [
|
27
|
-
"6 months ago": [
|
28
|
-
"1 year ago": [
|
15
|
+
"just now": [obj_10, obj_9],
|
16
|
+
"two hours ago": [obj_8, obj_7, obj_6],
|
17
|
+
"yesterday": [obj_5, obj_4, obj_3],
|
18
|
+
"6 months ago": [obj_2],
|
19
|
+
"1 year ago": [obj_1]
|
29
20
|
}
|
30
21
|
```
|
31
22
|
|
23
|
+
An example UI using Chronicle:
|
24
|
+
|
25
|
+
[ !["Chronicle on Sniphr"](http://f.cl.ly/items/2I2q0P0w2Z2r0D0d390D/chronicle.png "Chronicle on Sniphr") ](http://sniphr.com "Sniphr")
|
26
|
+
|
32
27
|
Installation
|
33
28
|
------------
|
34
29
|
|
@@ -54,6 +49,9 @@ chronicle = Chronicle.new(things, :eras => ["5 minutes ago", "2 hours ago", "thr
|
|
54
49
|
chronicle = Chronicle.new(things, :date_attr => :updated_at)
|
55
50
|
```
|
56
51
|
|
52
|
+
To see the default `eras` used by Chronicle, have a look at
|
53
|
+
[chronicle.rb](https://github.com/zeke/chronicle/blob/master/lib/chronicle.rb#L16).
|
54
|
+
|
57
55
|
License
|
58
56
|
-------
|
59
57
|
|
data/chronicle.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Zeke Sikelianos"]
|
9
9
|
s.email = ["zeke@sikelianos.com"]
|
10
10
|
s.homepage = "http://zeke.sikelianos.com"
|
11
|
-
s.summary = %q{Chronicle groups collections of
|
12
|
-
s.description = %q{Chronicle groups collections of
|
11
|
+
s.summary = %q{Chronicle groups collections of ruby objects into time periods.}
|
12
|
+
s.description = %q{Chronicle groups collections of ruby objects into time periods.}
|
13
13
|
|
14
14
|
s.rubyforge_project = "chronicle"
|
15
15
|
|
data/lib/chronicle.rb
CHANGED
@@ -15,23 +15,34 @@ module Chronicle
|
|
15
15
|
|
16
16
|
def self.default_eras
|
17
17
|
[
|
18
|
+
"7 years ago",
|
19
|
+
"6 years ago",
|
20
|
+
"5 years ago",
|
21
|
+
"4 years ago",
|
18
22
|
"3 years ago",
|
19
23
|
"2 years ago",
|
20
|
-
"
|
24
|
+
"1 year ago",
|
21
25
|
"6 months ago",
|
26
|
+
"5 months ago",
|
27
|
+
"4 months ago",
|
22
28
|
"3 months ago",
|
23
29
|
"2 months ago",
|
24
|
-
"
|
30
|
+
"1 month ago",
|
25
31
|
"3 weeks ago",
|
26
32
|
"2 weeks ago",
|
27
|
-
"
|
33
|
+
"1 week ago",
|
28
34
|
"6 days ago",
|
35
|
+
"5 days ago",
|
29
36
|
"4 days ago",
|
30
37
|
"3 days ago",
|
31
38
|
"2 days ago",
|
32
|
-
"
|
39
|
+
"1 day ago",
|
33
40
|
"8 hours ago",
|
41
|
+
"7 hours ago",
|
42
|
+
"6 hours ago",
|
43
|
+
"5 hours ago",
|
34
44
|
"4 hours ago",
|
45
|
+
"3 hours ago",
|
35
46
|
"2 hours ago",
|
36
47
|
"1 hour ago",
|
37
48
|
"30 minutes ago",
|
@@ -40,7 +51,7 @@ module Chronicle
|
|
40
51
|
"5 minutes ago",
|
41
52
|
"3 minutes ago",
|
42
53
|
"2 minutes ago",
|
43
|
-
"
|
54
|
+
"1 minute ago",
|
44
55
|
"just now"
|
45
56
|
]
|
46
57
|
end
|
data/lib/chronicle/version.rb
CHANGED
data/spec/chronicle_spec.rb
CHANGED
@@ -21,11 +21,11 @@ describe Chronicle do
|
|
21
21
|
|
22
22
|
it "sorts era keys from newest to oldest" do
|
23
23
|
@chronicle.keys.first.should == 'just now'
|
24
|
-
@chronicle.keys.last.should == '
|
24
|
+
@chronicle.keys.last.should == '1 month ago'
|
25
25
|
end
|
26
26
|
|
27
27
|
it "sorts objects in eras from newest to oldest" do
|
28
|
-
era = @chronicle['
|
28
|
+
era = @chronicle['1 week ago']
|
29
29
|
era.size.should == 2
|
30
30
|
era.last.created_at.should be < era.first.created_at
|
31
31
|
end
|
@@ -75,7 +75,7 @@ describe Chronicle do
|
|
75
75
|
it "allows an alternative to created_at" do
|
76
76
|
@chronicle = Chronicle.new(@things, :date_attr => :updated_at)
|
77
77
|
@chronicle.values.flatten.size.should == @things.size
|
78
|
-
@chronicle.keys.last.should == '
|
78
|
+
@chronicle.keys.last.should == '1 year ago'
|
79
79
|
@chronicle.keys.first.should == 'just now'
|
80
80
|
end
|
81
81
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chronicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hoe
|
16
|
-
requirement: &
|
16
|
+
requirement: &70113761128700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70113761128700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70113761128200 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70113761128200
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: autotest
|
38
|
-
requirement: &
|
38
|
+
requirement: &70113761127780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70113761127780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: chronic
|
49
|
-
requirement: &
|
49
|
+
requirement: &70113761127320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70113761127320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rails
|
60
|
-
requirement: &
|
60
|
+
requirement: &70113761126900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,9 +65,8 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
69
|
-
description: Chronicle groups collections of
|
70
|
-
ordered hashes.
|
68
|
+
version_requirements: *70113761126900
|
69
|
+
description: Chronicle groups collections of ruby objects into time periods.
|
71
70
|
email:
|
72
71
|
- zeke@sikelianos.com
|
73
72
|
executables: []
|
@@ -107,6 +106,5 @@ rubyforge_project: chronicle
|
|
107
106
|
rubygems_version: 1.8.10
|
108
107
|
signing_key:
|
109
108
|
specification_version: 3
|
110
|
-
summary: Chronicle groups collections of
|
111
|
-
ordered hashes.
|
109
|
+
summary: Chronicle groups collections of ruby objects into time periods.
|
112
110
|
test_files: []
|