mailfire 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in mailfire.gemspec
4
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,49 @@
1
+ require 'tinder'
2
+
3
+ require "mailfire/version"
4
+
5
+ module Mailfire
6
+
7
+ class TextToRoom
8
+
9
+ attr_reader :campfire, :rooms
10
+ attr_accessor :config
11
+
12
+ def initialize(opts={})
13
+ @config = opts
14
+ if opts[:room]
15
+ @config[:rooms] = [opts[:room]]
16
+ end
17
+ @config[:rooms].map!(&:downcase)
18
+
19
+ raise ArgumentError, 'No :account provided' if @config[:account].nil?
20
+ raise ArgumentError, 'No :token provided' if @config[:token].nil?
21
+ if @config[:rooms].nil? or @config[:rooms].empty?
22
+ raise ArgumentError, 'No :room or :rooms provided'
23
+ end
24
+
25
+ connect_to_campfire
26
+ select_rooms
27
+ end
28
+
29
+ def connect_to_campfire
30
+ @campfire = Tinder::Campfire.new @config[:account], token: @config[:token]
31
+ end
32
+
33
+ def select_rooms
34
+ @rooms = @campfire.rooms.select do |room|
35
+ @config[:rooms].include? room.name.downcase
36
+ end
37
+ end
38
+
39
+ def deliver!(mail)
40
+ @rooms.each do |room|
41
+ room.speak "To: #{mail.to}, From: #{mail.from}"
42
+ room.speak mail.subject
43
+ room.paste mail.text_part.to_s
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,3 @@
1
+ module Mailfire
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "mailfire/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "mailfire"
7
+ s.version = Mailfire::VERSION
8
+ s.authors = ["ryanlower"]
9
+ s.email = ["ryan@academia.edu"]
10
+ s.homepage = "http://academia.edu"
11
+ s.summary = %q{Send mail to campfire rooms}
12
+ s.description = %q{Send mail to campfire rooms}
13
+
14
+ s.rubyforge_project = "mailfire"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency 'tinder'
24
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mailfire
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - ryanlower
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: tinder
16
+ requirement: &70136558638380 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70136558638380
25
+ description: Send mail to campfire rooms
26
+ email:
27
+ - ryan@academia.edu
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - lib/mailfire.rb
36
+ - lib/mailfire/version.rb
37
+ - mailfire.gemspec
38
+ homepage: http://academia.edu
39
+ licenses: []
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project: mailfire
58
+ rubygems_version: 1.8.6
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Send mail to campfire rooms
62
+ test_files: []