facteur 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,4 +19,5 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
- spec/db/.*
22
+ spec/db/.*
23
+ *.gemspec
data/README.markdown ADDED
@@ -0,0 +1,113 @@
1
+ # facteur #
2
+
3
+ Facteur allows you to add an email-like messaging system in your Rails 3 application. You can create many mailboxes for your users where they will be able to send and receive messages.
4
+
5
+ ## Installation ##
6
+
7
+ Just run the following command :
8
+
9
+ gem install facteur
10
+
11
+ Then in your Gemfile add the following line :
12
+
13
+ gem 'facteur'
14
+
15
+ ## Usage ##
16
+
17
+ First install the messaging system in your application :
18
+
19
+ rails generate facteur:install
20
+
21
+ This commands create two new models called __mailbox__ and __message__ in *'app/models'* (in the future the names will be changeable):
22
+
23
+ class Mailbox < ActiveRecord::Base
24
+ include Facteur::MailboxModel
25
+ end
26
+
27
+ class Message < ActiveRecord::Base
28
+ include Facteur::MessageModel
29
+ end
30
+
31
+ It also creates the migrations for the new models so don't forget to migrate your database :
32
+
33
+ rake db:migrate
34
+
35
+ Then to activate __facteur__ in your user model, just include the addressee's model as follows :
36
+
37
+ class User < ActiveRecord::Base
38
+ include Facteur::AddresseeModel
39
+ end
40
+
41
+ You model must be named 'User'. This will be changed in the future.
42
+
43
+ ## Messaging system ##
44
+
45
+ ### Creating mailboxes ###
46
+
47
+ In the facteur's system, each user must have a mailbox where he can receive messages. The mailboxes can be declared statically and/or dynamically. Let's start first by the static way :
48
+
49
+ class User < ActiveRecord::Base
50
+ include Facteur::AddresseeModel
51
+
52
+ mailbox :private_mailbox, :default => true
53
+ mailbox :public_mailbox
54
+ end
55
+
56
+ The previous example declare two mailboxes that will be created for each user. The mailboxes are created just after the user was created itself. Facteur generates for you two methods to access your mailboxes :
57
+
58
+ # assuming that 'login' and 'password' are fields defined for the User model
59
+ @john = User.create(:login => 'john', :password => 'pass')
60
+
61
+ # Now, the mailboxes exist and they can be accessed
62
+ @john.private_mailbox #=> returns the private mailbox
63
+ @john.public_mailbox #=> returns the public mailbox
64
+
65
+ # To check the mailboxes which where defined
66
+ User.mailboxes #=> [{:name=>:private_mailbox, :default=>true}, {:name=>:public_mailbox}]
67
+
68
+ It is also possible to create a mailbox dynamically. This mailbox will not be available to all the user but only to the user who created it :
69
+
70
+ @john.create_mailbox(:new_mailbox) #=> true
71
+ User.mailboxes #=> [{:name=>:private_mailbox, :default=>true}, {:name=>:public_mailbox}]
72
+
73
+ After the previous example, the "news\_mailbox" is only avalaible to John. The names of the mailboxes must be unique. if you try to create a mailbox which already exists, the create_mailbox() method will return false.
74
+
75
+ ### Sending messages ###
76
+
77
+ It is possible to send a message to one or many user :
78
+
79
+ @peter = User.create(:login => 'peter', :password => 'pass')
80
+ @mary = User.create(:login => 'mary', :password => 'pass')
81
+
82
+ @john.send_message('hello', :to => @peter, :in => :private_mailbox)
83
+ @john.send_message('hello', :to => [@peter, @mary], :in => :public_mailbox)
84
+
85
+ The 'in' option is not mandatory. If it is not given, the message is delivered to the default mailbox. If there is no default mailbox defined then the method fails.
86
+
87
+ You can access the messages in a mailbox :
88
+
89
+ @peter.private_mailbox.messages
90
+
91
+ To list the messages sent by a user :
92
+
93
+ @john.messages_sent
94
+
95
+ ## Testing the gem ##
96
+
97
+ It is possible to test facteur by running the following command from the gem directory:
98
+
99
+ rake spec
100
+
101
+ ## Note on Patches/Pull Requests ##
102
+
103
+ * Fork the project.
104
+ * Make your feature addition or bug fix.
105
+ * Add tests for it. This is important so I don't break it in a
106
+ future version unintentionally.
107
+ * Commit, do not mess with rakefile, version, or history.
108
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
109
+ * Send me a pull request. Bonus points for topic branches.
110
+
111
+ ## Copyright ##
112
+
113
+ Copyright (c) 2010 Rawane ZOSSOU. See LICENSE for details.
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "facteur"
8
- gem.summary = "Messages managment system for Rails 3"
9
- gem.description = "Facteur allows you add a messages management system in your Rails 3. You can create many mailboxes for your users. They will be able to send and receive messages."
8
+ gem.summary = "Messaging system for Rails 3"
9
+ gem.description = "Facteur allows you add a messaging system in your Rails 3. You can create many mailboxes for your users. They will be able to send and receive messages."
10
10
  gem.email = "dev@raw1z.fr"
