cline 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +1 -2
- data/README.md +63 -31
- data/cline.gemspec +20 -25
- data/lib/cline.rb +6 -6
- data/lib/cline/collectors.rb +2 -2
- data/lib/cline/command.rb +22 -8
- data/lib/cline/configure.rb +10 -7
- data/lib/cline/notification.rb +39 -6
- data/lib/cline/out_streams.rb +1 -0
- data/lib/cline/version.rb +1 -1
- data/spec/fabricators.rb +1 -0
- data/spec/lib/cline_spec.rb +1 -1
- data/spec/lib/collectors_spec.rb +39 -19
- data/spec/lib/notification_spec.rb +19 -5
- data/spec/spec_helper.rb +2 -0
- data/spec/support/example_group_helper.rb +16 -0
- metadata +125 -31
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,76 +1,89 @@
|
|
1
|
-
# Cline - CLI Line Notifier
|
1
|
+
# Cline - CLI Line Notifier [](http://travis-ci.org/hibariya/cline)
|
2
2
|
|
3
3
|
Cline is a simple notification tool.
|
4
4
|
|
5
|
-
|
5
|
+
```
|
6
6
|
+------------+ +-----------+ +-----------+
|
7
7
|
| Collectors | ----------> | Cline | ----------> | OutStream |
|
8
8
|
+------------+ +-----------+ +-----------+
|
9
9
|
Collect any notifications Pool notifications Put anywhere
|
10
|
-
|
10
|
+
```
|
11
11
|
|
12
12
|
## Installation and Setting
|
13
13
|
|
14
|
-
|
14
|
+
```
|
15
15
|
$ gem install cline
|
16
16
|
$ cline init
|
17
|
-
|
17
|
+
```
|
18
18
|
|
19
19
|
In ~/.cline/config:
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
22
|
Cline.configure do |config|
|
23
23
|
config.pool_size = 2000
|
24
24
|
|
25
|
-
config.out_stream = Cline::OutStreams::
|
26
|
-
|
25
|
+
config.out_stream = Cline::OutStreams::WithNotify.new($stdout)
|
26
|
+
## Or
|
27
27
|
# config.out_stream = $stdout
|
28
28
|
|
29
29
|
config.append_collector Cline::Collectors::Feed
|
30
|
+
## Github:
|
31
|
+
# config.append_collector Cline::Collectors::Github
|
32
|
+
# Cline::Collectors::Github.login_name = 'hibariya'
|
30
33
|
end
|
31
|
-
|
34
|
+
```
|
32
35
|
|
33
36
|
Write your RSS feeds OPML file:
|
34
37
|
|
35
|
-
|
38
|
+
```
|
36
39
|
$ curl http://foo.examle.com/url/to/opml.xml > ~/.cline/feeds.xml
|
37
|
-
|
40
|
+
```
|
38
41
|
|
39
42
|
Collect notifications:
|
40
43
|
|
41
|
-
|
44
|
+
```
|
42
45
|
$ cline collect
|
43
|
-
|
46
|
+
```
|
44
47
|
|
45
48
|
Show notifications:
|
46
49
|
|
47
|
-
|
48
|
-
$ cline tick --offset 0 --interval 5
|
49
|
-
|
50
|
+
```
|
51
|
+
$ cline tick 0 5 # Or: cline tick --offset 0 --interval 5
|
52
|
+
[2012/05/02 02:34][9][w6] Introducing DuckDuckHack - Gabriel Weinberg's Blog http://www.gabrielweinberg.com/blog/2012/05/introducing-duckduckhack.html
|
53
|
+
| | |
|
54
|
+
`-- time | `-- alias
|
55
|
+
`----- display count
|
56
|
+
```
|
57
|
+
|
58
|
+
Open URL in the message:
|
59
|
+
|
60
|
+
```
|
61
|
+
$ cline open w6
|
62
|
+
```
|
50
63
|
|
51
64
|
## Use case
|
52
65
|
|
53
66
|
in ~/.screenrc
|
54
67
|
|
55
|
-
|
68
|
+
```
|
56
69
|
backtick 0 0 0 cline tick 0 60
|
57
|
-
|
70
|
+
```
|
58
71
|
|
59
72
|
## initialize Database
|
60
73
|
|
61
74
|
`init` command initialize new sqlite3 database.
|
62
75
|
|
63
|
-
|
76
|
+
```
|
64
77
|
$ cline init
|
65
|
-
|
78
|
+
```
|
66
79
|
|
67
80
|
## Collect
|
68
81
|
|
69
82
|
`collect` command collect new notifications from `Cline.collectors`.
|
70
83
|
|
71
|
-
|
84
|
+
```
|
72
85
|
$ cline collect
|
73
|
-
|
86
|
+
```
|
74
87
|
|
75
88
|
### Custom Collector
|
76
89
|
|
@@ -78,7 +91,7 @@ in ~/.screenrc
|
|
78
91
|
|
79
92
|
example:
|
80
93
|
|
81
|
-
|
94
|
+
```ruby
|
82
95
|
class MyCollector < Cline::Collectors::Base
|
83
96
|
def self.collect
|
84
97
|
new.sources.each do |source|
|
@@ -90,23 +103,23 @@ example:
|
|
90
103
|
# get new sources...
|
91
104
|
end
|
92
105
|
end
|
93
|
-
|
106
|
+
```
|
94
107
|
|
95
|
-
Cline::Collectors::Base class provides create_or_pass method.
|
108
|
+
Cline::Collectors::Base class provides `create_or_pass` method.
|
96
109
|
It create a new unique notification.
|
97
110
|
|
98
111
|
### Registration
|
99
112
|
|
100
113
|
in ~/.cline/config
|
101
114
|
|
102
|
-
|
115
|
+
```ruby
|
103
116
|
require 'path/to/my_collector'
|
104
117
|
|
105
118
|
Cline.configure do |config|
|
106
119
|
# ...
|
107
120
|
config.append_collector MyCollector
|
108
121
|
end
|
109
|
-
|
122
|
+
```
|
110
123
|
|
111
124
|
## Notifier
|
112
125
|
|
@@ -119,23 +132,42 @@ Cline's notifier required `puts` instance method.
|
|
119
132
|
|
120
133
|
example:
|
121
134
|
|
122
|
-
|
135
|
+
```ruby
|
123
136
|
class MyNotifier
|
124
137
|
def puts(str)
|
125
138
|
# implement notifier behaviour...
|
126
139
|
end
|
127
140
|
end
|
128
|
-
|
141
|
+
```
|
129
142
|
|
130
143
|
### Registration
|
131
144
|
|
132
145
|
in ~/.cline/config
|
133
146
|
|
134
|
-
|
147
|
+
```ruby
|
135
148
|
require 'path/to/my_notifier'
|
136
149
|
|
137
150
|
Cline.configure do |config|
|
138
151
|
# ...
|
139
152
|
config.out_stream = MyNotifier.new
|
140
153
|
end
|
141
|
-
|
154
|
+
```
|
155
|
+
|
156
|
+
## Filtering
|
157
|
+
|
158
|
+
Use ActiveRecord validators.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
Cline.configure do |config|
|
162
|
+
# ...
|
163
|
+
config.notification.validates :message, length: {maximum: 100}
|
164
|
+
end
|
165
|
+
```
|
166
|
+
|
167
|
+
## Contributing
|
168
|
+
|
169
|
+
1. Fork it
|
170
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
171
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
172
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
173
|
+
5. Create new Pull Request
|
data/cline.gemspec
CHANGED
@@ -1,43 +1,38 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'cline/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'cline'
|
7
7
|
s.version = Cline::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['hibariya']
|
9
|
+
s.email = ['celluloid.key@gmail.com']
|
10
|
+
s.homepage = 'https://github.com/hibariya/cline'
|
11
11
|
s.summary = %q{CLI Line Notifier}
|
12
12
|
s.description = %q{Cline - CLI Line Notifier}
|
13
13
|
|
14
14
|
#s.post_install_message = <<-EOM
|
15
15
|
#EOM
|
16
16
|
|
17
|
-
#s.rubyforge_project = "cline"
|
18
|
-
|
19
17
|
s.files = `git ls-files`.split("\n")
|
20
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
-
s.require_paths = [
|
23
|
-
|
24
|
-
# specify any dependencies here; for example:
|
25
|
-
# s.add_development_dependency "rspec"
|
26
|
-
# s.add_runtime_dependency "rest-client"
|
20
|
+
s.require_paths = ['lib']
|
27
21
|
|
28
|
-
s.add_runtime_dependency 'thor',
|
22
|
+
s.add_runtime_dependency 'thor', ['>= 0.14.6']
|
29
23
|
s.add_runtime_dependency 'activerecord', ['>= 3.1.1']
|
30
|
-
s.add_runtime_dependency 'sqlite3',
|
31
|
-
s.add_runtime_dependency 'feedzirra',
|
32
|
-
s.add_runtime_dependency 'notify',
|
24
|
+
s.add_runtime_dependency 'sqlite3', ['>= 1.3.4']
|
25
|
+
s.add_runtime_dependency 'feedzirra', ['~> 0.0.31'] # FIXME builder dependency workaround...
|
26
|
+
s.add_runtime_dependency 'notify', ['>= 0.3.0']
|
27
|
+
s.add_runtime_dependency 'launchy', ['>= 2.1.0']
|
33
28
|
|
34
|
-
s.add_development_dependency 'rake',
|
35
|
-
s.add_development_dependency 'ir_b',
|
36
|
-
s.add_development_dependency 'tapp',
|
37
|
-
s.add_development_dependency 'rspec',
|
38
|
-
s.add_development_dependency 'rr',
|
39
|
-
s.add_development_dependency 'fabrication',
|
40
|
-
s.add_development_dependency 'fuubar',
|
41
|
-
s.add_development_dependency 'simplecov',
|
29
|
+
s.add_development_dependency 'rake', ['>= 0.9.2']
|
30
|
+
s.add_development_dependency 'ir_b', ['>= 1.4.0']
|
31
|
+
s.add_development_dependency 'tapp', ['>= 1.1.0']
|
32
|
+
s.add_development_dependency 'rspec', ['>= 2.6.0']
|
33
|
+
s.add_development_dependency 'rr', ['>= 1.0.4']
|
34
|
+
s.add_development_dependency 'fabrication', ['>= 1.2.0']
|
35
|
+
s.add_development_dependency 'fuubar', ['>= 0.0.6']
|
36
|
+
s.add_development_dependency 'simplecov', ['>= 0.5.3']
|
42
37
|
s.add_development_dependency 'activesupport', ['>= 3.1.1']
|
43
38
|
end
|
data/lib/cline.rb
CHANGED
@@ -62,9 +62,9 @@ require 'thor'
|
|
62
62
|
require 'sqlite3'
|
63
63
|
require 'active_record'
|
64
64
|
|
65
|
-
require
|
66
|
-
require
|
67
|
-
require
|
68
|
-
require
|
69
|
-
require
|
70
|
-
require
|
65
|
+
require 'cline/version'
|
66
|
+
require 'cline/configure'
|
67
|
+
require 'cline/notification'
|
68
|
+
require 'cline/command'
|
69
|
+
require 'cline/collectors'
|
70
|
+
require 'cline/out_streams'
|
data/lib/cline/collectors.rb
CHANGED
@@ -10,9 +10,9 @@ module Cline::Collectors
|
|
10
10
|
return if oldest_notification && oldest_notification.notified_at.to_time > notified_at
|
11
11
|
|
12
12
|
Cline::Notification.instance_exec message, notified_at do |message, notified_at|
|
13
|
-
create(message: message, notified_at: notified_at) unless find_by_message_and_notified_at(message, notified_at)
|
13
|
+
create!(message: message, notified_at: notified_at) unless find_by_message_and_notified_at(message, notified_at)
|
14
14
|
end
|
15
|
-
rescue ActiveRecord::StatementInvalid => e
|
15
|
+
rescue ActiveRecord::StatementInvalid, ActiveRecord::RecordInvalid => e
|
16
16
|
puts e.class, e.message
|
17
17
|
end
|
18
18
|
|
data/lib/cline/command.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
require 'launchy'
|
4
|
+
|
3
5
|
module Cline
|
4
6
|
class Command < Thor
|
5
7
|
def self.start(*)
|
@@ -15,13 +17,13 @@ module Cline
|
|
15
17
|
'-i' => :init,
|
16
18
|
'-v' => :version
|
17
19
|
|
18
|
-
desc
|
20
|
+
desc :show, 'Show a latest message'
|
19
21
|
method_options offset: :integer
|
20
22
|
def show(offset = options[:offset] || 0)
|
21
23
|
Notification.display offset
|
22
24
|
end
|
23
25
|
|
24
|
-
desc
|
26
|
+
desc :tick, 'Rotate message'
|
25
27
|
method_options offset: :integer, interval: :integer
|
26
28
|
def tick(offset = options[:offset] || 0, interval = options[:interval] || 60)
|
27
29
|
loop do
|
@@ -30,7 +32,7 @@ module Cline
|
|
30
32
|
end
|
31
33
|
end
|
32
34
|
|
33
|
-
desc
|
35
|
+
desc :search, 'Search by query'
|
34
36
|
method_options query: :string
|
35
37
|
def search(keyword = optoins[:query])
|
36
38
|
Notification.by_keyword(keyword).each do |notification|
|
@@ -38,20 +40,32 @@ module Cline
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
|
-
desc
|
43
|
+
desc :open, 'Open the URL in the message if exists'
|
44
|
+
method_options hint: :string
|
45
|
+
def open(alias_string = options[:hint])
|
46
|
+
notification = Notification.by_alias_string(alias_string).last
|
47
|
+
|
48
|
+
if notification && url = notification.detect_url
|
49
|
+
Launchy.open url
|
50
|
+
else
|
51
|
+
say 'No URL found', :red
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc :status, 'Show status'
|
42
56
|
def status
|
43
57
|
say "displayed : #{Notification.displayed.count}", :green
|
44
58
|
say "total : #{Notification.count}", :cyan
|
45
59
|
end
|
46
60
|
|
47
|
-
desc
|
61
|
+
desc :collect, 'Collect sources'
|
48
62
|
def collect
|
49
63
|
Cline.collectors.each &:collect
|
50
64
|
|
51
65
|
clean_obsoletes
|
52
66
|
end
|
53
67
|
|
54
|
-
desc
|
68
|
+
desc :init, 'Init database'
|
55
69
|
def init
|
56
70
|
ActiveRecord::Base.connection.create_table(:notifications) do |t|
|
57
71
|
t.text :message, null: false, default: ''
|
@@ -60,7 +74,7 @@ module Cline
|
|
60
74
|
end
|
61
75
|
end
|
62
76
|
|
63
|
-
desc
|
77
|
+
desc :recent, 'Show recent notification'
|
64
78
|
method_options limit: :integer
|
65
79
|
def recent(limit = options[:limit] || 1)
|
66
80
|
Notification.recent_notified.limit(limit).each do |notification|
|
@@ -68,7 +82,7 @@ module Cline
|
|
68
82
|
end
|
69
83
|
end
|
70
84
|
|
71
|
-
desc
|
85
|
+
desc :version, 'Show version.'
|
72
86
|
def version
|
73
87
|
say "cline version #{Cline::VERSION}"
|
74
88
|
end
|
data/lib/cline/configure.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
require 'forwardable'
|
4
|
+
|
3
5
|
module Cline
|
4
|
-
def self.configure(&
|
5
|
-
|
6
|
+
def self.configure(&block)
|
7
|
+
configure = Configure.new
|
8
|
+
block ? block.(configure) : configure
|
6
9
|
end
|
7
10
|
|
8
11
|
class Configure
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
+
extend Forwardable
|
13
|
+
|
14
|
+
def_delegators Cline, :pool_size=, :out_stream=
|
12
15
|
|
13
|
-
def
|
14
|
-
Cline
|
16
|
+
def notification
|
17
|
+
Cline::Notification
|
15
18
|
end
|
16
19
|
|
17
20
|
def append_collector(collector)
|
data/lib/cline/notification.rb
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
require 'uri'
|
4
|
+
|
3
5
|
module Cline
|
4
6
|
class Notification < ActiveRecord::Base
|
5
7
|
validate :notified_at, presence: true
|
6
8
|
validate :message, presence: true, uniqueness: true
|
7
9
|
validate :display_count, presence: true, numerically: true
|
8
10
|
|
11
|
+
scope :with_id_alias, -> {
|
12
|
+
select('(id - (SELECT MIN(id) FROM notifications)) AS id_alias, *')
|
13
|
+
}
|
14
|
+
|
15
|
+
scope :by_alias_string, ->(alias_string) {
|
16
|
+
with_id_alias.where('id_alias = ?', alias_string.to_i(36))
|
17
|
+
}
|
18
|
+
|
9
19
|
scope :by_keyword, ->(word) {
|
10
20
|
where('message like ?', "%#{word}%").order('notified_at DESC, display_count')
|
11
21
|
}
|
@@ -14,7 +24,7 @@ module Cline
|
|
14
24
|
order(:display_count).order(:notified_at).limit(limit).offset(offset)
|
15
25
|
}
|
16
26
|
|
17
|
-
scope :displayed, where('display_count > 0')
|
27
|
+
scope :displayed, -> { where('display_count > 0') }
|
18
28
|
|
19
29
|
scope :recent_notified, ->(limit = 1) {
|
20
30
|
n = earliest.first
|
@@ -27,8 +37,11 @@ module Cline
|
|
27
37
|
end
|
28
38
|
|
29
39
|
class << self
|
30
|
-
def display(offset)
|
31
|
-
|
40
|
+
def display(offset = 0)
|
41
|
+
with_id_alias.
|
42
|
+
earliest(1, offset).
|
43
|
+
first.
|
44
|
+
display
|
32
45
|
end
|
33
46
|
|
34
47
|
def normalize_message(m)
|
@@ -36,7 +49,7 @@ module Cline
|
|
36
49
|
end
|
37
50
|
|
38
51
|
def clean(pool_size)
|
39
|
-
|
52
|
+
order('notified_at DESC').
|
40
53
|
order(:display_count).
|
41
54
|
offset(pool_size).
|
42
55
|
destroy_all
|
@@ -44,13 +57,33 @@ module Cline
|
|
44
57
|
end
|
45
58
|
|
46
59
|
def display
|
47
|
-
Cline.out_stream.
|
60
|
+
Cline.out_stream.tap do |out|
|
61
|
+
out.puts display_message
|
62
|
+
|
63
|
+
out.flush if out.respond_to?(:flush)
|
64
|
+
end
|
48
65
|
|
49
66
|
increment! :display_count
|
50
67
|
end
|
51
68
|
|
52
69
|
def display_message
|
53
|
-
|
70
|
+
display_time = notified_at.strftime('%Y/%m/%d %H:%M')
|
71
|
+
|
72
|
+
"[#{display_time}][#{display_count}][#{id_alias_string}] #{message}"
|
73
|
+
end
|
74
|
+
|
75
|
+
def detect_url(protocols = %w(http https))
|
76
|
+
regexp = URI.regexp(protocols)
|
77
|
+
|
78
|
+
if match = message.match(regexp)
|
79
|
+
match.to_s
|
80
|
+
else
|
81
|
+
nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def id_alias_string
|
86
|
+
id_alias.to_i.to_s(36)
|
54
87
|
end
|
55
88
|
end
|
56
89
|
end
|
data/lib/cline/out_streams.rb
CHANGED
data/lib/cline/version.rb
CHANGED
data/spec/fabricators.rb
CHANGED
data/spec/lib/cline_spec.rb
CHANGED
data/spec/lib/collectors_spec.rb
CHANGED
@@ -1,38 +1,58 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Cline::Collectors::Base do
|
6
|
-
describe '.
|
7
|
-
|
6
|
+
describe '.create_or_pass' do
|
7
|
+
describe '.oldest_notification' do
|
8
|
+
let(:oldest_notified_at) { 100.days.ago }
|
8
9
|
|
9
|
-
before do
|
10
|
-
Cline::Collectors::Base.send :reset_oldest_notification
|
11
|
-
Cline::Notification.create(message: 'awesome', notified_at: oldest_notified_at)
|
12
|
-
end
|
13
|
-
|
14
|
-
context 'too old notification' do
|
15
10
|
before do
|
16
|
-
|
11
|
+
Cline::Collectors::Base.send :reset_oldest_notification
|
12
|
+
Cline::Notification.create(message: 'awesome', notified_at: oldest_notified_at)
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'too old notification' do
|
16
|
+
before do
|
17
|
+
flunk unless Cline::Notification.count == 1
|
17
18
|
|
18
|
-
|
19
|
+
Cline::Collectors::Base.create_or_pass('too old', oldest_notified_at - 1.day)
|
20
|
+
end
|
21
|
+
|
22
|
+
subject { Cline::Notification.count }
|
23
|
+
|
24
|
+
it { should == 1 }
|
19
25
|
end
|
20
26
|
|
21
|
-
|
27
|
+
context 'newly notification' do
|
28
|
+
before do
|
29
|
+
flunk unless Cline::Notification.count == 1
|
30
|
+
|
31
|
+
Cline::Collectors::Base.create_or_pass('newly', oldest_notified_at + 1.day)
|
32
|
+
end
|
22
33
|
|
23
|
-
|
34
|
+
subject { Cline::Notification.count }
|
35
|
+
|
36
|
+
it { should == 2 }
|
37
|
+
end
|
24
38
|
end
|
25
39
|
|
26
|
-
context '
|
40
|
+
context 'invalid(filtered) notification' do
|
27
41
|
before do
|
28
|
-
|
29
|
-
|
30
|
-
|
42
|
+
Cline.configure do |config|
|
43
|
+
config.notification.validates :message, length: {maximum: 1000}
|
44
|
+
end
|
31
45
|
end
|
32
46
|
|
33
|
-
subject { Cline::
|
47
|
+
subject { capture(:stdout) { Cline::Collectors::Base.create_or_pass('a'*1001, Time.now) } }
|
34
48
|
|
35
|
-
it { should
|
49
|
+
it { should match 'ActiveRecord::RecordInvalid' }
|
50
|
+
|
51
|
+
describe 'Cline::Notification.count' do
|
52
|
+
subject { Cline::Notification.count }
|
53
|
+
|
54
|
+
it { should == 0 }
|
55
|
+
end
|
36
56
|
end
|
37
57
|
end
|
38
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Cline::Notification do
|
6
6
|
describe '.ealiest' do
|
@@ -87,11 +87,25 @@ describe Cline::Notification do
|
|
87
87
|
its(:message) { should_not match /\n/ }
|
88
88
|
end
|
89
89
|
|
90
|
-
describe '
|
91
|
-
let!(:notification) { Fabricate(:notification, display_count: 0) }
|
90
|
+
describe '.display' do
|
91
|
+
let!(:notification) { Fabricate(:notification, message: 'hi', notified_at: '2011-01-01 00:00:00', display_count: 0) }
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
before do
|
94
|
+
Cline::Notification.display
|
95
|
+
|
96
|
+
Cline.out_stream.rewind
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'stdout' do
|
100
|
+
subject { Cline.out_stream.read.strip }
|
101
|
+
|
102
|
+
it { should == '[2011/01/01 00:00][0][0] hi' }
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'display_count' do
|
106
|
+
subject { notification.reload }
|
107
|
+
|
108
|
+
its(:display_count) { should == 1 }
|
95
109
|
end
|
96
110
|
end
|
97
111
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module ExampleGroupHelper
|
4
|
+
def capture(stream)
|
5
|
+
begin
|
6
|
+
stream = stream.to_s
|
7
|
+
eval "$#{stream} = StringIO.new"
|
8
|
+
yield
|
9
|
+
result = eval("$#{stream}").string
|
10
|
+
ensure
|
11
|
+
eval("$#{stream} = #{stream.upcase}")
|
12
|
+
end
|
13
|
+
|
14
|
+
result
|
15
|
+
end
|
16
|
+
end
|
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.
|
4
|
+
version: 0.3.0
|
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:
|
12
|
+
date: 2012-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.14.6
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: activerecord
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 3.1.1
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.1.1
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: sqlite3
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 1.3.4
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.4
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: feedzirra
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: 0.0.31
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.0.31
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: notify
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,31 @@ dependencies:
|
|
65
85
|
version: 0.3.0
|
66
86
|
type: :runtime
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.3.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: launchy
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.1.0
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.1.0
|
69
110
|
- !ruby/object:Gem::Dependency
|
70
111
|
name: rake
|
71
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
72
113
|
none: false
|
73
114
|
requirements:
|
74
115
|
- - ! '>='
|
@@ -76,10 +117,15 @@ dependencies:
|
|
76
117
|
version: 0.9.2
|
77
118
|
type: :development
|
78
119
|
prerelease: false
|
79
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 0.9.2
|
80
126
|
- !ruby/object:Gem::Dependency
|
81
127
|
name: ir_b
|
82
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
83
129
|
none: false
|
84
130
|
requirements:
|
85
131
|
- - ! '>='
|
@@ -87,10 +133,15 @@ dependencies:
|
|
87
133
|
version: 1.4.0
|
88
134
|
type: :development
|
89
135
|
prerelease: false
|
90
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.4.0
|
91
142
|
- !ruby/object:Gem::Dependency
|
92
143
|
name: tapp
|
93
|
-
requirement:
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
94
145
|
none: false
|
95
146
|
requirements:
|
96
147
|
- - ! '>='
|
@@ -98,10 +149,15 @@ dependencies:
|
|
98
149
|
version: 1.1.0
|
99
150
|
type: :development
|
100
151
|
prerelease: false
|
101
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 1.1.0
|
102
158
|
- !ruby/object:Gem::Dependency
|
103
159
|
name: rspec
|
104
|
-
requirement:
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
105
161
|
none: false
|
106
162
|
requirements:
|
107
163
|
- - ! '>='
|
@@ -109,10 +165,15 @@ dependencies:
|
|
109
165
|
version: 2.6.0
|
110
166
|
type: :development
|
111
167
|
prerelease: false
|
112
|
-
version_requirements:
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 2.6.0
|
113
174
|
- !ruby/object:Gem::Dependency
|
114
175
|
name: rr
|
115
|
-
requirement:
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
116
177
|
none: false
|
117
178
|
requirements:
|
118
179
|
- - ! '>='
|
@@ -120,10 +181,15 @@ dependencies:
|
|
120
181
|
version: 1.0.4
|
121
182
|
type: :development
|
122
183
|
prerelease: false
|
123
|
-
version_requirements:
|
184
|
+
version_requirements: !ruby/object:Gem::Requirement
|
185
|
+
none: false
|
186
|
+
requirements:
|
187
|
+
- - ! '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: 1.0.4
|
124
190
|
- !ruby/object:Gem::Dependency
|
125
191
|
name: fabrication
|
126
|
-
requirement:
|
192
|
+
requirement: !ruby/object:Gem::Requirement
|
127
193
|
none: false
|
128
194
|
requirements:
|
129
195
|
- - ! '>='
|
@@ -131,10 +197,15 @@ dependencies:
|
|
131
197
|
version: 1.2.0
|
132
198
|
type: :development
|
133
199
|
prerelease: false
|
134
|
-
version_requirements:
|
200
|
+
version_requirements: !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ! '>='
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: 1.2.0
|
135
206
|
- !ruby/object:Gem::Dependency
|
136
207
|
name: fuubar
|
137
|
-
requirement:
|
208
|
+
requirement: !ruby/object:Gem::Requirement
|
138
209
|
none: false
|
139
210
|
requirements:
|
140
211
|
- - ! '>='
|
@@ -142,10 +213,15 @@ dependencies:
|
|
142
213
|
version: 0.0.6
|
143
214
|
type: :development
|
144
215
|
prerelease: false
|
145
|
-
version_requirements:
|
216
|
+
version_requirements: !ruby/object:Gem::Requirement
|
217
|
+
none: false
|
218
|
+
requirements:
|
219
|
+
- - ! '>='
|
220
|
+
- !ruby/object:Gem::Version
|
221
|
+
version: 0.0.6
|
146
222
|
- !ruby/object:Gem::Dependency
|
147
223
|
name: simplecov
|
148
|
-
requirement:
|
224
|
+
requirement: !ruby/object:Gem::Requirement
|
149
225
|
none: false
|
150
226
|
requirements:
|
151
227
|
- - ! '>='
|
@@ -153,10 +229,15 @@ dependencies:
|
|
153
229
|
version: 0.5.3
|
154
230
|
type: :development
|
155
231
|
prerelease: false
|
156
|
-
version_requirements:
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
none: false
|
234
|
+
requirements:
|
235
|
+
- - ! '>='
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: 0.5.3
|
157
238
|
- !ruby/object:Gem::Dependency
|
158
239
|
name: activesupport
|
159
|
-
requirement:
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
160
241
|
none: false
|
161
242
|
requirements:
|
162
243
|
- - ! '>='
|
@@ -164,7 +245,12 @@ dependencies:
|
|
164
245
|
version: 3.1.1
|
165
246
|
type: :development
|
166
247
|
prerelease: false
|
167
|
-
version_requirements:
|
248
|
+
version_requirements: !ruby/object:Gem::Requirement
|
249
|
+
none: false
|
250
|
+
requirements:
|
251
|
+
- - ! '>='
|
252
|
+
- !ruby/object:Gem::Version
|
253
|
+
version: 3.1.1
|
168
254
|
description: Cline - CLI Line Notifier
|
169
255
|
email:
|
170
256
|
- celluloid.key@gmail.com
|
@@ -209,6 +295,7 @@ files:
|
|
209
295
|
- spec/lib/notification_spec.rb
|
210
296
|
- spec/spec_helper.rb
|
211
297
|
- spec/support/.gitkeep
|
298
|
+
- spec/support/example_group_helper.rb
|
212
299
|
- spec/tmp/.gitkeep
|
213
300
|
homepage: https://github.com/hibariya/cline
|
214
301
|
licenses: []
|
@@ -222,15 +309,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
222
309
|
- - ! '>='
|
223
310
|
- !ruby/object:Gem::Version
|
224
311
|
version: '0'
|
312
|
+
segments:
|
313
|
+
- 0
|
314
|
+
hash: 35415735698241322
|
225
315
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
316
|
none: false
|
227
317
|
requirements:
|
228
318
|
- - ! '>='
|
229
319
|
- !ruby/object:Gem::Version
|
230
320
|
version: '0'
|
321
|
+
segments:
|
322
|
+
- 0
|
323
|
+
hash: 35415735698241322
|
231
324
|
requirements: []
|
232
325
|
rubyforge_project:
|
233
|
-
rubygems_version: 1.8.
|
326
|
+
rubygems_version: 1.8.23
|
234
327
|
signing_key:
|
235
328
|
specification_version: 3
|
236
329
|
summary: CLI Line Notifier
|
@@ -254,4 +347,5 @@ test_files:
|
|
254
347
|
- spec/lib/notification_spec.rb
|
255
348
|
- spec/spec_helper.rb
|
256
349
|
- spec/support/.gitkeep
|
350
|
+
- spec/support/example_group_helper.rb
|
257
351
|
- spec/tmp/.gitkeep
|