fat_free_wunderlist 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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm use 1.9.2
2
+ rvm gemset use fat_free_wunderlist
@@ -0,0 +1,3 @@
1
+ ## v0.0.1
2
+
3
+ * initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fat_free_wunderlist.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Johnathan Pulos
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # Fat Free Wunderlist
2
+
3
+ **This gem can only be used on an existing [Fat Free CRM](http://www.fatfreecrm.com/) application**
4
+
5
+ Using an after_filter on the Task controller, this gem will send your task to your existing Wunderlist account. It sends the task using Action Mailer (email) directly to your Wunderlist inbox or a specific list. Wunderlist allows posting tasks through emails, and the process is described on this [blog post](http://blog.wunderlist.com/post/6521016265/secret-features-part-3-add-tasks-via-mail).
6
+
7
+ # Features
8
+
9
+ Here are some of the features in this release:
10
+
11
+ * Important Tasks - Tasks due "As Soon As Possible" or "Today" will be flagged as important.
12
+ * User Specific - Each user can use their Wunderlist account.
13
+ * Post to a List - Just supply the list in the initializer file, and all tasks will be added to that list.
14
+ * Flags Assets - If the task involves an account, contact, opportunity, etc, then the asset name and type is added to the Wunderlist todo.
15
+
16
+ ## Limitations
17
+
18
+ Since we are using the email approach, you will not be able to update or delete tasks added to your Wunderlist account through your Fat Free CRM. You will need to manage them in your Wunderlist account. Also, this gem only supports one Wunderlist account and list per user.
19
+
20
+ ## Requirements
21
+
22
+ Requirements for this release:
23
+
24
+ * Ruby 1.9.2 or later.
25
+ * Rails 3.0 or later.
26
+ * Fat Free CRM 10.0 or later.
27
+ * A Wunderlist Account
28
+
29
+ ## Installation
30
+
31
+ Note: Before installing, please make sure you setup Action Mailer in your Fat Free CRM application. You can find more information at [RailsCast.com](http://railscasts.com/episodes/206-action-mailer-in-rails-3).
32
+
33
+ Add the gem to your Gemfile and run the `bundle` command to install it.
34
+
35
+ ```ruby
36
+ gem 'fat_free_wunderlist', :git => 'git@github.com:codemis/fat_free_wunderlist.git'
37
+ ```
38
+
39
+ Run the generator for Fat Free Wunderlist:
40
+
41
+ ```ruby
42
+ rails generate fat_free_wunderlist:install
43
+ ```
44
+
45
+ Now change the settings in config/initializers/fat\_free\_wunderlist.rb file that was generated. The Hash is keyed to the User.id for the specific user.
46
+
47
+ ```ruby
48
+ FatFreeWunderlist.options.merge!(
49
+ 1 => {
50
+ :wunderlist_email => '',
51
+ :wunderlist_list => ''
52
+ }
53
+ )
54
+ ```
55
+ Here are your options:
56
+
57
+ * wunderlist_email - the email address used on your Wunderlist account **Required**
58
+ * wunderlist_list - the list you want to add all tasks to. If you leave it empty, it will be delivered in your inbox
59
+
60
+ ## Links
61
+
62
+ - [Fat Free CRM](http://www.fatfreecrm.com/)
63
+ - [Wunderlist](http://www.wunderlist.com/)
64
+
65
+ ## Development
66
+
67
+ Questions or problems? Please post them on the [issue tracker](https://github.com/codemis/fat_free_wunderlist/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running `bundle` and `rspec`.
68
+
69
+ This gem is created by Johnathan Pulos and is under the MIT License.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ # make sure to require mail gem
2
+ class WunderlistMailer < ActionMailer::Base
3
+
4
+ # Email the task to Wunderlist and set its importance
5
+ #
6
+ def email_task(task, options)
7
+ mail_options = {:to => "me@wunderlist.com"}
8
+ mail_options[:subject] = options.has_key?(:wunderlist_list) ? options[:wunderlist_list] : ''
9
+ mail_options[:from] = options[:wunderlist_email]
10
+ @task = task
11
+ @task.name = @task.asset_type.empty? ? @task.name : "#{@task.name} for #{@task.asset.name} (#{@task.asset_type.downcase})"
12
+ @important_marker = ['due_asap', 'due_today'].include?(@task.bucket) ? '*' : ''
13
+ mail(mail_options)
14
+ end
15
+
16
+ end
@@ -0,0 +1 @@
1
+ <%= @important_marker %><%= @task.name %>
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize!
7
+ run Combustion::Application
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "fat_free_wunderlist/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "fat_free_wunderlist"
7
+ s.version = FatFreeWunderlist::VERSION
8
+ s.authors = ["Codemis"]
9
+ s.email = ["johnathan@still-water.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Sends Fat Free CRM tasks to Wunderlist To Do Manager}
12
+ s.description = %q{Using Action Mailer, gem sends all tasks from Fat Free CRM to your Wunderlist account.}
13
+
14
+ s.rubyforge_project = "fat_free_wunderlist"
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 "mail"
24
+ s.add_development_dependency "rails"
25
+ s.add_development_dependency "actionmailer"
26
+ s.add_development_dependency "rspec"
27
+ s.add_development_dependency "rspec-rails"
28
+ s.add_development_dependency 'combustion', '~> 0.3.1'
29
+ s.add_development_dependency 'sqlite3'
30
+ s.add_development_dependency 'factory_girl'
31
+ end
@@ -0,0 +1,17 @@
1
+ require "fat_free_wunderlist/version"
2
+ require "fat_free_wunderlist/controller_additions"
3
+ require "fat_free_wunderlist/railtie" if defined? Rails && Rails::VERSION::MAJOR == 3
4
+ # require the engine if rails is defined
5
+ require 'fat_free_wunderlist/engine' if defined? Rails && Rails::VERSION::MAJOR == 3
6
+
7
+ module FatFreeWunderlist
8
+
9
+ # Set options for the wunderlist email. Here are the options:
10
+ # wunderlist_email: The email used in wunderlist. This is required in order for this to work.
11
+ # wunderlist_list: The list to add the task to. If you leave it blank, it will add it to your inbox
12
+ #
13
+ def self.options
14
+ @options ||= {}
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ module FatFreeWunderlist
2
+ module ControllerAdditions
3
+
4
+ # Send a mailer if we are creating a task
5
+ #
6
+ def send_mailer
7
+ if FatFreeWunderlist.options.empty?
8
+ logger.info "ERROR: Fat Free Wunderlist Gem: Please edit the settings in config/initializers/fat_free_wunderlist.rb in order to use this gem."
9
+ else
10
+ WunderlistMailer.email_task(@task, FatFreeWunderlist.options[@task.user.id]).deliver if send_mailer_now?
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ # check if it is the task#create action
17
+ #
18
+ def send_mailer_now?
19
+ (params[:controller] == 'tasks' and params[:action] == 'create' and FatFreeWunderlist.options.has_key?(@task.user.id)) ? true : false
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ module FatFreeWunderlist
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ module FatFreeWunderlist
2
+ class Railtie < Rails::Railtie
3
+
4
+ initializer 'FatFreeWunderlist.controller_additions' do
5
+ ActionController::Base.send :include, FatFreeWunderlist::ControllerAdditions
6
+ ActionController::Base.send :after_filter, :send_mailer
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module FatFreeWunderlist
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ require 'rails'
2
+
3
+ module FatFreeWunderlist
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ desc "Creates an intializer file for configuring settings in the Fat Free Wunderlist Gem."
7
+
8
+ def self.source_root
9
+ @_fat_free_wunderlist_source_root ||= File.expand_path("../templates", __FILE__)
10
+ end
11
+
12
+ # Copy the initializer file from templates to the Rails intializer directory
13
+ #
14
+ def copy_initializer
15
+ copy_file "fat_free_wunderlist.rb", "config/initializers/fat_free_wunderlist.rb"
16
+ puts "Please edit the settings in config/initializers/fat_free_wunderlist.rb."
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ # The key for each setting is the User.id from Fat Free CRM
2
+ # wunderlist_email - the email address used on your Wunderlist account **Required**
3
+ # wunderlist_list - the list you want to add all tasks to. If you leave it empty, it will be delivered in your inbox
4
+ FatFreeWunderlist.options.merge!(
5
+ 1 => {
6
+ :wunderlist_email => '',
7
+ :wunderlist_list => ''
8
+ }
9
+ )
Binary file
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe WunderlistMailer do
5
+
6
+ describe "#email_task" do
7
+
8
+ before(:each) do
9
+ @task = FactoryGirl.create(:task)
10
+ @options = {:wunderlist_email => 'johnathan@jpulos.com', :wunderlist_list => ''}
11
+ end
12
+
13
+ it "should render successfully" do
14
+ lambda { WunderlistMailer.email_task(@task, @options) }.should_not raise_error
15
+ end
16
+
17
+ end
18
+
19
+ describe "email structure" do
20
+
21
+ before(:each) do
22
+ @task = FactoryGirl.create(:task)
23
+ @options = {:wunderlist_email => 'johnathan@jpulos.com', :wunderlist_list => 'My Unique List'}
24
+ end
25
+
26
+ it "sends an e-mail to wunderlist" do
27
+ mail = WunderlistMailer.email_task(@task, @options)
28
+ mail.to.should == ['me@wunderlist.com']
29
+ end
30
+
31
+ it "should set the subject based on the option" do
32
+ @options[:wunderlist_list] = 'The Correct Subject'
33
+ mail = WunderlistMailer.email_task(@task, @options)
34
+ mail.subject.should == @options[:wunderlist_list]
35
+ end
36
+
37
+ it "should set the subject based on the option even blank" do
38
+ @options[:wunderlist_list] = ''
39
+ mail = WunderlistMailer.email_task(@task, @options)
40
+ mail.subject.should == nil
41
+ end
42
+
43
+ it "should have the task name as the body" do
44
+ mail = WunderlistMailer.email_task(@task, @options)
45
+ mail.body.should == "*#{@task.name}"
46
+ end
47
+
48
+ it "should add an astericks if bucket is due_asap" do
49
+ task = FactoryGirl.create(:task, {:bucket => 'due_asap', :name => 'My Test'})
50
+ mail = WunderlistMailer.email_task(task, @options)
51
+ mail.body.should == "*#{task.name}"
52
+ end
53
+
54
+ it "should add an astericks if bucket is due_today" do
55
+ task = FactoryGirl.create(:task, {:bucket => 'due_today', :name => 'My Test'})
56
+ mail = WunderlistMailer.email_task(task, @options)
57
+ mail.body.should == "*#{task.name}"
58
+ end
59
+
60
+ it "should not add an astericks if bucket is due_tomorrow" do
61
+ task = FactoryGirl.create(:task, {:bucket => 'due_tomorrow', :name => 'My Test'})
62
+ mail = WunderlistMailer.email_task(task, @options)
63
+ mail.body.should == "#{task.name}"
64
+ end
65
+
66
+ it "should add contact info if it exists" do
67
+ contact = FactoryGirl.create(:contact)
68
+ task = FactoryGirl.create(:task, {:bucket => 'due_tomorrow', :name => 'My Test', :asset => contact, :asset_type => 'Contact'})
69
+ expected = "#{task.name} for #{contact.name} (#{task.asset_type.downcase})"
70
+ mail = WunderlistMailer.email_task(task, @options)
71
+ mail.body.should == expected
72
+ end
73
+
74
+ it "should not add contact info if it is missing" do
75
+ task = FactoryGirl.create(:task, {:bucket => 'due_tomorrow', :name => 'My Test'})
76
+ mail = WunderlistMailer.email_task(task, @options)
77
+ mail.body.should_not include("for")
78
+ end
79
+
80
+ end
81
+
82
+ end
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+ factory :task do
3
+ name "A New Task"
4
+ bucket 'due_asap'
5
+ asset_type ''
6
+ end
7
+
8
+ factory :contact do
9
+ name 'My Special Name'
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ class Contact < ActiveRecord::Base
2
+ has_many :tasks, :as => :asset
3
+ end
@@ -0,0 +1,3 @@
1
+ class Task < ActiveRecord::Base
2
+ belongs_to :asset, :polymorphic => true
3
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,13 @@
1
+ ActiveRecord::Schema.define do
2
+ create_table(:tasks, :force => true) do |t|
3
+ t.string :name
4
+ t.string :bucket
5
+ t.string :asset_id
6
+ t.string :asset_type
7
+ t.timestamps
8
+ end
9
+ create_table(:contacts, :force => true) do |t|
10
+ t.string :name
11
+ t.timestamps
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'rails'
3
+ require 'fat_free_wunderlist'
4
+ require 'bundler'
5
+ require 'factory_girl'
6
+
7
+ Bundler.require :default, :development
8
+
9
+ Combustion.initialize!
10
+
11
+ require 'rspec/rails'
12
+ FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
13
+ FactoryGirl.find_definitions
14
+
15
+ ActionMailer::Base.delivery_method = :test
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fat_free_wunderlist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Codemis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-14 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mail
16
+ requirement: &70290387600320 !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: *70290387600320
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &70290387599900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70290387599900
36
+ - !ruby/object:Gem::Dependency
37
+ name: actionmailer
38
+ requirement: &70290387599480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70290387599480
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70290387599060 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70290387599060
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec-rails
60
+ requirement: &70290387598640 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70290387598640
69
+ - !ruby/object:Gem::Dependency
70
+ name: combustion
71
+ requirement: &70290387598140 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 0.3.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70290387598140
80
+ - !ruby/object:Gem::Dependency
81
+ name: sqlite3
82
+ requirement: &70290387597720 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70290387597720
91
+ - !ruby/object:Gem::Dependency
92
+ name: factory_girl
93
+ requirement: &70290387597260 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70290387597260
102
+ description: Using Action Mailer, gem sends all tasks from Fat Free CRM to your Wunderlist
103
+ account.
104
+ email:
105
+ - johnathan@still-water.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - .gitignore
111
+ - .rspec
112
+ - .rvmrc
113
+ - CHANGELOG.md
114
+ - Gemfile
115
+ - LICENSE
116
+ - README.md
117
+ - Rakefile
118
+ - app/mailers/wunderlist_mailer.rb
119
+ - app/views/wunderlist_mailer/email_task.text.erb
120
+ - config.ru
121
+ - fat_free_wunderlist.gemspec
122
+ - lib/fat_free_wunderlist.rb
123
+ - lib/fat_free_wunderlist/controller_additions.rb
124
+ - lib/fat_free_wunderlist/engine.rb
125
+ - lib/fat_free_wunderlist/railtie.rb
126
+ - lib/fat_free_wunderlist/version.rb
127
+ - lib/generators/fat_free_wunderlist/install/install_generator.rb
128
+ - lib/generators/fat_free_wunderlist/install/templates/fat_free_wunderlist.rb
129
+ - spec/.DS_Store
130
+ - spec/app/mailers/wunderlist_mailer_spec.rb
131
+ - spec/factories/factories.rb
132
+ - spec/internal/app/models/contact.rb
133
+ - spec/internal/app/models/task.rb
134
+ - spec/internal/config/database.yml
135
+ - spec/internal/config/routes.rb
136
+ - spec/internal/db/combustion_test.sqlite
137
+ - spec/internal/db/schema.rb
138
+ - spec/internal/log/.gitignore
139
+ - spec/internal/public/favicon.ico
140
+ - spec/spec_helper.rb
141
+ homepage: ''
142
+ licenses: []
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ requirements: []
160
+ rubyforge_project: fat_free_wunderlist
161
+ rubygems_version: 1.8.17
162
+ signing_key:
163
+ specification_version: 3
164
+ summary: Sends Fat Free CRM tasks to Wunderlist To Do Manager
165
+ test_files:
166
+ - spec/app/mailers/wunderlist_mailer_spec.rb
167
+ - spec/factories/factories.rb
168
+ - spec/internal/app/models/contact.rb
169
+ - spec/internal/app/models/task.rb
170
+ - spec/internal/config/database.yml
171
+ - spec/internal/config/routes.rb
172
+ - spec/internal/db/combustion_test.sqlite
173
+ - spec/internal/db/schema.rb
174
+ - spec/internal/log/.gitignore
175
+ - spec/internal/public/favicon.ico
176
+ - spec/spec_helper.rb