enough_fields 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +2 -0
- data/enough_fields.gemspec +30 -0
- data/lib/enough_fields.rb +114 -0
- data/lib/enough_fields/attribute_value.rb +27 -0
- data/lib/enough_fields/attributes.rb +36 -0
- data/lib/enough_fields/monit_set.rb +20 -0
- data/lib/enough_fields/notification.rb +23 -0
- data/lib/enough_fields/rack.rb +44 -0
- data/lib/enough_fields/version.rb +3 -0
- data/spec/enough_fields/enough_fields_spec.rb +29 -0
- data/spec/models/user.rb +5 -0
- data/spec/spec_helper.rb +27 -0
- metadata +211 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
enough_fields (0.0.1)
|
5
|
+
uniform_notifier (~> 1.0.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (3.0.3)
|
11
|
+
activesupport (= 3.0.3)
|
12
|
+
builder (~> 2.1.2)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
activesupport (3.0.3)
|
15
|
+
bson (1.1.2)
|
16
|
+
bson_ext (1.1.2)
|
17
|
+
builder (2.1.2)
|
18
|
+
diff-lcs (1.1.2)
|
19
|
+
i18n (0.4.2)
|
20
|
+
mongo (1.1.2)
|
21
|
+
bson (>= 1.1.1)
|
22
|
+
mongoid (2.0.0.beta.20)
|
23
|
+
activemodel (~> 3.0)
|
24
|
+
mongo (~> 1.1)
|
25
|
+
tzinfo (~> 0.3.22)
|
26
|
+
will_paginate (~> 3.0.pre)
|
27
|
+
rspec (2.1.0)
|
28
|
+
rspec-core (~> 2.1.0)
|
29
|
+
rspec-expectations (~> 2.1.0)
|
30
|
+
rspec-mocks (~> 2.1.0)
|
31
|
+
rspec-core (2.1.0)
|
32
|
+
rspec-expectations (2.1.0)
|
33
|
+
diff-lcs (~> 1.1.2)
|
34
|
+
rspec-mocks (2.1.0)
|
35
|
+
ruby-growl (3.0)
|
36
|
+
tzinfo (0.3.23)
|
37
|
+
uniform_notifier (1.0.0)
|
38
|
+
will_paginate (3.0.pre2)
|
39
|
+
xmpp4r (0.5)
|
40
|
+
|
41
|
+
PLATFORMS
|
42
|
+
ruby
|
43
|
+
|
44
|
+
DEPENDENCIES
|
45
|
+
bson (= 1.1.2)
|
46
|
+
bson_ext (= 1.1.2)
|
47
|
+
bundler (>= 1.0.0)
|
48
|
+
enough_fields!
|
49
|
+
mongoid (= 2.0.0.beta.20)
|
50
|
+
rspec (~> 2.1.0)
|
51
|
+
ruby-growl
|
52
|
+
uniform_notifier (~> 1.0.0)
|
53
|
+
xmpp4r
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Richard Huang (flyerhzm@gmail.com)
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
EnoughFields
|
2
|
+
============
|
3
|
+
|
4
|
+
EnoughFields helps you to use specified fields for mongoid.
|
5
|
+
|
6
|
+
Best practice is to use EnoughFields in development mode or custom mode (staging, profile, etc.).
|
7
|
+
|
8
|
+
Usage
|
9
|
+
-----
|
10
|
+
|
11
|
+
EnoughFields won't do ANYTHING unless you tell it to explicitly. Append to <code>config/environments/development.rb</code> initializer with the following code:
|
12
|
+
config.after_initialize do
|
13
|
+
EnoughFields.enable = true
|
14
|
+
EnoughFields.alert = true
|
15
|
+
EnoughFields.enough_fields_logger = true
|
16
|
+
EnoughFields.console = true
|
17
|
+
EnoughFields.growl = true
|
18
|
+
EnoughFields.xmpp = { :account => 'enough_fields_account@jabber.org',
|
19
|
+
:password => 'enough_fields_password_for_jabber',
|
20
|
+
:receiver => 'your_account@jabber.org',
|
21
|
+
:show_online_status => true }
|
22
|
+
EnoughFields.rails_logger = true
|
23
|
+
EnoughFields.disable_browser_cache = true
|
24
|
+
end
|
25
|
+
|
26
|
+
The notifier of enough_fields is a wrap of "uniform_notifier":https://github.com/flyerhzm/uniform_notifier
|
27
|
+
|
28
|
+
The code above will enable all six of the EnoughFields notification systems:
|
29
|
+
* <code>EnoughFields.enable</code>: enable EnoughFields plugin/gem, otherwise do nothing
|
30
|
+
* <code>EnoughFields.alert</code>: pop up a JavaScript alert in the browser
|
31
|
+
* <code>EnoughFields.enough_fields_logger</code>: log to the EnoughFields log file (Rails.root/log/enough_fields.log)
|
32
|
+
* <code>EnoughFields.rails_logger</code>: add warnings directly to the Rails log
|
33
|
+
* <code>EnoughFields.console</code>: log warnings to your browser's console.log (Safari/Webkit browsers or Firefox w/Firebug installed)
|
34
|
+
* <code>EnoughFields.growl</code>: pop up Growl warnings if your system has Growl installed. Requires a little bit of configuration
|
35
|
+
* <code>EnoughFields.xmpp</code>: send XMPP/Jabber notifications to the receiver indicated. Note that the code will currently not handle the adding of contacts, so you will need to make both accounts indicated know each other manually before you will receive any notifications. If you restart the development server frequently, the 'coming online' sound for the enough_fields account may start to annoy - in this case set :show_online_status to false; you will still get notifications, but the enough_fields account won't announce it's online status anymore.
|
36
|
+
* <code>EnoughFields.disable_browser_cache</code>: disable browser cache which usually causes unexpected problems
|
37
|
+
|
38
|
+
Growl Support
|
39
|
+
-------------
|
40
|
+
|
41
|
+
To get Growl support up-and-running for EnoughFields, follow the steps below:
|
42
|
+
* Install the ruby-growl gem: <code>gem install ruby-growl</code>
|
43
|
+
* Open the Growl preference pane in Systems Preferences
|
44
|
+
* Click the "Network" tab
|
45
|
+
* Make sure both "Listen for incoming notifications" and "Allow remote application registration" are checked. *Note*: If you set a password, you will need to set <code>EnoughFields.growl_password = { :password => 'growl password' }</code> in the config file.
|
46
|
+
* Restart Growl ("General" tab -> Stop Growl -> Start Growl)
|
47
|
+
* Boot up your application. EnoughFields will automatically send a Growl notification when Growl is turned on. If you do not see it when your application loads, make sure it is enabled in your initializer and double-check the steps above.
|
48
|
+
|
49
|
+
Ruby 1.9 issue
|
50
|
+
--------------
|
51
|
+
|
52
|
+
ruby-growl gem has an issue about md5 in ruby 1.9, if you use growl and ruby 1.9, check this gist http://gist.github.com/300184
|
53
|
+
|
54
|
+
XMPP/Jabber Support
|
55
|
+
-------------------
|
56
|
+
|
57
|
+
To get XMPP support up-and-running for EnoughFields, follow the steps below:
|
58
|
+
* Install the xmpp4r gem: <code>gem install xmpp4r</code>
|
59
|
+
* Make both the enough_fields and the recipient account add each other as contacts.
|
60
|
+
This will require you to manually log into both accounts, add each other
|
61
|
+
as contact and confirm each others contact request.
|
62
|
+
* Boot up your application. EnoughFields will automatically send an XMPP notification when XMPP is turned on.
|
63
|
+
|
64
|
+
Important
|
65
|
+
---------
|
66
|
+
|
67
|
+
If you find enough_fields does not work for you, *please disable your browser's cache*.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/enough_fields/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "enough_fields"
|
6
|
+
s.version = EnoughFields::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ['Richard Huang']
|
9
|
+
s.email = ['flyerhzm@gmail.com']
|
10
|
+
s.homepage = "http://rubygems.org/gems/enough_fields"
|
11
|
+
s.summary = "help to use specified fields for mongoid"
|
12
|
+
s.description = "help to use specified fields for mongoid"
|
13
|
+
|
14
|
+
s.required_rubygems_version = ">= 1.3.6"
|
15
|
+
s.rubyforge_project = "enough_fields"
|
16
|
+
|
17
|
+
s.add_dependency "uniform_notifier", "~> 1.0.0"
|
18
|
+
|
19
|
+
s.add_development_dependency "ruby-growl"
|
20
|
+
s.add_development_dependency "xmpp4r"
|
21
|
+
s.add_development_dependency "bson", "1.1.2"
|
22
|
+
s.add_development_dependency "bson_ext", "1.1.2"
|
23
|
+
s.add_development_dependency "mongoid", "2.0.0.beta.20"
|
24
|
+
s.add_development_dependency "rspec", "~> 2.1.0"
|
25
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
26
|
+
|
27
|
+
s.files = `git ls-files`.split("\n")
|
28
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
29
|
+
s.require_path = 'lib'
|
30
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'uniform_notifier'
|
2
|
+
|
3
|
+
module EnoughFields
|
4
|
+
autoload :Rack, 'enough_fields/rack'
|
5
|
+
autoload :AttributeValue, 'enough_fields/attribute_value'
|
6
|
+
autoload :Notification, 'enough_fields/notification'
|
7
|
+
autoload :Attributes, 'enough_fields/attributes'
|
8
|
+
autoload :MonitSet, 'enough_fields/monit_set'
|
9
|
+
|
10
|
+
if defined? Rails::Railtie
|
11
|
+
class EnoughFieldsRailtie < Rails::Railtie
|
12
|
+
initializer "enough_fields.configure_rails_initialization" do |app|
|
13
|
+
app.middleware.use EnoughFields::Rack
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class <<self
|
19
|
+
attr_accessor :disable_browser_cache
|
20
|
+
delegate :alert=, :console=, :growl=, :rails_logger=, :xmpp=, :to => UniformNotifier
|
21
|
+
|
22
|
+
def enable=(enable)
|
23
|
+
@enable = enable
|
24
|
+
if enable?
|
25
|
+
Mongoid::Cursor.class_eval do
|
26
|
+
alias_method :origin_each, :each
|
27
|
+
|
28
|
+
def each
|
29
|
+
if @cursor.count > 1
|
30
|
+
@cursor.each do |document|
|
31
|
+
attributes = Attributes.build(@klass, document)
|
32
|
+
yield Mongoid::Factory.build(@klass, attributes)
|
33
|
+
end
|
34
|
+
else
|
35
|
+
:origin_each
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Mongoid::Factory.class_eval do
|
41
|
+
class <<self
|
42
|
+
def build(klass, attributes)
|
43
|
+
type = attributes["_type"]
|
44
|
+
type ? type.constantize.instantiate(attributes) : klass.instantiate(attributes)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def enable?
|
52
|
+
@enable == true
|
53
|
+
end
|
54
|
+
|
55
|
+
def enough_fields_logger=(active)
|
56
|
+
if active
|
57
|
+
enough_fields_log_file = File.open( 'log/enough_fields.log', 'a+' )
|
58
|
+
enough_fields_log_file.sync
|
59
|
+
UniformNotifier.customized_logger = enough_fields_log_file
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def start_request
|
64
|
+
Thread.current[:monit_set] = MonitSet.new
|
65
|
+
end
|
66
|
+
|
67
|
+
def end_request
|
68
|
+
Thread.current[:monit_set] = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
def notification?
|
72
|
+
current_monit_set.check_notifications
|
73
|
+
!notifications.empty?
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_notification(call_stack, klass, fields)
|
77
|
+
notification = Notification.new(call_stack, klass, fields)
|
78
|
+
notifications << notification
|
79
|
+
end
|
80
|
+
|
81
|
+
def gather_inline_notifications
|
82
|
+
responses = []
|
83
|
+
for_each_active_notifier_with_notification do |notification|
|
84
|
+
responses << notification.notify_inline
|
85
|
+
end
|
86
|
+
responses.join( "\n" )
|
87
|
+
end
|
88
|
+
|
89
|
+
def perform_out_of_channel_notifications
|
90
|
+
for_each_active_notifier_with_notification do |notification|
|
91
|
+
notification.notify_out_of_channel
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def current_monit_set
|
97
|
+
Thread.current[:monit_set]
|
98
|
+
end
|
99
|
+
|
100
|
+
def notifications
|
101
|
+
@notifications ||= []
|
102
|
+
end
|
103
|
+
|
104
|
+
def for_each_active_notifier_with_notification
|
105
|
+
UniformNotifier.active_notifiers.each do |notifier|
|
106
|
+
notifications.each do |notification|
|
107
|
+
notification.notifier = notifier
|
108
|
+
yield notification
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module EnoughFields
|
2
|
+
class AttributeValue
|
3
|
+
attr_reader :klass, :field, :call_stack
|
4
|
+
attr_writer :call_stack
|
5
|
+
|
6
|
+
def initialize(value, klass, field, call_stack)
|
7
|
+
@value = value
|
8
|
+
@klass = klass
|
9
|
+
@field = field
|
10
|
+
@call_stack = call_stack
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_value
|
14
|
+
@value
|
15
|
+
end
|
16
|
+
|
17
|
+
def eql?( other )
|
18
|
+
self.klass == other.klass &&
|
19
|
+
self.field == other.field &&
|
20
|
+
self.call_stack == other.call_stack
|
21
|
+
end
|
22
|
+
|
23
|
+
def hash
|
24
|
+
self.klass.hash + self.field.hash + self.call_stack.hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module EnoughFields
|
2
|
+
class Attributes < ActiveSupport::HashWithIndifferentAccess
|
3
|
+
class <<self
|
4
|
+
attr_accessor :klass
|
5
|
+
|
6
|
+
def build(klass, attributes)
|
7
|
+
@klass = klass
|
8
|
+
self[attributes]
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](attributes)
|
12
|
+
return super unless Thread.current[:monit_set]
|
13
|
+
|
14
|
+
hash = super
|
15
|
+
hash.each do |key, value|
|
16
|
+
next if key.is_a? Array
|
17
|
+
attribute_value = AttributeValue.new(value, @klass, key, caller.find_all { |c| c.index Rails.root })
|
18
|
+
hash[ key ] = attribute_value
|
19
|
+
Thread.current[:monit_set] << attribute_value
|
20
|
+
end
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def [](key)
|
26
|
+
return super unless Thread.current[:monit_set]
|
27
|
+
|
28
|
+
if super && super.is_a?(AttributeValue)
|
29
|
+
super.call_stack = nil
|
30
|
+
super.to_value
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
module EnoughFields
|
4
|
+
class MonitSet < Set
|
5
|
+
|
6
|
+
def check_notifications
|
7
|
+
results = {}
|
8
|
+
self.each do |attribute_value|
|
9
|
+
if attribute_value.call_stack
|
10
|
+
results[ [attribute_value.call_stack, attribute_value.klass] ] ||= []
|
11
|
+
results[ [attribute_value.call_stack, attribute_value.klass] ] << attribute_value.field
|
12
|
+
end
|
13
|
+
end
|
14
|
+
results.each do |call_stack_klass, fields|
|
15
|
+
call_stack, klass = *call_stack_klass
|
16
|
+
EnoughFields.add_notification(call_stack, klass, fields)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EnoughFields
|
2
|
+
class Notification
|
3
|
+
attr_accessor :notifier
|
4
|
+
|
5
|
+
def initialize(call_stack, klass, fields)
|
6
|
+
@call_stack = call_stack
|
7
|
+
@klass = klass
|
8
|
+
@fields = fields
|
9
|
+
end
|
10
|
+
|
11
|
+
def full_notice
|
12
|
+
"add .only(#{(@klass.fields.keys - @fields).inspect}) for\n#{@call_stack.join("\n")}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def notify_inline
|
16
|
+
self.notifier.inline_notify( self.full_notice )
|
17
|
+
end
|
18
|
+
|
19
|
+
def notify_out_of_channel
|
20
|
+
self.notifier.out_of_channel_notify( self.full_notice )
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module EnoughFields
|
2
|
+
class Rack
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
return @app.call(env) unless EnoughFields.enable?
|
9
|
+
|
10
|
+
EnoughFields.start_request
|
11
|
+
status, headers, response = @app.call(env)
|
12
|
+
return [status, headers, response] if empty?(response)
|
13
|
+
|
14
|
+
if EnoughFields.notification?
|
15
|
+
if status == 200 and !response.body.frozen? and check_html?(headers, response)
|
16
|
+
response_body = response.body << EnoughFields.gather_inline_notifications
|
17
|
+
headers['Content-Length'] = response_body.length.to_s
|
18
|
+
end
|
19
|
+
EnoughFields.perform_out_of_channel_notifications
|
20
|
+
end
|
21
|
+
response_body ||= response.body
|
22
|
+
EnoughFields.end_request
|
23
|
+
no_browser_cache(headers) if EnoughFields.disable_browser_cache
|
24
|
+
[status, headers, [response_body]]
|
25
|
+
end
|
26
|
+
|
27
|
+
# fix issue if response's body is a Proc
|
28
|
+
def empty?(response)
|
29
|
+
# response may be ["Not Found"], ["Move Permanently"], etc.
|
30
|
+
(response.is_a?(Array) && response.size <= 1) ||
|
31
|
+
!response.body.is_a?(String) || response.body.empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_html?(headers, response)
|
35
|
+
headers['Content-Type'] and headers['Content-Type'].include? 'text/html' and response.body =~ %r{<html.*</html>}m
|
36
|
+
end
|
37
|
+
|
38
|
+
def no_browser_cache(headers)
|
39
|
+
headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
|
40
|
+
headers["Pragma"] = "no-cache"
|
41
|
+
headers["Expires"] = "Wed, 09 Sep 2009 09:09:09 GMT"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Rails
|
4
|
+
def self.root
|
5
|
+
File.dirname(__FILE__)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe EnoughFields do
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
User.create(:login => 'flyerhzm', :email => 'flyerhzm@gmail.com', :first_name => 'richard', :last_name => 'huang')
|
13
|
+
User.create(:login => 'richard', :email => 'richard@gmail.com', :first_name => 'richard', :last_name => 'huang')
|
14
|
+
User.create(:login => 'test', :email => 'test@gmail.com', :first_name => 'test', :last_name => 'test')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should" do
|
18
|
+
EnoughFields.enable = true
|
19
|
+
EnoughFields.growl = true
|
20
|
+
EnoughFields.start_request
|
21
|
+
Thread.current[:monit_set] = EnoughFields::MonitSet.new
|
22
|
+
p User.all.collect(&:email)
|
23
|
+
# User.all.to_a
|
24
|
+
if EnoughFields.notification?
|
25
|
+
EnoughFields.perform_out_of_channel_notifications
|
26
|
+
end
|
27
|
+
EnoughFields.end_request
|
28
|
+
end
|
29
|
+
end
|
data/spec/models/user.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
+
|
4
|
+
MODELS = File.join(File.dirname(__FILE__), "models")
|
5
|
+
$LOAD_PATH.unshift(MODELS)
|
6
|
+
|
7
|
+
require "mongoid"
|
8
|
+
require "enough_fields"
|
9
|
+
require "rspec"
|
10
|
+
|
11
|
+
Mongoid.configure do |config|
|
12
|
+
name = "mongoid_test"
|
13
|
+
host = "localhost"
|
14
|
+
config.master = Mongo::Connection.new.db(name)
|
15
|
+
config.logger = nil
|
16
|
+
# config.slaves = [
|
17
|
+
# Mongo::Connection.new(host, 27018, :slave_ok => true).db(name)
|
18
|
+
# ]
|
19
|
+
end
|
20
|
+
|
21
|
+
Dir[ File.join(MODELS, "*.rb") ].sort.each { |file| require File.basename(file) }
|
22
|
+
|
23
|
+
Rspec.configure do |config|
|
24
|
+
config.after :suite do
|
25
|
+
Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,211 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: enough_fields
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Richard Huang
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-22 00:00:00 +08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: uniform_notifier
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 23
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 1.0.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: ruby-growl
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 3
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
version: "0"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: xmpp4r
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: bson
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - "="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 23
|
74
|
+
segments:
|
75
|
+
- 1
|
76
|
+
- 1
|
77
|
+
- 2
|
78
|
+
version: 1.1.2
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: bson_ext
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - "="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 23
|
90
|
+
segments:
|
91
|
+
- 1
|
92
|
+
- 1
|
93
|
+
- 2
|
94
|
+
version: 1.1.2
|
95
|
+
type: :development
|
96
|
+
version_requirements: *id005
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mongoid
|
99
|
+
prerelease: false
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - "="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
hash: 62196427
|
106
|
+
segments:
|
107
|
+
- 2
|
108
|
+
- 0
|
109
|
+
- 0
|
110
|
+
- beta
|
111
|
+
- 20
|
112
|
+
version: 2.0.0.beta.20
|
113
|
+
type: :development
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rspec
|
117
|
+
prerelease: false
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 11
|
124
|
+
segments:
|
125
|
+
- 2
|
126
|
+
- 1
|
127
|
+
- 0
|
128
|
+
version: 2.1.0
|
129
|
+
type: :development
|
130
|
+
version_requirements: *id007
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: bundler
|
133
|
+
prerelease: false
|
134
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 23
|
140
|
+
segments:
|
141
|
+
- 1
|
142
|
+
- 0
|
143
|
+
- 0
|
144
|
+
version: 1.0.0
|
145
|
+
type: :development
|
146
|
+
version_requirements: *id008
|
147
|
+
description: help to use specified fields for mongoid
|
148
|
+
email:
|
149
|
+
- flyerhzm@gmail.com
|
150
|
+
executables: []
|
151
|
+
|
152
|
+
extensions: []
|
153
|
+
|
154
|
+
extra_rdoc_files: []
|
155
|
+
|
156
|
+
files:
|
157
|
+
- .gitignore
|
158
|
+
- Gemfile
|
159
|
+
- Gemfile.lock
|
160
|
+
- LICENSE
|
161
|
+
- README.md
|
162
|
+
- Rakefile
|
163
|
+
- enough_fields.gemspec
|
164
|
+
- lib/enough_fields.rb
|
165
|
+
- lib/enough_fields/attribute_value.rb
|
166
|
+
- lib/enough_fields/attributes.rb
|
167
|
+
- lib/enough_fields/monit_set.rb
|
168
|
+
- lib/enough_fields/notification.rb
|
169
|
+
- lib/enough_fields/rack.rb
|
170
|
+
- lib/enough_fields/version.rb
|
171
|
+
- spec/enough_fields/enough_fields_spec.rb
|
172
|
+
- spec/models/user.rb
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
has_rdoc: true
|
175
|
+
homepage: http://rubygems.org/gems/enough_fields
|
176
|
+
licenses: []
|
177
|
+
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
none: false
|
185
|
+
requirements:
|
186
|
+
- - ">="
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
hash: 3
|
189
|
+
segments:
|
190
|
+
- 0
|
191
|
+
version: "0"
|
192
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
hash: 23
|
198
|
+
segments:
|
199
|
+
- 1
|
200
|
+
- 3
|
201
|
+
- 6
|
202
|
+
version: 1.3.6
|
203
|
+
requirements: []
|
204
|
+
|
205
|
+
rubyforge_project: enough_fields
|
206
|
+
rubygems_version: 1.3.7
|
207
|
+
signing_key:
|
208
|
+
specification_version: 3
|
209
|
+
summary: help to use specified fields for mongoid
|
210
|
+
test_files: []
|
211
|
+
|