11
11
  gem.homepage = "http://github.com/raw1z/facteur"
12
12
  gem.authors = ["Rawane ZOSSOU"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -0,0 +1,29 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Facteur
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ desc "Generate the facteur's message and mailbox models"
10
+
11
+ def self.source_root
12
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
13
+ end
14
+
15
+ def self.next_migration_number
16
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
17
+ end
18
+
19
+ def create_facteur_files
20
+ template 'message.rb', 'app/models/message.rb'
21
+ template 'create_messages.rb', "db/migrate/#{self.class.next_migration_number}_create_messages.rb"
22
+
23
+ sleep(1)
24
+ template 'mailbox.rb', 'app/models/mailbox.rb'
25
+ template 'create_mailboxes.rb', "db/migrate/#{self.class.next_migration_number}_create_mailboxes.rb"
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ class CreateMailboxes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :mailboxes do |t|
4
+ t.string :name
5
+ t.text :contents
6
+ t.integer :addressee_id
7
+ t.string :addressee_type
8
+ t.boolean :default
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :mailboxes
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ class CreateMessages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :messages do |t|
4
+ t.string :subject
5
+ t.text :body
6
+ t.integer :mailbox_id
7
+ t.integer :author_id
8
+ t.boolean :deleted_by_author, :default => false
9
+ t.datetime :deleted_by_author_at
10
+ t.boolean :deleted_by_addressee, :default => false
11
+ t.datetime :deleted_by_addressee_at
12
+ t.boolean :read, :default => false
13
+ end
14
+ end
15
+
16
+ def self.down
17
+ drop_table :messages
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ class Mailbox < ActiveRecord::Base
2
+ include Facteur::MailboxModel
3
+ end
@@ -0,0 +1,3 @@
1
+ class Message < ActiveRecord::Base
2
+ include Facteur::MessageModel
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facteur
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rawane ZOSSOU
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-10 00:00:00 +02:00
18
+ date: 2010-06-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: 1.2.9
35
35
  type: :development
36
36
  version_requirements: *id001
37
- description: Facteur allows you add a messages management system in your Rails 3. You can create many mailboxes for your users. They will be able to send and receive messages.
37
+ description: Facteur allows you add a messaging system in your Rails 3. You can create many mailboxes for your users. They will be able to send and receive messages.
38
38
  email: dev@raw1z.fr
39
39
  executables: []
40
40
 
@@ -42,18 +42,23 @@ extensions: []
42
42
 
43
43
  extra_rdoc_files:
44
44
  - LICENSE
45
- - README.rdoc
45
+ - README.markdown
46
46
  files:
47
47
  - .document
48
48
  - .gitignore
49
49
  - LICENSE
50
- - README.rdoc
50
+ - README.markdown
51
51
  - Rakefile
52
52
  - VERSION
53
53
  - lib/facteur.rb
54
54
  - lib/facteur/addressee_model.rb
55
55
  - lib/facteur/mailbox_model.rb
56
56
  - lib/facteur/message_model.rb
57
+ - lib/generators/facteur/install/install_generator.rb
58
+ - lib/generators/facteur/install/templates/create_mailboxes.rb
59
+ - lib/generators/facteur/install/templates/create_messages.rb
60
+ - lib/generators/facteur/install/templates/mailbox.rb
61
+ - lib/generators/facteur/install/templates/message.rb
57
62
  - spec/db/database.log
58
63
  - spec/db/facteur.sqlite3.db
59
64
  - spec/facteur_spec.rb
@@ -91,7 +96,7 @@ rubyforge_project:
91
96
  rubygems_version: 1.3.7
92
97
  signing_key:
93
98
  specification_version: 3
94
- summary: Messages managment system for Rails 3
99
+ summary: Messaging system for Rails 3
95
100
  test_files:
96
101
  - spec/facteur_spec.rb
97
102
  - spec/spec_helper.rb
data/README.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = facteur
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Rawane ZOSSOU. See LICENSE for details.