Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

Commit

Permalink
Merge branch 'be-1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
hibariya committed Jan 2, 2013
2 parents 307f42f + cdfd085 commit 8a90657
Show file tree
Hide file tree
Showing 21 changed files with 545 additions and 224 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,2 +1,2 @@
rvm:
- '1.9.3-p125'
- 1.9.3
119 changes: 77 additions & 42 deletions README.md
@@ -1,39 +1,78 @@
# Cline - CLI Line Notifier [![Build Status](https://secure.travis-ci.org/hibariya/cline.png?branch=master)](http://travis-ci.org/hibariya/cline)
# Cline - Show recently news on the terminal[![Build Status](https://secure.travis-ci.org/hibariya/cline.png?branch=master)](http://travis-ci.org/hibariya/cline)

Cline is a simple notification tool.
```
+-------------------------+ +-------+ +--------------------------------------+
| Notification Collectors | -> | Cline | -> | IO (STDOUT, File and Other notifier) |
+-------------------------+ +-------+ +--------------------------------------+
Collect any news Store notifications Put anywhere
```

Cline is a simple notification tool for CLI.
This tool collects automatically any Feeds and GitHub activities.
Those notifications shown on stdout or anywhere at good timing.

Like this:

```
$ cline show
[2012/11/27 01:18][5][184] TED: Ideas worth spreading http://icio.us/+a922037eaf9bb
```

A notification is structured by below contents:

* Published date of the entry and activity
* Displayed count
* Alias number for specify from CLI ([0-9a-z]+)
* Title or summary (includes source URL)

In most cases Cline used for backtick of screen. Like this:

```
[2012/12/01 23:12][9][1bt] Amazon Redshift http://aws.amazon.com/redshift/
[2012/12/01 23:12][9][1bu] My eBook build process and some PDF, EPUB and MOBI tips - Pat Shaughnessy http://patshaughnessy.net/2012/11/27/my-ebook-build-process-and-some-pdf-epub-and-mobi-tips
[2012/12/01 23:12][9][1bs] How to Clean Up Your Online Presence and Make a Great First Impression http://lifehacker.com/5963864/how-to-clean-up-your-online-presence-and-make-a-great-first-impression
```

You can open the URI of a notification. Like this:

```
+------------+ +-----------+ +-----------+
| Collectors | ----------> | Cline | ----------> | OutStream |
+------------+ +-----------+ +-----------+
Collect any notifications Pool notifications Put anywhere
$ cline open 1bt
```

Cline decides priority of each notification automatically with 'displayed count' and 'published date'.
You can't control priority of Cline's output.

## Installation and Setting

```
$ gem install cline
$ cline init
$ cline init # database file will created under ~/.cline directory
```

In ~/.cline/config:
An example of configuration file (~/.cline/config):

```ruby
ENV['NOTIFY'] = 'notify-send' # ensure notification behaviour if you use the notify gem

Cline.configure do |config|
config.pool_size = 2000
config.notifications_limit = 2000 # old notifications will be removed automatically

config.notify_io = Cline::NotifyIO::WithNotify.new
# Default is:
# config.notify_io = $stdout

config.out_stream = Cline::OutStreams::WithNotify.new($stdout)
## Or
# config.out_stream = $stdout
config.collectors << Cline::Collectors::Feed

config.append_collector Cline::Collectors::Feed
## Github:
# config.append_collector Cline::Collectors::Github
# Cline::Collectors::Github.login_name = 'hibariya'
# Github:
config.collectors << Cline::Collectors::Github
Cline::Collectors::Github.login_name = 'hibariya'

# When server is running then collectors will run every hours.
config.jobs << Cline::ScheduledJob.new(-> { Time.now.min.zero? }, &:collect)
end
```

Write your RSS feeds OPML file:
Write OPML file of your RSS feeds:

```
$ curl http://foo.examle.com/url/to/opml.xml > ~/.cline/feeds.xml
Expand All @@ -48,44 +87,44 @@ Collect notifications:
Show notifications:

```
$ cline tick 0 5 # Or: cline tick --offset 0 --interval 5
$ cline tick 5
[2012/05/02 02:34][9][w6] Introducing DuckDuckHack - Gabriel Weinberg's Blog http://www.gabrielweinberg.com/blog/2012/05/introducing-duckduckhack.html
| | |
`-- time | `-- alias
`----- display count
```

Open URL in the message:
How to open a URL in the message: Use open command and specify notification alias.

```
$ cline open w6
```

## Use case

in ~/.screenrc

```
backtick 0 0 0 cline tick 0 60
```

## initialize Database
In most cases Cline used for backtick of screen.

`init` command initialize new sqlite3 database.
In ~/.screenrc:

```
$ cline init
backtick 0 0 0 cline tick 5
```

## Collect
## Cline daemon

