hut 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/hut +7 -0
- data/hut.gemspec +27 -0
- data/lib/hut.rb +39 -0
- data/lib/hut/cli.rb +4 -0
- data/lib/hut/config.rb +31 -0
- data/lib/hut/input.rb +15 -0
- data/lib/hut/message.rb +26 -0
- data/lib/hut/room.rb +49 -0
- data/lib/hut/version.rb +3 -0
- data/lib/hut/window.rb +54 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: dcdd8d84d7c94bbf554e953ba43dbd28e2dcc54d
|
4
|
+
data.tar.gz: e938bf4cc44f468c04edc76552b7dc749dfed595
|
5
|
+
!binary "U0hBNTEy":
|
6
|
+
metadata.gz: c86b85abbe4f7ba6536db8035457b3dfcdbf13869661200013b1964ffbf8a9ab01d1123ec056c6604c1dd8be33c4e45798beda0318819366eb4fad4b49f34b8f
|
7
|
+
data.tar.gz: 61688be7fa4a275f72b0263bb862b1f67f9d00be70213c6970bea44dfbfe17b5f75b519a0f90c6cb7ff69af2e6594f98e865621ec3d196ec2e0ab95d5968502b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ryan Lower
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Hut
|
2
|
+
|
3
|
+
Terminal campfire client
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hut'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hut
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/hut
ADDED
data/hut.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hut/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hut"
|
8
|
+
spec.version = Hut::VERSION
|
9
|
+
spec.authors = ["Ryan Lower"]
|
10
|
+
spec.email = ["rpjlower@gmail.com"]
|
11
|
+
spec.description = %q{Terminal campfire client}
|
12
|
+
spec.summary = %q{Terminal campfire client}
|
13
|
+
spec.homepage = "https://github.com/ryanlower/hut"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "highline"
|
22
|
+
spec.add_dependency "open4"
|
23
|
+
spec.add_dependency "tinder"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
data/lib/hut.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'hut/config'
|
2
|
+
require 'hut/cli'
|
3
|
+
require "hut/input"
|
4
|
+
require "hut/message"
|
5
|
+
require "hut/room"
|
6
|
+
require "hut/window"
|
7
|
+
require "hut/version"
|
8
|
+
|
9
|
+
module Hut
|
10
|
+
class Hut
|
11
|
+
require 'tinder'
|
12
|
+
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@config = Config.new
|
17
|
+
@window = Window.new self
|
18
|
+
@room = Room.new self, @config.rooms.first
|
19
|
+
end
|
20
|
+
|
21
|
+
def campfire
|
22
|
+
@campfire ||= Tinder::Campfire.new @config.account, token: @config.token
|
23
|
+
end
|
24
|
+
|
25
|
+
def me
|
26
|
+
@me ||= campfire.me
|
27
|
+
end
|
28
|
+
|
29
|
+
def listen
|
30
|
+
@window.room = @room
|
31
|
+
@room.window = @window
|
32
|
+
@room.listen
|
33
|
+
end
|
34
|
+
|
35
|
+
def new_message(room, msg)
|
36
|
+
Message.new self, room, msg
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/hut/cli.rb
ADDED
data/lib/hut/config.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Hut
|
2
|
+
class Config
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
if File.exists? config_path
|
7
|
+
@config = YAML.load_file config_path
|
8
|
+
else
|
9
|
+
raise 'config must be provided at ~/.hut'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def config_path
|
14
|
+
if ENV['HOME'] && File.directory?(ENV['HOME'])
|
15
|
+
File.expand_path '~/.hut'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def account
|
20
|
+
@config[:account]
|
21
|
+
end
|
22
|
+
|
23
|
+
def token
|
24
|
+
@config[:token]
|
25
|
+
end
|
26
|
+
|
27
|
+
def rooms
|
28
|
+
@config[:rooms]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/hut/input.rb
ADDED
data/lib/hut/message.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Hut
|
2
|
+
class Message
|
3
|
+
|
4
|
+
def initialize(hut, room, tinder_msg)
|
5
|
+
@me = hut.me
|
6
|
+
@room = room
|
7
|
+
@msg = tinder_msg
|
8
|
+
end
|
9
|
+
|
10
|
+
def formatted_for_print
|
11
|
+
"#{'* ' if by_me?}#{username}: #{body}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def by_me?
|
15
|
+
@me.id == @msg.user.id
|
16
|
+
end
|
17
|
+
|
18
|
+
def username
|
19
|
+
@msg.user.name
|
20
|
+
end
|
21
|
+
|
22
|
+
def body
|
23
|
+
@msg.body
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/hut/room.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Hut
|
2
|
+
class Room
|
3
|
+
|
4
|
+
attr_reader :name
|
5
|
+
|
6
|
+
def initialize(hut, room_name)
|
7
|
+
@hut = hut
|
8
|
+
@name = room_name
|
9
|
+
@room = @hut.campfire.rooms.select do |room|
|
10
|
+
room.name.downcase == room_name
|
11
|
+
end.first
|
12
|
+
@messages = []
|
13
|
+
get_recent_messages
|
14
|
+
end
|
15
|
+
|
16
|
+
def window=(window)
|
17
|
+
@window = window
|
18
|
+
end
|
19
|
+
|
20
|
+
def listen
|
21
|
+
@room.listen do |msg|
|
22
|
+
add_message msg
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def new_message(body)
|
27
|
+
@room.speak body
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_message(msg)
|
31
|
+
if msg.body
|
32
|
+
@messages << @hut.new_message(self, msg)
|
33
|
+
@window.room_was_updated(self) if @window
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def last_messages(num)
|
38
|
+
@messages.last(num)
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_recent_messages
|
42
|
+
# Room#recent calls Time.parse
|
43
|
+
require 'time'
|
44
|
+
@room.recent.each do |msg|
|
45
|
+
add_message msg
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/hut/version.rb
ADDED
data/lib/hut/window.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
module Hut
|
2
|
+
class Window
|
3
|
+
require 'highline'
|
4
|
+
|
5
|
+
def initialize(hut)
|
6
|
+
@out = $stdout
|
7
|
+
@columns, @lines = HighLine::SystemExtensions.terminal_size
|
8
|
+
@room = nil
|
9
|
+
@input = Input.new self
|
10
|
+
end
|
11
|
+
|
12
|
+
def room=(room)
|
13
|
+
@room = room
|
14
|
+
update
|
15
|
+
end
|
16
|
+
|
17
|
+
def update
|
18
|
+
clear
|
19
|
+
print_header
|
20
|
+
@room.last_messages(@lines - 4).each do |msg|
|
21
|
+
@out.print "#{msg.formatted_for_print}\n"
|
22
|
+
end
|
23
|
+
@out.flush
|
24
|
+
print_footer
|
25
|
+
end
|
26
|
+
|
27
|
+
def room_was_updated(room)
|
28
|
+
if room == @room
|
29
|
+
update
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def new_message(body)
|
34
|
+
@room.new_message body
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def clear
|
40
|
+
@out.print "\e[2J\e[f"
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_header
|
44
|
+
@out.print "#{@room.name}\n"
|
45
|
+
@out.print "#{'-' * @columns}\n"
|
46
|
+
@out.flush
|
47
|
+
end
|
48
|
+
|
49
|
+
def print_footer
|
50
|
+
@out.print "#{'-' * @columns}\n"
|
51
|
+
@out.print ">"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hut
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Lower
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: highline
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: open4
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: tinder
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Terminal campfire client
|
84
|
+
email:
|
85
|
+
- rpjlower@gmail.com
|
86
|
+
executables:
|
87
|
+
- hut
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- Gemfile
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/hut
|
97
|
+
- hut.gemspec
|
98
|
+
- lib/hut.rb
|
99
|
+
- lib/hut/cli.rb
|
100
|
+
- lib/hut/config.rb
|
101
|
+
- lib/hut/input.rb
|
102
|
+
- lib/hut/message.rb
|
103
|
+
- lib/hut/room.rb
|
104
|
+
- lib/hut/version.rb
|
105
|
+
- lib/hut/window.rb
|
106
|
+
homepage: https://github.com/ryanlower/hut
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.3
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Terminal campfire client
|
130
|
+
test_files: []
|
131
|
+
has_rdoc:
|