facteur 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.2.0
@@ -89,7 +89,7 @@ module Facteur
89
89
  mailbox.default = options[:default]
90
90
  return false if mailbox.save == false
91
91
 
92
- @default_mailbox = name if options[:default]
92
+ @default_mailbox = name if options[:default]
93
93
  true
94
94
  end
95
95
 
@@ -101,15 +101,23 @@ module Facteur
101
101
  self.send "#{name}"
102
102
  end
103
103
 
104
+ # generates the mailboxes accessors
104
105
  def method_missing(method, *args, &block)
105
- mailboxes = self.class.mailboxes.map{ |mailbox| mailbox[:name] }
106
+ # mailboxes = self.class.mailboxes.map{ |mailbox| mailbox[:name] }
107
+ #
108
+ # if mailboxes.include?(method)
109
+ # mailbox = Mailbox.find(:first, :conditions => {:name => method.to_s, :addressee_id => self.attributes["id"], :addressee_type => self.class.to_s})
110
+ # return mailbox unless mailbox.nil?
111
+ # end
106
112
 
107
- if mailboxes.include?(method)
113
+ begin
114
+ super
115
+ rescue NoMethodError
108
116
  mailbox = Mailbox.find(:first, :conditions => {:name => method.to_s, :addressee_id => self.attributes["id"], :addressee_type => self.class.to_s})
109
- return mailbox if not mailbox.nil?
117
+ return mailbox unless mailbox.nil?
118
+ super
110
119
  end
111
120
 
112
- super
113
121
  end
114
122
 
115
123
  private
@@ -0,0 +1,13 @@
1
+ def obtain_class
2
+ class_name = ENV['CLASS'] || ENV['class']
3
+ raise "Must specify CLASS" unless class_name
4
+ @klass = Object.const_get(class_name)
5
+ end
6
+
7
+ namespace :facteur do
8
+ desc "Regenerates the mailboxes. The existing ones are not destroyed"
9
+ task :update => :environment do
10
+ klass = obtain_class
11
+ klass.update_addressees_mailboxes
12
+ end
13
+ end
data/lib/facteur.rb CHANGED
@@ -1,3 +1,14 @@
1
1
  require File.join(File.dirname(__FILE__), 'facteur/message_model')
2
2
  require File.join(File.dirname(__FILE__), 'facteur/mailbox_model')
3
3
  require File.join(File.dirname(__FILE__), 'facteur/addressee_model')
4
+ require 'rails'
5
+
6
+ module Facteur
7
+ module Rails
8
+ class Railtie < ::Rails::Railtie
9
+ rake_tasks do
10
+ load "facteur/rails/tasks/facteur.rake"
11
+ end
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 1
9
- version: 1.1.1
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rawane ZOSSOU
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-13 00:00:00 +02:00
17
+ date: 2010-11-04 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,7 +43,6 @@ extra_rdoc_files:
43
43
  - README.markdown
44
44
  files:
45
45
  - .document
46
- - .gitignore
47
46
  - LICENSE
48
47
  - README.markdown
49
48
  - Rakefile
@@ -52,6 +51,7 @@ files:
52
51
  - lib/facteur/addressee_model.rb
53
52
  - lib/facteur/mailbox_model.rb
54
53
  - lib/facteur/message_model.rb
54
+ - lib/facteur/rails/tasks/facteur.rake
55
55
  - lib/generators/facteur/install/install_generator.rb
56
56
  - lib/generators/facteur/install/templates/create_mailboxes.rb
57
57
  - lib/generators/facteur/install/templates/create_messages.rb
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- spec/db/.*
23
- *.gemspec