`collect` command collect new notifications from `Cline.collectors`.
When server is running then cline uses server process.
Using server is faster and less memory.

```
$ cline collect
$ cline server start # start server
$ cline server reload # reload ~/.cline/config file
$ cline server stop # stop server
$ cline server status # show server status
```

### Custom Collector
## Customize

### Custom collector

*collector* required `collect` method.

Expand All @@ -106,29 +145,27 @@ example:
```

Cline::Collectors::Base class provides `create_or_pass` method.
It create a new unique notification.
It create a new (unique) notification.

### Registration

in ~/.cline/config
In ~/.cline/config:

```ruby
require 'path/to/my_collector'

Cline.configure do |config|
# ...
config.append_collector MyCollector
config.collectors << MyCollector
end
```

## Notifier

`show` and `tick` command uses Cline's notifier.
Default notifier is STDOUT.
Default notifier is $stdout.

### Custom Notifyer

Cline's notifier required `puts` instance method.
Cline's notifier required `puts` method.

example:

Expand All @@ -140,9 +177,7 @@ example:
end
```

### Registration

in ~/.cline/config
In ~/.cline/config

```ruby
require 'path/to/my_notifier'
Expand Down
17 changes: 3 additions & 14 deletions bin/cline
Expand Up @@ -6,18 +6,7 @@ trap :INT do
exit
end

require_relative '../lib/cline'
require 'cline'

begin
Cline::Command.start
rescue Exception
Pathname.new("#{Cline.cline_dir}/log").open('a') do |f|
f.puts '---'
f.puts Time.now
f.puts $!.class
f.puts $!.message
f.puts $!.backtrace.join("\n")
end

raise $!
end
Cline.boot
Cline::Command.start
52 changes: 32 additions & 20 deletions cline.gemspec
@@ -1,4 +1,5 @@
# -*- encoding: utf-8 -*-

$:.push File.expand_path('../lib', __FILE__)
require 'cline/version'

Expand All @@ -8,31 +9,42 @@ Gem::Specification.new do |s|
s.authors = ['hibariya']
s.email = ['celluloid.key@gmail.com']
s.homepage = 'https://github.com/hibariya/cline'
s.summary = %q{CLI Line Notifier}
s.description = %q{Cline - CLI Line Notifier}
s.summary = %q{Show recently news on the terminal}
s.description = %q{Show recently news on the terminal.}

s.post_install_message = <<-EOM
**Important changes**
`tick` command usage has changed.
`cline tick OFFSET INTERVAL' -> `cline tick INTERVAL OFFSET'
#s.post_install_message = <<-EOM
#EOM
**Cline server is available**
Cline uses daemon process if it's running.
$ cline server start # start server
$ cline server stop # stop server
$ cline server reload # reload config file
EOM

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ['lib']

s.add_runtime_dependency 'thor', ['>= 0.14.6']
s.add_runtime_dependency 'activerecord', ['>= 3.1.1']
s.add_runtime_dependency 'sqlite3', ['>= 1.3.4']
s.add_runtime_dependency 'feedzirra', ['~> 0.0.31'] # FIXME builder dependency workaround...
s.add_runtime_dependency 'notify', ['>= 0.3.0']
s.add_runtime_dependency 'launchy', ['>= 2.1.0']

s.add_development_dependency 'rake', ['>= 0.9.2']
s.add_development_dependency 'ir_b', ['>= 1.4.0']
s.add_development_dependency 'tapp', ['>= 1.1.0']
s.add_development_dependency 'rspec', ['>= 2.6.0']
s.add_development_dependency 'rr', ['>= 1.0.4']
s.add_development_dependency 'fabrication', ['>= 1.2.0']
s.add_development_dependency 'fuubar', ['>= 0.0.6']
s.add_development_dependency 'simplecov', ['>= 0.5.3']
s.add_development_dependency 'activesupport', ['>= 3.1.1']
s.add_runtime_dependency 'thor', ['~> 0.16.0']
s.add_runtime_dependency 'activerecord', ['~> 3.1.8']
s.add_runtime_dependency 'sqlite3', ['~> 1.3.6']
s.add_runtime_dependency 'feedzirra', ['~> 0.1.3']
s.add_runtime_dependency 'notify', ['~> 0.4.0']
s.add_runtime_dependency 'launchy', ['~> 2.1.2']

s.add_development_dependency 'rake', ['~> 10.0.2']
s.add_development_dependency 'tapp', ['~> 1.4.0']
s.add_development_dependency 'rspec', ['~> 2.12.0']
s.add_development_dependency 'fabrication', ['~> 2.5.0']
s.add_development_dependency 'fuubar', ['~> 1.1.0']
s.add_development_dependency 'simplecov', ['~> 0.7.1']
s.add_development_dependency 'activesupport', ['~> 3.1.8']
end

0 comments on commit 8a90657

Please sign in to comment.