puffer 0.0.26 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -1
- data/Gemfile.lock +12 -10
- data/VERSION +1 -1
- data/app/components/references_one/form.html.erb +0 -18
- data/app/views/layouts/puffer.html.erb +1 -1
- data/lib/puffer/component.rb +4 -7
- data/lib/puffer/controller/config.rb +6 -10
- data/lib/puffer/controller/mutate.rb +14 -13
- data/lib/puffer/extensions/controller.rb +5 -13
- data/lib/puffer/extensions/core.rb +7 -0
- data/lib/puffer/extensions/mapper.rb +4 -6
- data/lib/puffer/field.rb +2 -2
- data/lib/puffer/field_set.rb +1 -1
- data/lib/puffer/orm_adapter/active_record.rb +15 -0
- data/lib/puffer/orm_adapter/base.rb +13 -0
- data/lib/puffer/orm_adapter/mongoid.rb +15 -0
- data/lib/puffer/resource/routing.rb +2 -2
- data/lib/puffer/resource.rb +2 -2
- data/lib/puffer.rb +14 -7
- data/puffer.gemspec +17 -7
- data/spec/dummy/app/controllers/orms/mongoid_tests_controller.rb +19 -0
- data/spec/dummy/app/models/mongoid_test.rb +13 -0
- data/spec/dummy/app/models/post.rb +1 -1
- data/spec/dummy/config/mongoid.yml +11 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/lib/fields_spec.rb +1 -1
- metadata +60 -34
- data/lib/puffer/controller/helpers.rb +0 -31
- data/lib/puffer/extensions/activerecord.rb +0 -23
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -30,12 +30,10 @@ GEM
|
|
30
30
|
activesupport (= 3.1.0)
|
31
31
|
activesupport (3.1.0)
|
32
32
|
multi_json (~> 1.0)
|
33
|
-
apotomo (1.1.2)
|
34
|
-
cells (>= 3.5.6)
|
35
|
-
hooks (~> 0.1.3)
|
36
|
-
onfire (~> 0.2.0)
|
37
33
|
arel (2.2.1)
|
38
34
|
bcrypt-ruby (3.0.0)
|
35
|
+
bson (1.3.1)
|
36
|
+
bson_ext (1.3.1)
|
39
37
|
builder (3.0.0)
|
40
38
|
capybara (1.1.1)
|
41
39
|
mime-types (>= 1.16)
|
@@ -44,9 +42,6 @@ GEM
|
|
44
42
|
rack-test (>= 0.5.4)
|
45
43
|
selenium-webdriver (~> 2.0)
|
46
44
|
xpath (~> 0.1.4)
|
47
|
-
cells (3.6.5)
|
48
|
-
actionpack (~> 3.0)
|
49
|
-
railties (~> 3.0)
|
50
45
|
childprocess (0.2.2)
|
51
46
|
ffi (~> 1.0.6)
|
52
47
|
database_cleaner (0.6.7)
|
@@ -62,7 +57,6 @@ GEM
|
|
62
57
|
guard-rspec (0.4.4)
|
63
58
|
guard (>= 0.4.0)
|
64
59
|
hike (1.2.1)
|
65
|
-
hooks (0.1.4)
|
66
60
|
i18n (0.6.0)
|
67
61
|
jeweler (1.6.4)
|
68
62
|
bundler (~> 1.0)
|
@@ -78,12 +72,18 @@ GEM
|
|
78
72
|
mime-types (~> 1.16)
|
79
73
|
treetop (~> 1.4.8)
|
80
74
|
mime-types (1.16)
|
75
|
+
mongo (1.3.1)
|
76
|
+
bson (>= 1.3.1)
|
77
|
+
mongoid (2.2.0)
|
78
|
+
activemodel (~> 3.0)
|
79
|
+
mongo (~> 1.3)
|
80
|
+
tzinfo (~> 0.3.22)
|
81
81
|
multi_json (1.0.3)
|
82
82
|
nested_set (1.6.8)
|
83
83
|
activerecord (>= 3.0.0)
|
84
84
|
railties (>= 3.0.0)
|
85
85
|
nokogiri (1.5.0)
|
86
|
-
|
86
|
+
orm_adapter (0.0.5)
|
87
87
|
polyglot (0.3.2)
|
88
88
|
rack (1.3.2)
|
89
89
|
rack-cache (1.0.3)
|
@@ -149,7 +149,7 @@ PLATFORMS
|
|
149
149
|
ruby
|
150
150
|
|
151
151
|
DEPENDENCIES
|
152
|
-
|
152
|
+
bson_ext
|
153
153
|
capybara
|
154
154
|
database_cleaner
|
155
155
|
fabrication
|
@@ -159,7 +159,9 @@ DEPENDENCIES
|
|
159
159
|
jeweler
|
160
160
|
kaminari
|
161
161
|
libnotify
|
162
|
+
mongoid
|
162
163
|
nested_set
|
164
|
+
orm_adapter
|
163
165
|
rails (~> 3.1.0)
|
164
166
|
rspec-rails
|
165
167
|
sqlite3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.28
|
@@ -1,22 +1,4 @@
|
|
1
1
|
<% content_for :input do %>
|
2
|
-
<% value = [
|
3
|
-
swallow_nil{opts[:form].object.send(field.name)[field.reflection.primary_key_column.name.to_sym]},
|
4
|
-
swallow_nil{opts[:form].object.send(field.name).to_title}
|
5
|
-
].compact.join(' - ')
|
6
|
-
%>
|
7
|
-
|
8
|
-
<div class="association">
|
9
|
-
<%= text_field_tag field, value, field.input_options.merge(
|
10
|
-
:autocomplete => :off,
|
11
|
-
:disabled => (true if opts[:form].object.send(field.name)),
|
12
|
-
'data-autocompleter' => "{url: '#{event_path :choose}', onDone: association_done}"
|
13
|
-
) %>
|
14
|
-
<div class="association_clear">×</div>
|
15
|
-
<%= opts[:form].hidden_field field.reflection.foreign_key %>
|
16
|
-
</div>
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<% clean_content_for :input do %>
|
20
2
|
<% link_to "Choose", '#', :"data-dialog-uri" => event_path(:choose) %>
|
21
3
|
<% end %>
|
22
4
|
|
data/lib/puffer/component.rb
CHANGED
@@ -12,6 +12,8 @@ module Puffer
|
|
12
12
|
# handling and component state changing
|
13
13
|
class Base < AbstractController::Base
|
14
14
|
|
15
|
+
abstract!
|
16
|
+
|
15
17
|
module ComponentHelper
|
16
18
|
def component_wrap name = :span, options = {}, &block
|
17
19
|
content_tag name, options.merge(:id => component_id), &block
|
@@ -28,21 +30,19 @@ module Puffer
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
|
-
module
|
33
|
+
module ClassMethods
|
32
34
|
def render_component parent_controller, field, context, *args
|
33
35
|
klass = "#{field.type}_component".camelize.constantize rescue StringComponent
|
34
36
|
component = klass.new field
|
35
37
|
component.process parent_controller, context, *args
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
39
|
-
module ClassMethods
|
40
40
|
def controller_path
|
41
41
|
@controller_path ||= name.sub(/Component$/, '').underscore unless anonymous?
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
extend ClassMethods
|
46
46
|
|
47
47
|
include AbstractController::Rendering
|
48
48
|
include AbstractController::Helpers
|
@@ -54,9 +54,6 @@ module Puffer
|
|
54
54
|
include ActionController::UrlFor
|
55
55
|
include Rails.application.routes.url_helpers
|
56
56
|
|
57
|
-
extend SingletonMethods
|
58
|
-
extend ClassMethods
|
59
|
-
|
60
57
|
helper ComponentHelper, PufferHelper
|
61
58
|
|
62
59
|
attr_accessor :parent_controller, :field, :opts, :identifer
|
@@ -1,18 +1,14 @@
|
|
1
1
|
module Puffer
|
2
2
|
module Controller
|
3
3
|
module Config
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
included do
|
7
|
+
puffer_class_attribute :group
|
8
|
+
puffer_class_attribute :model_name
|
9
|
+
puffer_class_attribute :destroy, true
|
9
10
|
|
10
|
-
|
11
|
-
puffer_class_attribute :model_name
|
12
|
-
puffer_class_attribute :destroy, true
|
13
|
-
|
14
|
-
helper_method :configuration
|
15
|
-
end
|
11
|
+
helper_method :configuration
|
16
12
|
end
|
17
13
|
|
18
14
|
module InstanceMethods
|
@@ -1,26 +1,27 @@
|
|
1
1
|
module Puffer
|
2
2
|
module Controller
|
3
3
|
module Mutate
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
layout 'puffer'
|
11
|
-
helper :puffer
|
12
|
-
helper_method :puffer?, :namespace
|
13
|
-
end
|
6
|
+
included do
|
7
|
+
layout 'puffer'
|
8
|
+
helper :puffer
|
9
|
+
delegate :namespace, :model, :model_name, :to => 'self.class'
|
10
|
+
helper_method :namespace, :resource, :record, :records
|
14
11
|
end
|
15
12
|
|
16
13
|
module InstanceMethods
|
17
14
|
|
18
|
-
def
|
19
|
-
self
|
15
|
+
def resource
|
16
|
+
@resource ||= Puffer::Resource.new params, self
|
20
17
|
end
|
21
18
|
|
22
|
-
def
|
23
|
-
|
19
|
+
def record
|
20
|
+
@record || instance_variable_get("@#{resource.model_name}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def records
|
24
|
+
@records || instance_variable_get("@#{resource.model_name.pluralize}")
|
24
25
|
end
|
25
26
|
|
26
27
|
end
|
@@ -5,30 +5,22 @@ module Puffer
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
9
|
-
|
10
|
-
helper_method :puffer?, :render_component
|
8
|
+
delegate :puffer?, :to => 'self.class'
|
9
|
+
helper_method :puffer?
|
11
10
|
end
|
12
11
|
|
13
12
|
module ClassMethods
|
14
|
-
def puffer
|
13
|
+
def puffer?
|
14
|
+
false
|
15
|
+
end
|
15
16
|
|
16
17
|
def pufferize!
|
17
18
|
include Puffer::Controller::Mutate
|
18
|
-
include Puffer::Controller::Helpers
|
19
19
|
include Puffer::Controller::Dsl
|
20
20
|
include Puffer::Controller::Config
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
module InstanceMethods
|
25
|
-
def puffer?; false; end
|
26
|
-
|
27
|
-
def render_component *args
|
28
|
-
Puffer::Component::Base.render_component self, *args
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
24
|
end
|
33
25
|
end
|
34
26
|
end
|
@@ -1,6 +1,12 @@
|
|
1
1
|
module Puffer
|
2
2
|
module Extensions
|
3
3
|
|
4
|
+
module Object
|
5
|
+
def call_chain chain
|
6
|
+
swallow_nil{instance_eval(chain.to_s)}
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
4
10
|
module String
|
5
11
|
def singular?
|
6
12
|
self.singularize == self
|
@@ -37,6 +43,7 @@ module Puffer
|
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
46
|
+
Object.send :include, Puffer::Extensions::Object
|
40
47
|
String.send :include, Puffer::Extensions::String
|
41
48
|
Symbol.send :include, Puffer::Extensions::Symbol
|
42
49
|
Array.send :include, Puffer::Extensions::Array
|
@@ -1,13 +1,11 @@
|
|
1
1
|
module Puffer
|
2
2
|
module Extensions
|
3
3
|
module Mapper
|
4
|
+
extend ActiveSupport::Concern
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
alias_method_chain :resource, :puffer
|
9
|
-
alias_method_chain :resources, :puffer
|
10
|
-
end
|
6
|
+
included do
|
7
|
+
alias_method_chain :resource, :puffer
|
8
|
+
alias_method_chain :resources, :puffer
|
11
9
|
end
|
12
10
|
|
13
11
|
module InstanceMethods
|
data/lib/puffer/field.rb
CHANGED
@@ -83,11 +83,11 @@ module Puffer
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def column
|
86
|
-
@column ||= model && model.columns_hash[name]
|
86
|
+
@column ||= model && model.to_adapter.columns_hash[name]
|
87
87
|
end
|
88
88
|
|
89
89
|
def column_type
|
90
|
-
column
|
90
|
+
column[:type] if column
|
91
91
|
end
|
92
92
|
|
93
93
|
def query_column
|
data/lib/puffer/field_set.rb
CHANGED
@@ -14,7 +14,7 @@ module Puffer
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def searchable
|
17
|
-
@searchable ||= map { |f| f if f.column && [:text, :string, :integer, :decimal, :float].include?(f.
|
17
|
+
@searchable ||= map { |f| f if f.column && [:text, :string, :integer, :decimal, :float].include?(f.column_type) }.compact
|
18
18
|
end
|
19
19
|
|
20
20
|
def searches query
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Puffer
|
2
|
+
module OrmAdapter
|
3
|
+
module ActiveRecord
|
4
|
+
|
5
|
+
def columns_hash
|
6
|
+
klass.columns_hash.inject({}) do |result, (name, object)|
|
7
|
+
result.merge name => {:type => object.type}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
ActiveRecord::Base::OrmAdapter.send :include, Puffer::OrmAdapter::ActiveRecord
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Puffer
|
2
|
+
module OrmAdapter
|
3
|
+
module Mongoid
|
4
|
+
|
5
|
+
def columns_hash
|
6
|
+
klass.fields.inject({}) do |result, (name, object)|
|
7
|
+
result.merge name => {:type => object.type.to_s.underscore.to_sym}
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Mongoid::Document::OrmAdapter.send :include, Puffer::OrmAdapter::Mongoid
|
@@ -10,7 +10,7 @@ module Puffer
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def member_url *args
|
13
|
-
suggest = args.shift if args.first.
|
13
|
+
suggest = args.shift if args.first.respond_to? :to_key
|
14
14
|
polymorphic_url *route_args(route_member(suggest), *args)
|
15
15
|
end
|
16
16
|
|
@@ -19,7 +19,7 @@ module Puffer
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def edit_url *args
|
22
|
-
suggest = args.shift if args.first.
|
22
|
+
suggest = args.shift if args.first.respond_to? :to_key
|
23
23
|
edit_polymorphic_url *route_args(route_member(suggest), *args)
|
24
24
|
end
|
25
25
|
|
data/lib/puffer/resource.rb
CHANGED
@@ -106,12 +106,12 @@ module Puffer
|
|
106
106
|
def member
|
107
107
|
if parent
|
108
108
|
if plural?
|
109
|
-
parent.member.send(model_name.pluralize).find params[:id]
|
109
|
+
parent.member.send(model_name.pluralize).find params[:id] if params[:id]
|
110
110
|
else
|
111
111
|
parent.member.send(model_name)
|
112
112
|
end
|
113
113
|
else
|
114
|
-
model.find params[:id]
|
114
|
+
model.find params[:id] if params[:id]
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
data/lib/puffer.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'kaminari'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'orm_adapter'
|
4
|
+
require 'puffer/orm_adapter/base'
|
5
|
+
require 'puffer/orm_adapter/active_record' if defined?(ActiveRecord::Base::OrmAdapter)
|
6
|
+
require 'puffer/orm_adapter/mongoid' if defined?(Mongoid::Document::OrmAdapter)
|
7
|
+
#require 'puffer/orm_adapter/data_mapper' if defined?(DataMapper::Resource::OrmAdapter)
|
8
|
+
#require 'puffer/orm_adapter/mongo_mapper' if defined?(MongoMapper::Document::OrmAdapter)
|
9
|
+
|
4
10
|
require 'puffer/extensions/controller'
|
5
11
|
require 'puffer/extensions/core'
|
6
12
|
require 'puffer/extensions/mapper'
|
@@ -9,6 +15,12 @@ require 'puffer/extensions/engine'
|
|
9
15
|
require 'puffer/engine'
|
10
16
|
|
11
17
|
module Puffer
|
18
|
+
|
19
|
+
module Controller
|
20
|
+
autoload :Action, 'puffer/controller/actions'
|
21
|
+
autoload :MemberAction, 'puffer/controller/actions'
|
22
|
+
autoload :CollectionAction, 'puffer/controller/actions'
|
23
|
+
end
|
12
24
|
|
13
25
|
module Component
|
14
26
|
autoload :Base, 'puffer/component'
|
@@ -29,12 +41,7 @@ module Puffer
|
|
29
41
|
map_component :has_many, :has_and_belongs_to_many, :to => :ReferencesManyComponent
|
30
42
|
map_component :date, :time, :datetime, :timestamp, :to => :DateTimeComponent
|
31
43
|
map_component :integer, :decimal, :to => :StringComponent
|
32
|
-
|
33
|
-
|
34
|
-
module Controller
|
35
|
-
autoload :Action, 'puffer/controller/actions'
|
36
|
-
autoload :MemberAction, 'puffer/controller/actions'
|
37
|
-
autoload :CollectionAction, 'puffer/controller/actions'
|
44
|
+
map_component :array, :decimal, :to => :StringComponent
|
38
45
|
end
|
39
46
|
|
40
47
|
end
|
data/puffer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{puffer}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.28"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{pyromaniac}]
|
12
|
-
s.date = %q{2011-09-
|
12
|
+
s.date = %q{2011-09-11}
|
13
13
|
s.description = %q{In Soviet Russia puffer admins you}
|
14
14
|
s.email = %q{kinwizard@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -101,10 +101,8 @@ Gem::Specification.new do |s|
|
|
101
101
|
"lib/puffer/controller/actions.rb",
|
102
102
|
"lib/puffer/controller/config.rb",
|
103
103
|
"lib/puffer/controller/dsl.rb",
|
104
|
-
"lib/puffer/controller/helpers.rb",
|
105
104
|
"lib/puffer/controller/mutate.rb",
|
106
105
|
"lib/puffer/engine.rb",
|
107
|
-
"lib/puffer/extensions/activerecord.rb",
|
108
106
|
"lib/puffer/extensions/controller.rb",
|
109
107
|
"lib/puffer/extensions/core.rb",
|
110
108
|
"lib/puffer/extensions/engine.rb",
|
@@ -112,6 +110,9 @@ Gem::Specification.new do |s|
|
|
112
110
|
"lib/puffer/extensions/mapper.rb",
|
113
111
|
"lib/puffer/field.rb",
|
114
112
|
"lib/puffer/field_set.rb",
|
113
|
+
"lib/puffer/orm_adapter/active_record.rb",
|
114
|
+
"lib/puffer/orm_adapter/base.rb",
|
115
|
+
"lib/puffer/orm_adapter/mongoid.rb",
|
115
116
|
"lib/puffer/resource.rb",
|
116
117
|
"lib/puffer/resource/routing.rb",
|
117
118
|
"lib/puffer/resource/scoping.rb",
|
@@ -141,9 +142,11 @@ Gem::Specification.new do |s|
|
|
141
142
|
"spec/dummy/app/controllers/admin/tags_controller.rb",
|
142
143
|
"spec/dummy/app/controllers/admin/users_controller.rb",
|
143
144
|
"spec/dummy/app/controllers/application_controller.rb",
|
145
|
+
"spec/dummy/app/controllers/orms/mongoid_tests_controller.rb",
|
144
146
|
"spec/dummy/app/helpers/application_helper.rb",
|
145
147
|
"spec/dummy/app/models/category.rb",
|
146
148
|
"spec/dummy/app/models/friendship.rb",
|
149
|
+
"spec/dummy/app/models/mongoid_test.rb",
|
147
150
|
"spec/dummy/app/models/news.rb",
|
148
151
|
"spec/dummy/app/models/post.rb",
|
149
152
|
"spec/dummy/app/models/post_category.rb",
|
@@ -168,6 +171,7 @@ Gem::Specification.new do |s|
|
|
168
171
|
"spec/dummy/config/initializers/session_store.rb",
|
169
172
|
"spec/dummy/config/initializers/wrap_parameters.rb",
|
170
173
|
"spec/dummy/config/locales/en.yml",
|
174
|
+
"spec/dummy/config/mongoid.yml",
|
171
175
|
"spec/dummy/config/routes.rb",
|
172
176
|
"spec/dummy/db/migrate/20100930132559_create_users.rb",
|
173
177
|
"spec/dummy/db/migrate/20100930132656_create_posts.rb",
|
@@ -213,8 +217,10 @@ Gem::Specification.new do |s|
|
|
213
217
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
214
218
|
s.add_runtime_dependency(%q<rails>, ["~> 3.1.0"])
|
215
219
|
s.add_runtime_dependency(%q<kaminari>, [">= 0"])
|
216
|
-
s.add_runtime_dependency(%q<
|
220
|
+
s.add_runtime_dependency(%q<orm_adapter>, [">= 0"])
|
217
221
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
222
|
+
s.add_development_dependency(%q<mongoid>, [">= 0"])
|
223
|
+
s.add_development_dependency(%q<bson_ext>, [">= 0"])
|
218
224
|
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
219
225
|
s.add_development_dependency(%q<capybara>, [">= 0"])
|
220
226
|
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
@@ -228,8 +234,10 @@ Gem::Specification.new do |s|
|
|
228
234
|
else
|
229
235
|
s.add_dependency(%q<rails>, ["~> 3.1.0"])
|
230
236
|
s.add_dependency(%q<kaminari>, [">= 0"])
|
231
|
-
s.add_dependency(%q<
|
237
|
+
s.add_dependency(%q<orm_adapter>, [">= 0"])
|
232
238
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
239
|
+
s.add_dependency(%q<mongoid>, [">= 0"])
|
240
|
+
s.add_dependency(%q<bson_ext>, [">= 0"])
|
233
241
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
234
242
|
s.add_dependency(%q<capybara>, [">= 0"])
|
235
243
|
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
@@ -244,8 +252,10 @@ Gem::Specification.new do |s|
|
|
244
252
|
else
|
245
253
|
s.add_dependency(%q<rails>, ["~> 3.1.0"])
|
246
254
|
s.add_dependency(%q<kaminari>, [">= 0"])
|
247
|
-
s.add_dependency(%q<
|
255
|
+
s.add_dependency(%q<orm_adapter>, [">= 0"])
|
248
256
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
257
|
+
s.add_dependency(%q<mongoid>, [">= 0"])
|
258
|
+
s.add_dependency(%q<bson_ext>, [">= 0"])
|
249
259
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
250
260
|
s.add_dependency(%q<capybara>, [">= 0"])
|
251
261
|
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Orms::MongoidTestsController < Puffer::Base
|
2
|
+
|
3
|
+
setup do
|
4
|
+
group :mongoid
|
5
|
+
end
|
6
|
+
|
7
|
+
index do
|
8
|
+
field :string_field
|
9
|
+
field :integer_field
|
10
|
+
field :array_field
|
11
|
+
end
|
12
|
+
|
13
|
+
form do
|
14
|
+
field :string_field
|
15
|
+
field :integer_field
|
16
|
+
field :array_field
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class MongoidTest
|
2
|
+
include Mongoid::Document
|
3
|
+
|
4
|
+
field :string_field, :type => String
|
5
|
+
field :integer_field, :type => Integer, :default => 0
|
6
|
+
field :array_field, :type => Array
|
7
|
+
|
8
|
+
def array_field= value
|
9
|
+
value = value.split(',').map(&:strip).map(&:presence) if value.is_a? String
|
10
|
+
write_attribute :array_field, value
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/lib/fields_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &10916560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *10916560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: kaminari
|
27
|
-
requirement: &
|
27
|
+
requirement: &10916000 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *10916000
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement: &
|
37
|
+
name: orm_adapter
|
38
|
+
requirement: &10915480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *10915480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: sqlite3
|
49
|
-
requirement: &
|
49
|
+
requirement: &10914960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,32 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *10914960
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mongoid
|
60
|
+
requirement: &10914380 !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: *10914380
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bson_ext
|
71
|
+
requirement: &10913880 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *10913880
|
58
80
|
- !ruby/object:Gem::Dependency
|
59
81
|
name: rspec-rails
|
60
|
-
requirement: &
|
82
|
+
requirement: &10913380 !ruby/object:Gem::Requirement
|
61
83
|
none: false
|
62
84
|
requirements:
|
63
85
|
- - ! '>='
|
@@ -65,10 +87,10 @@ dependencies:
|
|
65
87
|
version: '0'
|
66
88
|
type: :development
|
67
89
|
prerelease: false
|
68
|
-
version_requirements: *
|
90
|
+
version_requirements: *10913380
|
69
91
|
- !ruby/object:Gem::Dependency
|
70
92
|
name: capybara
|
71
|
-
requirement: &
|
93
|
+
requirement: &10912880 !ruby/object:Gem::Requirement
|
72
94
|
none: false
|
73
95
|
requirements:
|
74
96
|
- - ! '>='
|
@@ -76,10 +98,10 @@ dependencies:
|
|
76
98
|
version: '0'
|
77
99
|
type: :development
|
78
100
|
prerelease: false
|
79
|
-
version_requirements: *
|
101
|
+
version_requirements: *10912880
|
80
102
|
- !ruby/object:Gem::Dependency
|
81
103
|
name: database_cleaner
|
82
|
-
requirement: &
|
104
|
+
requirement: &10912260 !ruby/object:Gem::Requirement
|
83
105
|
none: false
|
84
106
|
requirements:
|
85
107
|
- - ! '>='
|
@@ -87,10 +109,10 @@ dependencies:
|
|
87
109
|
version: '0'
|
88
110
|
type: :development
|
89
111
|
prerelease: false
|
90
|
-
version_requirements: *
|
112
|
+
version_requirements: *10912260
|
91
113
|
- !ruby/object:Gem::Dependency
|
92
114
|
name: guard
|
93
|
-
requirement: &
|
115
|
+
requirement: &10911680 !ruby/object:Gem::Requirement
|
94
116
|
none: false
|
95
117
|
requirements:
|
96
118
|
- - ! '>='
|
@@ -98,10 +120,10 @@ dependencies:
|
|
98
120
|
version: '0'
|
99
121
|
type: :development
|
100
122
|
prerelease: false
|
101
|
-
version_requirements: *
|
123
|
+
version_requirements: *10911680
|
102
124
|
- !ruby/object:Gem::Dependency
|
103
125
|
name: libnotify
|
104
|
-
requirement: &
|
126
|
+
requirement: &10911140 !ruby/object:Gem::Requirement
|
105
127
|
none: false
|
106
128
|
requirements:
|
107
129
|
- - ! '>='
|
@@ -109,10 +131,10 @@ dependencies:
|
|
109
131
|
version: '0'
|
110
132
|
type: :development
|
111
133
|
prerelease: false
|
112
|
-
version_requirements: *
|
134
|
+
version_requirements: *10911140
|
113
135
|
- !ruby/object:Gem::Dependency
|
114
136
|
name: guard-rspec
|
115
|
-
requirement: &
|
137
|
+
requirement: &10910620 !ruby/object:Gem::Requirement
|
116
138
|
none: false
|
117
139
|
requirements:
|
118
140
|
- - ! '>='
|
@@ -120,10 +142,10 @@ dependencies:
|
|
120
142
|
version: '0'
|
121
143
|
type: :development
|
122
144
|
prerelease: false
|
123
|
-
version_requirements: *
|
145
|
+
version_requirements: *10910620
|
124
146
|
- !ruby/object:Gem::Dependency
|
125
147
|
name: forgery
|
126
|
-
requirement: &
|
148
|
+
requirement: &10910100 !ruby/object:Gem::Requirement
|
127
149
|
none: false
|
128
150
|
requirements:
|
129
151
|
- - ! '>='
|
@@ -131,10 +153,10 @@ dependencies:
|
|
131
153
|
version: '0'
|
132
154
|
type: :development
|
133
155
|
prerelease: false
|
134
|
-
version_requirements: *
|
156
|
+
version_requirements: *10910100
|
135
157
|
- !ruby/object:Gem::Dependency
|
136
158
|
name: fabrication
|
137
|
-
requirement: &
|
159
|
+
requirement: &10909540 !ruby/object:Gem::Requirement
|
138
160
|
none: false
|
139
161
|
requirements:
|
140
162
|
- - ! '>='
|
@@ -142,10 +164,10 @@ dependencies:
|
|
142
164
|
version: '0'
|
143
165
|
type: :development
|
144
166
|
prerelease: false
|
145
|
-
version_requirements: *
|
167
|
+
version_requirements: *10909540
|
146
168
|
- !ruby/object:Gem::Dependency
|
147
169
|
name: jeweler
|
148
|
-
requirement: &
|
170
|
+
requirement: &10908960 !ruby/object:Gem::Requirement
|
149
171
|
none: false
|
150
172
|
requirements:
|
151
173
|
- - ! '>='
|
@@ -153,10 +175,10 @@ dependencies:
|
|
153
175
|
version: '0'
|
154
176
|
type: :development
|
155
177
|
prerelease: false
|
156
|
-
version_requirements: *
|
178
|
+
version_requirements: *10908960
|
157
179
|
- !ruby/object:Gem::Dependency
|
158
180
|
name: nested_set
|
159
|
-
requirement: &
|
181
|
+
requirement: &10908460 !ruby/object:Gem::Requirement
|
160
182
|
none: false
|
161
183
|
requirements:
|
162
184
|
- - ! '>='
|
@@ -164,7 +186,7 @@ dependencies:
|
|
164
186
|
version: '0'
|
165
187
|
type: :development
|
166
188
|
prerelease: false
|
167
|
-
version_requirements: *
|
189
|
+
version_requirements: *10908460
|
168
190
|
description: In Soviet Russia puffer admins you
|
169
191
|
email: kinwizard@gmail.com
|
170
192
|
executables: []
|
@@ -257,10 +279,8 @@ files:
|
|
257
279
|
- lib/puffer/controller/actions.rb
|
258
280
|
- lib/puffer/controller/config.rb
|
259
281
|
- lib/puffer/controller/dsl.rb
|
260
|
-
- lib/puffer/controller/helpers.rb
|
261
282
|
- lib/puffer/controller/mutate.rb
|
262
283
|
- lib/puffer/engine.rb
|
263
|
-
- lib/puffer/extensions/activerecord.rb
|
264
284
|
- lib/puffer/extensions/controller.rb
|
265
285
|
- lib/puffer/extensions/core.rb
|
266
286
|
- lib/puffer/extensions/engine.rb
|
@@ -268,6 +288,9 @@ files:
|
|
268
288
|
- lib/puffer/extensions/mapper.rb
|
269
289
|
- lib/puffer/field.rb
|
270
290
|
- lib/puffer/field_set.rb
|
291
|
+
- lib/puffer/orm_adapter/active_record.rb
|
292
|
+
- lib/puffer/orm_adapter/base.rb
|
293
|
+
- lib/puffer/orm_adapter/mongoid.rb
|
271
294
|
- lib/puffer/resource.rb
|
272
295
|
- lib/puffer/resource/routing.rb
|
273
296
|
- lib/puffer/resource/scoping.rb
|
@@ -297,9 +320,11 @@ files:
|
|
297
320
|
- spec/dummy/app/controllers/admin/tags_controller.rb
|
298
321
|
- spec/dummy/app/controllers/admin/users_controller.rb
|
299
322
|
- spec/dummy/app/controllers/application_controller.rb
|
323
|
+
- spec/dummy/app/controllers/orms/mongoid_tests_controller.rb
|
300
324
|
- spec/dummy/app/helpers/application_helper.rb
|
301
325
|
- spec/dummy/app/models/category.rb
|
302
326
|
- spec/dummy/app/models/friendship.rb
|
327
|
+
- spec/dummy/app/models/mongoid_test.rb
|
303
328
|
- spec/dummy/app/models/news.rb
|
304
329
|
- spec/dummy/app/models/post.rb
|
305
330
|
- spec/dummy/app/models/post_category.rb
|
@@ -324,6 +349,7 @@ files:
|
|
324
349
|
- spec/dummy/config/initializers/session_store.rb
|
325
350
|
- spec/dummy/config/initializers/wrap_parameters.rb
|
326
351
|
- spec/dummy/config/locales/en.yml
|
352
|
+
- spec/dummy/config/mongoid.yml
|
327
353
|
- spec/dummy/config/routes.rb
|
328
354
|
- spec/dummy/db/migrate/20100930132559_create_users.rb
|
329
355
|
- spec/dummy/db/migrate/20100930132656_create_posts.rb
|
@@ -371,7 +397,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
371
397
|
version: '0'
|
372
398
|
segments:
|
373
399
|
- 0
|
374
|
-
hash:
|
400
|
+
hash: 2497691897434957664
|
375
401
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
376
402
|
none: false
|
377
403
|
requirements:
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Puffer
|
2
|
-
module Controller
|
3
|
-
module Helpers
|
4
|
-
|
5
|
-
def self.included base
|
6
|
-
base.class_eval do
|
7
|
-
include InstanceMethods
|
8
|
-
|
9
|
-
helper_method :resource_session, :resource, :record, :records
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module InstanceMethods
|
14
|
-
|
15
|
-
def resource
|
16
|
-
@resource ||= Puffer::Resource.new params, self
|
17
|
-
end
|
18
|
-
|
19
|
-
def record
|
20
|
-
@record || instance_variable_get("@#{resource.model_name}")
|
21
|
-
end
|
22
|
-
|
23
|
-
def records
|
24
|
-
@records || instance_variable_get("@#{resource.model_name.pluralize}")
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Puffer
|
2
|
-
module Extensions
|
3
|
-
module ActiveRecord
|
4
|
-
module Base
|
5
|
-
|
6
|
-
def call_chain chain
|
7
|
-
swallow_nil{instance_eval(chain.to_s)}
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_title
|
11
|
-
send title_method
|
12
|
-
end
|
13
|
-
|
14
|
-
def title_method
|
15
|
-
self.class.column_names.detect {|c| c =~ /name|title/} || self.class.column_names[1].to_sym
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
ActiveRecord::Base.send :include, Puffer::Extensions::ActiveRecord::Base
|