cinch-notes 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +7 -0
- data/cinch-notes.gemspec +30 -0
- data/lib/cinch-notes.rb +4 -0
- data/lib/cinch/plugins/notes.rb +43 -0
- data/lib/cinch/plugins/notes/note.rb +25 -0
- data/lib/cinch/plugins/notes/version.rb +9 -0
- data/spec/cinch-notes_spec.rb +22 -0
- data/spec/spec_helper.rb +11 -0
- metadata +190 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brian Haberer
|
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,35 @@
|
|
1
|
+
# Cinch::Plugins::Notes
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cinch-notes.png)](http://badge.fury.io/rb/cinch-notes)
|
4
|
+
[![Dependency Status](https://gemnasium.com/bhaberer/cinch-notes.png)](https://gemnasium.com/bhaberer/cinch-notes)
|
5
|
+
[![Build Status](https://travis-ci.org/bhaberer/cinch-notes.png?branch=master)](https://travis-ci.org/bhaberer/cinch-notes)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/bhaberer/cinch-notes/badge.png?branch=master)](https://coveralls.io/r/bhaberer/cinch-notes?branch=master)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/bhaberer/cinch-notes.png)](https://codeclimate.com/github/bhaberer/cinch-notes)
|
8
|
+
|
9
|
+
Cinch plugin to allow users to leave notes for one another.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'cinch-notes'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install cinch-notes
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/cinch-notes.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cinch/plugins/notes/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cinch-notes"
|
8
|
+
spec.version = Cinch::Plugins::Notes::VERSION
|
9
|
+
spec.authors = ["Brian Haberer"]
|
10
|
+
spec.email = ["bhaberer@gmail.com"]
|
11
|
+
spec.description = %q{A cinch plugin to allow leaving other users notes.}
|
12
|
+
spec.summary = %q{Cinch Notes Plugin}
|
13
|
+
spec.homepage = "https://github.com/bhaberer/cinch-note"
|
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_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency 'coveralls'
|
25
|
+
spec.add_development_dependency 'cinch-test'
|
26
|
+
|
27
|
+
spec.add_dependency 'cinch'
|
28
|
+
spec.add_dependency 'cinch-toolbox'
|
29
|
+
spec.add_dependency 'cinch-storage'
|
30
|
+
end
|
data/lib/cinch-notes.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'cinch'
|
3
|
+
require 'cinch-storage'
|
4
|
+
|
5
|
+
module Cinch::Plugins
|
6
|
+
# Cinch Plugin to send notes
|
7
|
+
class Notes
|
8
|
+
include Cinch::Plugin
|
9
|
+
|
10
|
+
listen_to :channel, method: :send_notes
|
11
|
+
|
12
|
+
set prefix: ''
|
13
|
+
|
14
|
+
match /\Atell (\w+) (.+)/, react_on: :private,
|
15
|
+
method: :make_note
|
16
|
+
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
@storage = CinchStorage.new(config[:filename] || 'yaml/notes.yml')
|
20
|
+
@storage.data ||= {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def make_note(m, user, message)
|
24
|
+
note = Note.new(m.user.nick, user, message)
|
25
|
+
@storage.data[user.downcase] ||= []
|
26
|
+
@storage.data[user.downcase] << note
|
27
|
+
@storage.synced_save(@bot)
|
28
|
+
m.reply 'ok, I will let them know!'
|
29
|
+
end
|
30
|
+
|
31
|
+
def send_notes(m)
|
32
|
+
nick = m.user.nick.downcase
|
33
|
+
if @storage.data.key?(nick)
|
34
|
+
@storage.data[nick].each do |note|
|
35
|
+
unless note.sent
|
36
|
+
m.user.send("#{note.from} asked me to tell you '#{note.message}'")
|
37
|
+
note.mark_sent
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Cinch::Plugins
|
3
|
+
class Notes
|
4
|
+
# Object to store note information
|
5
|
+
class Note
|
6
|
+
attr_accessor :from, :to, :message, :time, :sent
|
7
|
+
|
8
|
+
def initialize(from, to, message)
|
9
|
+
@from = from
|
10
|
+
@to = to
|
11
|
+
@message = message
|
12
|
+
@sent = false
|
13
|
+
@time = Time.now
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_yaml
|
17
|
+
{ from: from, to: to, message: message, time: time, sent: sent }
|
18
|
+
end
|
19
|
+
|
20
|
+
def mark_sent
|
21
|
+
@sent = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cinch::Plugins::Notes do
|
4
|
+
include Cinch::Test
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@bot = make_bot(Cinch::Plugins::Notes, { filename: '/tmp/notes.yml' })
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'handling hangout links' do
|
11
|
+
it 'should accept a message to give to someone later' do
|
12
|
+
get_replies(make_message(@bot, 'tell foo bar'), :private).first.text.
|
13
|
+
should == "ok, I will let them know!"
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should send the message when someone talks later' do
|
17
|
+
get_replies(make_message(@bot, 'tell joe bar'), :private)
|
18
|
+
get_replies(make_message(@bot, 'hi', { nick: 'joe', channel: '#foo' })).first.text.
|
19
|
+
should == "test asked me to tell you 'bar'"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cinch-notes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brian Haberer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: coveralls
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cinch-test
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: cinch
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '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: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: cinch-toolbox
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: cinch-storage
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
description: A cinch plugin to allow leaving other users notes.
|
143
|
+
email:
|
144
|
+
- bhaberer@gmail.com
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- .gitignore
|
150
|
+
- .travis.yml
|
151
|
+
- Gemfile
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.md
|
154
|
+
- Rakefile
|
155
|
+
- cinch-notes.gemspec
|
156
|
+
- lib/cinch-notes.rb
|
157
|
+
- lib/cinch/plugins/notes.rb
|
158
|
+
- lib/cinch/plugins/notes/note.rb
|
159
|
+
- lib/cinch/plugins/notes/version.rb
|
160
|
+
- spec/cinch-notes_spec.rb
|
161
|
+
- spec/spec_helper.rb
|
162
|
+
homepage: https://github.com/bhaberer/cinch-note
|
163
|
+
licenses:
|
164
|
+
- MIT
|
165
|
+
post_install_message:
|
166
|
+
rdoc_options: []
|
167
|
+
require_paths:
|
168
|
+
- lib
|
169
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
+
none: false
|
171
|
+
requirements:
|
172
|
+
- - ! '>='
|
173
|
+
- !ruby/object:Gem::Version
|
174
|
+
version: '0'
|
175
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
requirements: []
|
182
|
+
rubyforge_project:
|
183
|
+
rubygems_version: 1.8.25
|
184
|
+
signing_key:
|
185
|
+
specification_version: 3
|
186
|
+
summary: Cinch Notes Plugin
|
187
|
+
test_files:
|
188
|
+
- spec/cinch-notes_spec.rb
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
has_rdoc:
|