cline 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +63 -18
- data/lib/cline/command.rb +2 -2
- data/lib/cline/configure.rb +21 -0
- data/lib/cline/version.rb +1 -1
- data/lib/cline.rb +1 -0
- data/spec/lib/notification_spec.rb +43 -1
- data/spec/spec_helper.rb +3 -2
- metadata +31 -30
data/README.md
CHANGED
@@ -1,17 +1,51 @@
|
|
1
1
|
# Cline - CLI Line Notifier
|
2
2
|
|
3
|
-
|
3
|
+
Cline is a simple notification tool.
|
4
4
|
|
5
5
|
~~~~
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
+------------+ +-----------+ +-----------+
|
7
|
+
| Collectors | ----------> | Cline | ----------> | OutStream |
|
8
|
+
+------------+ +-----------+ +-----------+
|
9
|
+
Collect any notifications Pool notifications Put anywhere
|
10
|
+
~~~~
|
11
|
+
|
12
|
+
## Installation and Setting
|
13
|
+
|
14
|
+
~~~~
|
15
|
+
$ gem install cline
|
16
|
+
$ cline init
|
17
|
+
~~~~
|
18
|
+
|
19
|
+
In ~/.cline/config:
|
20
|
+
|
21
|
+
~~~~ruby
|
22
|
+
Cline.configure do |config|
|
23
|
+
config.pool_size = 2000
|
24
|
+
|
25
|
+
config.out_stream = Cline::OutStreams::WithGrowl.new($stdout)
|
26
|
+
# Or
|
27
|
+
# config.out_stream = $stdout
|
12
28
|
|
13
|
-
|
14
|
-
|
29
|
+
config.append_collector Cline::Collectors::Feed
|
30
|
+
end
|
31
|
+
~~~~
|
32
|
+
|
33
|
+
Write your RSS feeds OPML file:
|
34
|
+
|
35
|
+
~~~~
|
36
|
+
$ curl http://foo.examle.com/url/to/opml.xml > ~/.cline/feeds.xml
|
37
|
+
~~~~
|
38
|
+
|
39
|
+
Collect notifications:
|
40
|
+
|
41
|
+
~~~~
|
42
|
+
$ cline collect
|
43
|
+
~~~~
|
44
|
+
|
45
|
+
Show notifications:
|
46
|
+
|
47
|
+
~~~~
|
48
|
+
$ cline tick --offset 0 --interval 5
|
15
49
|
~~~~
|
16
50
|
|
17
51
|
## Use case
|
@@ -24,18 +58,18 @@ in ~/.screenrc
|
|
24
58
|
|
25
59
|
## initialize Database
|
26
60
|
|
27
|
-
`init`command initialize new sqlite3 database.
|
61
|
+
`init` command initialize new sqlite3 database.
|
28
62
|
|
29
63
|
~~~~
|
30
|
-
cline init
|
64
|
+
$ cline init
|
31
65
|
~~~~
|
32
66
|
|
33
|
-
##
|
67
|
+
## Collect
|
34
68
|
|
35
|
-
`collect`command collect new notifications from `Cline.collectors`.
|
69
|
+
`collect` command collect new notifications from `Cline.collectors`.
|
36
70
|
|
37
71
|
~~~~
|
38
|
-
cline collect
|
72
|
+
$ cline collect
|
39
73
|
~~~~
|
40
74
|
|
41
75
|
### Custom Collector
|
@@ -45,10 +79,10 @@ in ~/.screenrc
|
|
45
79
|
example:
|
46
80
|
|
47
81
|
~~~~ruby
|
48
|
-
class MyCollector
|
82
|
+
class MyCollector < Cline::Collectors::Base
|
49
83
|
def self.collect
|
50
84
|
new.sources.each do |source|
|
51
|
-
|
85
|
+
create_or_pass source.body, source.created_at
|
52
86
|
end
|
53
87
|
end
|
54
88
|
|
@@ -58,13 +92,20 @@ example:
|
|
58
92
|
end
|
59
93
|
~~~~
|
60
94
|
|
95
|
+
Cline::Collectors::Base class provides create_or_pass method.
|
96
|
+
It create a new unique notification.
|
97
|
+
|
61
98
|
### Registration
|
62
99
|
|
63
100
|
in ~/.cline/config
|
64
101
|
|
65
102
|
~~~~ruby
|
66
103
|
require 'path/to/my_collector'
|
67
|
-
|
104
|
+
|
105
|
+
Cline.configure do |config|
|
106
|
+
# ...
|
107
|
+
config.append_collector MyCollector
|
108
|
+
end
|
68
109
|
~~~~
|
69
110
|
|
70
111
|
## Notifier
|
@@ -92,5 +133,9 @@ in ~/.cline/config
|
|
92
133
|
|
93
134
|
~~~~ruby
|
94
135
|
require 'path/to/my_notifier'
|
95
|
-
|
136
|
+
|
137
|
+
Cline.configure do |config|
|
138
|
+
# ...
|
139
|
+
config.out_stream = MyNotifier.new
|
140
|
+
end
|
96
141
|
~~~~
|
data/lib/cline/command.rb
CHANGED
@@ -48,7 +48,7 @@ module Cline
|
|
48
48
|
def collect
|
49
49
|
Cline.collectors.each &:collect
|
50
50
|
|
51
|
-
clean_obsoletes
|
51
|
+
clean_obsoletes
|
52
52
|
end
|
53
53
|
|
54
54
|
desc 'init', 'Init database'
|
@@ -76,7 +76,7 @@ module Cline
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def clean_obsoletes
|
79
|
-
Notification.clean Cline.pool_size
|
79
|
+
Notification.clean(Cline.pool_size) if Cline.pool_size
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Cline
|
4
|
+
def self.configure(&config)
|
5
|
+
config.call Configure.new
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configure
|
9
|
+
def pool_size=(size)
|
10
|
+
Cline.pool_size = size
|
11
|
+
end
|
12
|
+
|
13
|
+
def out_stream=(stream)
|
14
|
+
Cline.out_stream = stream
|
15
|
+
end
|
16
|
+
|
17
|
+
def append_collector(collector)
|
18
|
+
Cline.collectors << collector
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/cline/version.rb
CHANGED
data/lib/cline.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative '../spec_helper'
|
|
5
5
|
describe Cline::Notification do
|
6
6
|
describe '.ealiest' do
|
7
7
|
let!(:notification1) { Fabricate(:notification, notified_at: 2.days.ago.beginning_of_day, display_count: 3) }
|
8
|
-
let!(:notification2) { Fabricate(:notification, notified_at:
|
8
|
+
let!(:notification2) { Fabricate(:notification, notified_at: 2.days.ago.beginning_of_day, display_count: 2) }
|
9
9
|
let!(:notification3) { Fabricate(:notification, notified_at: 3.days.ago.beginning_of_day, display_count: 2) }
|
10
10
|
|
11
11
|
context 'default(limit 1 offset 0)' do
|
@@ -30,6 +30,48 @@ describe Cline::Notification do
|
|
30
30
|
it { should == [notification2] }
|
31
31
|
end
|
32
32
|
|
33
|
+
describe '.clean' do
|
34
|
+
let!(:notification1) { Fabricate(:notification, notified_at: 3.days.ago.beginning_of_day, display_count: 3) }
|
35
|
+
let!(:notification2) { Fabricate(:notification, notified_at: 3.days.ago.beginning_of_day, display_count: 2) }
|
36
|
+
let!(:notification3) { Fabricate(:notification, notified_at: 2.days.ago.beginning_of_day, display_count: 2) }
|
37
|
+
|
38
|
+
context 'pool_size 2' do
|
39
|
+
before do
|
40
|
+
Cline::Notification.clean 2
|
41
|
+
end
|
42
|
+
|
43
|
+
subject { Cline::Notification.all }
|
44
|
+
|
45
|
+
its(:length) { should == 2 }
|
46
|
+
it { should include notification2 }
|
47
|
+
it { should include notification3 }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'pool_size 1' do
|
51
|
+
before do
|
52
|
+
Cline::Notification.clean 1
|
53
|
+
end
|
54
|
+
|
55
|
+
subject { Cline::Notification.all }
|
56
|
+
|
57
|
+
its(:length) { should == 1 }
|
58
|
+
it { should include notification3 }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.recent_notified' do
|
63
|
+
let!(:notification1) { Fabricate(:notification, notified_at: 3.days.ago.beginning_of_day, display_count: 0) }
|
64
|
+
let!(:notification2) { Fabricate(:notification, notified_at: 2.days.ago.beginning_of_day, display_count: 0) }
|
65
|
+
|
66
|
+
before do
|
67
|
+
Cline::Notification.display 0
|
68
|
+
end
|
69
|
+
|
70
|
+
subject { Cline::Notification.recent_notified(1).all }
|
71
|
+
|
72
|
+
it { should == [notification1] }
|
73
|
+
end
|
74
|
+
|
33
75
|
describe '#message=' do
|
34
76
|
let(:notification) { Fabricate(:notification, display_count: 0) }
|
35
77
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70363467909660 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70363467909660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activerecord
|
27
|
-
requirement: &
|
27
|
+
requirement: &70363467907460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 3.1.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70363467907460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &70363467903860 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.3.4
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70363467903860
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: feedzirra
|
49
|
-
requirement: &
|
49
|
+
requirement: &70363467902320 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.0.31
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70363467902320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: notify
|
60
|
-
requirement: &
|
60
|
+
requirement: &70363467916860 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.3.0
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70363467916860
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &70363467911660 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.9.2
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70363467911660
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: ir_b
|
82
|
-
requirement: &
|
82
|
+
requirement: &70363467924200 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.4.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70363467924200
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: tapp
|
93
|
-
requirement: &
|
93
|
+
requirement: &70363467921920 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.1.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70363467921920
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &70363467920900 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 2.6.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70363467920900
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rr
|
115
|
-
requirement: &
|
115
|
+
requirement: &70363467919920 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ! '>='
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 1.0.4
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *70363467919920
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: fabrication
|
126
|
-
requirement: &
|
126
|
+
requirement: &70363467919320 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,10 +131,10 @@ dependencies:
|
|
131
131
|
version: 1.2.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *70363467919320
|
135
135
|
- !ruby/object:Gem::Dependency
|
136
136
|
name: fuubar
|
137
|
-
requirement: &
|
137
|
+
requirement: &70363467918440 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
@@ -142,10 +142,10 @@ dependencies:
|
|
142
142
|
version: 0.0.6
|
143
143
|
type: :development
|
144
144
|
prerelease: false
|
145
|
-
version_requirements: *
|
145
|
+
version_requirements: *70363467918440
|
146
146
|
- !ruby/object:Gem::Dependency
|
147
147
|
name: simplecov
|
148
|
-
requirement: &
|
148
|
+
requirement: &70363467928960 !ruby/object:Gem::Requirement
|
149
149
|
none: false
|
150
150
|
requirements:
|
151
151
|
- - ! '>='
|
@@ -153,10 +153,10 @@ dependencies:
|
|
153
153
|
version: 0.5.3
|
154
154
|
type: :development
|
155
155
|
prerelease: false
|
156
|
-
version_requirements: *
|
156
|
+
version_requirements: *70363467928960
|
157
157
|
- !ruby/object:Gem::Dependency
|
158
158
|
name: activesupport
|
159
|
-
requirement: &
|
159
|
+
requirement: &70363467942860 !ruby/object:Gem::Requirement
|
160
160
|
none: false
|
161
161
|
requirements:
|
162
162
|
- - ! '>='
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
version: 3.1.1
|
165
165
|
type: :development
|
166
166
|
prerelease: false
|
167
|
-
version_requirements: *
|
167
|
+
version_requirements: *70363467942860
|
168
168
|
description: Cline - CLI Line Notifier
|
169
169
|
email:
|
170
170
|
- celluloid.key@gmail.com
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- lib/cline/collectors/feed.rb
|
187
187
|
- lib/cline/collectors/github.rb
|
188
188
|
- lib/cline/command.rb
|
189
|
+
- lib/cline/configure.rb
|
189
190
|
- lib/cline/notification.rb
|
190
191
|
- lib/cline/out_streams.rb
|
191
192
|
- lib/cline/version.rb
|