puffer 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails', '~> 3.0.3'
3
+ gem 'rails', '~> 3.0.4'
4
4
  gem 'will_paginate', '~> 3.0.pre2'
5
5
  gem 'cells', '~> 3.4.4'
6
6
 
data/Gemfile.lock CHANGED
@@ -3,37 +3,37 @@ GEM
3
3
  specs:
4
4
  ZenTest (4.4.2)
5
5
  abstract (1.0.0)
6
- actionmailer (3.0.3)
7
- actionpack (= 3.0.3)
8
- mail (~> 2.2.9)
9
- actionpack (3.0.3)
10
- activemodel (= 3.0.3)
11
- activesupport (= 3.0.3)
6
+ actionmailer (3.0.4)
7
+ actionpack (= 3.0.4)
8
+ mail (~> 2.2.15)
9
+ actionpack (3.0.4)
10
+ activemodel (= 3.0.4)
11
+ activesupport (= 3.0.4)
12
12
  builder (~> 2.1.2)
13
13
  erubis (~> 2.6.6)
14
14
  i18n (~> 0.4)
15
15
  rack (~> 1.2.1)
16
16
  rack-mount (~> 0.6.13)
17
- rack-test (~> 0.5.6)
17
+ rack-test (~> 0.5.7)
18
18
  tzinfo (~> 0.3.23)
19
- activemodel (3.0.3)
20
- activesupport (= 3.0.3)
19
+ activemodel (3.0.4)
20
+ activesupport (= 3.0.4)
21
21
  builder (~> 2.1.2)
22
22
  i18n (~> 0.4)
23
- activerecord (3.0.3)
24
- activemodel (= 3.0.3)
25
- activesupport (= 3.0.3)
23
+ activerecord (3.0.4)
24
+ activemodel (= 3.0.4)
25
+ activesupport (= 3.0.4)
26
26
  arel (~> 2.0.2)
27
27
  tzinfo (~> 0.3.23)
28
- activeresource (3.0.3)
29
- activemodel (= 3.0.3)
30
- activesupport (= 3.0.3)
31
- activesupport (3.0.3)
32
- arel (2.0.6)
28
+ activeresource (3.0.4)
29
+ activemodel (= 3.0.4)
30
+ activesupport (= 3.0.4)
31
+ activesupport (3.0.4)
32
+ arel (2.0.8)
33
33
  autotest (4.4.6)
34
34
  ZenTest (>= 4.4.1)
35
35
  builder (2.1.2)
36
- capybara (0.4.0)
36
+ capybara (0.4.1.2)
37
37
  celerity (>= 0.7.9)
38
38
  culerity (>= 0.2.4)
39
39
  mime-types (>= 1.16)
@@ -41,22 +41,23 @@ GEM
41
41
  rack (>= 1.0.0)
42
42
  rack-test (>= 0.5.4)
43
43
  selenium-webdriver (>= 0.0.27)
44
- xpath (~> 0.1.2)
45
- celerity (0.8.6)
44
+ xpath (~> 0.1.3)
45
+ celerity (0.8.8)
46
46
  cells (3.4.4)
47
47
  cgi_multipart_eof_fix (2.5.0)
48
- childprocess (0.1.6)
48
+ childprocess (0.1.7)
49
49
  ffi (~> 0.6.3)
50
- culerity (0.2.13)
50
+ culerity (0.2.15)
51
51
  daemons (1.1.0)
52
52
  diff-lcs (1.1.2)
53
53
  erubis (2.6.6)
54
54
  abstract (>= 1.0.0)
55
- fabrication (0.9.4)
55
+ fabrication (0.9.5)
56
56
  fastthread (1.0.7)
57
57
  ffi (0.6.3)
58
58
  rake (>= 0.8.7)
59
- forgery (0.3.6)
59
+ forgery (0.3.7)
60
+ nokogiri (~> 1.4)
60
61
  gem_plugin (0.2.3)
61
62
  git (1.2.5)
62
63
  i18n (0.5.0)
@@ -64,8 +65,8 @@ GEM
64
65
  bundler (~> 1.0.0)
65
66
  git (>= 1.2.5)
66
67
  rake
67
- json_pure (1.4.6)
68
- mail (2.2.13)
68
+ json_pure (1.5.1)
69
+ mail (2.2.15)
69
70
  activesupport (>= 2.3.6)
70
71
  i18n (>= 0.4.0)
71
72
  mime-types (~> 1.16)
@@ -81,48 +82,50 @@ GEM
81
82
  rack (1.2.1)
82
83
  rack-mount (0.6.13)
83
84
  rack (>= 1.0.0)
84
- rack-test (0.5.6)
85
+ rack-test (0.5.7)
85
86
  rack (>= 1.0)
86
- rails (3.0.3)
87
- actionmailer (= 3.0.3)
88
- actionpack (= 3.0.3)
89
- activerecord (= 3.0.3)
90
- activeresource (= 3.0.3)
91
- activesupport (= 3.0.3)
87
+ rails (3.0.4)
88
+ actionmailer (= 3.0.4)
89
+ actionpack (= 3.0.4)
90
+ activerecord (= 3.0.4)
91
+ activeresource (= 3.0.4)
92
+ activesupport (= 3.0.4)
92
93
  bundler (~> 1.0)
93
- railties (= 3.0.3)
94
- railties (3.0.3)
95
- actionpack (= 3.0.3)
96
- activesupport (= 3.0.3)
94
+ railties (= 3.0.4)
95
+ railties (3.0.4)
96
+ actionpack (= 3.0.4)
97
+ activesupport (= 3.0.4)
97
98
  rake (>= 0.8.7)
98
99
  thor (~> 0.14.4)
99
100
  rake (0.8.7)
100
- rspec (2.3.0)
101
- rspec-core (~> 2.3.0)
102
- rspec-expectations (~> 2.3.0)
103
- rspec-mocks (~> 2.3.0)
104
- rspec-core (2.3.1)
105
- rspec-expectations (2.3.0)
101
+ rspec (2.5.0)
102
+ rspec-core (~> 2.5.0)
103
+ rspec-expectations (~> 2.5.0)
104
+ rspec-mocks (~> 2.5.0)
105
+ rspec-core (2.5.1)
106
+ rspec-expectations (2.5.0)
106
107
  diff-lcs (~> 1.1.2)
107
- rspec-mocks (2.3.0)
108
- rspec-rails (2.3.1)
108
+ rspec-mocks (2.5.0)
109
+ rspec-rails (2.5.0)
109
110
  actionpack (~> 3.0)
110
111
  activesupport (~> 3.0)
111
112
  railties (~> 3.0)
112
- rspec (~> 2.3.0)
113
+ rspec (~> 2.5.0)
113
114
  rubyzip (0.9.4)
114
- selenium-webdriver (0.1.2)
115
+ selenium-webdriver (0.1.3)
115
116
  childprocess (~> 0.1.5)
116
117
  ffi (~> 0.6.3)
117
118
  json_pure
118
119
  rubyzip
119
- sqlite3-ruby (1.3.2)
120
+ sqlite3 (1.3.3)
121
+ sqlite3-ruby (1.3.3)
122
+ sqlite3 (>= 1.3.3)
120
123
  thor (0.14.6)
121
124
  treetop (1.4.9)
122
125
  polyglot (>= 0.3.1)
123
- tzinfo (0.3.23)
126
+ tzinfo (0.3.24)
124
127
  will_paginate (3.0.pre2)
125
- xpath (0.1.2)
128
+ xpath (0.1.3)
126
129
  nokogiri (~> 1.3)
127
130
 
128
131
  PLATFORMS
@@ -136,7 +139,7 @@ DEPENDENCIES
136
139
  forgery
137
140
  jeweler
138
141
  mongrel
139
- rails (~> 3.0.3)
142
+ rails (~> 3.0.4)
140
143
  rspec-rails
141
144
  sqlite3-ruby
142
145
  will_paginate (~> 3.0.pre2)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.18
1
+ 0.0.19
@@ -13,7 +13,7 @@ module PufferHelper
13
13
  def puffer_navigation
14
14
  Rails.application.routes.puffer[namespace].values.map(&:first).each do |controller|
15
15
  title = controller.configuration.group.to_s.humanize
16
- path = send("#{namespace}_#{controller.controller_name}_path")
16
+ path = polymorphic_url [namespace, controller.model]
17
17
  current = configuration.group && resource.root.controller.configuration.group == controller.configuration.group
18
18
  yield title, path, current
19
19
  end
@@ -22,7 +22,7 @@ module PufferHelper
22
22
  def sidebar_puffer_navigation
23
23
  (Rails.application.routes.puffer[namespace][configuration.group] || []).each do |controller|
24
24
  title = controller.model.model_name.human
25
- path = send("#{namespace}_#{controller.controller_name}_path")
25
+ path = polymorphic_url [namespace, controller.model]
26
26
  current = controller.controller_name == resource.root.controller_name
27
27
  yield title, path, current
28
28
  end
@@ -7,7 +7,7 @@
7
7
  <ul class="additional">
8
8
  <% controllers.each do |controller| %>
9
9
  <li>
10
- <%= link_to controller.model.model_name.human, send("#{namespace}_#{controller.controller_name}_path") %>
10
+ <%= link_to controller.model.model_name.human, polymorphic_url([namespace, controller.model]) %>
11
11
  </li>
12
12
  <% end %>
13
13
  </ul>
@@ -2,7 +2,7 @@ class Puffer::ControllerGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
 
4
4
  def generate_controller
5
- @modules = name.classify.split('::')
5
+ @modules = name.camelize.split('::')
6
6
  @model_name = @modules.delete_at(-1)
7
7
 
8
8
  template 'controller.rb', "app/controllers/#{controller_name.underscore}_controller.rb"
@@ -40,7 +40,7 @@ module Puffer
40
40
  end
41
41
 
42
42
  def model
43
- @model ||= model_name.classify.constantize rescue nil
43
+ @model ||= model_name.camelize.constantize rescue nil
44
44
  end
45
45
 
46
46
  def view_paths_fallbacks *args
@@ -0,0 +1,63 @@
1
+ module Puffer
2
+ module Customs
3
+
4
+ # Custom field types
5
+
6
+ mattr_accessor :types
7
+ self.types = []
8
+
9
+ def self.map_type &block
10
+ types.unshift block if block_given?
11
+ end
12
+
13
+ def self.type_for field
14
+ swallow_nil{ types.detect { |offer| offer.call(field) }.call(field) }
15
+ end
16
+
17
+ map_type { |field| :select if field.options.key?(:select) }
18
+ map_type { |field| :password if field.name =~ /password/ }
19
+ map_type { |field| swallow_nil{ field.reflection.macro } }
20
+
21
+
22
+ # Custom inputs
23
+
24
+ mattr_accessor :inputs
25
+ self.inputs = {}
26
+
27
+ def self.map_input *args
28
+ to = args.extract_options![:to]
29
+ args.each { |type| inputs[type] = to }
30
+ end
31
+
32
+ def self.input_for field
33
+ inputs[field.type] || ("Puffer::Inputs::#{field.type.to_s.camelize}".constantize rescue Puffer::Inputs::Base)
34
+ end
35
+
36
+ map_input :belongs_to, :has_one, :to => Puffer::Inputs::Association
37
+ map_input :has_many, :has_and_belongs_to_many, :to => Puffer::Inputs::CollectionAssociation
38
+ map_input :date, :time, :datetime, :timestamp, :to => Puffer::Inputs::DateTime
39
+
40
+
41
+ # Customs renderers
42
+
43
+ mattr_accessor :renderers
44
+ self.renderers = {}
45
+
46
+ def self.map_renderer *args
47
+ to = args.extract_options![:to]
48
+ args.each { |type| renderers[type] = to }
49
+ end
50
+
51
+
52
+ # Customs filters
53
+
54
+ mattr_accessor :filters
55
+ self.filters = {}
56
+
57
+ def self.map_filter *args
58
+ to = args.extract_options![:to]
59
+ args.each { |type| filters[type] = to }
60
+ end
61
+
62
+ end
63
+ end
@@ -10,8 +10,7 @@ module Puffer
10
10
  Puffer::Fields::Field.new args, options
11
11
  end
12
12
  field.resource = object.class
13
- input = Puffer::Inputs.map_field field
14
- input.new(self, @template, field).render
13
+ field.input self
15
14
  end
16
15
 
17
16
  end
@@ -31,7 +31,7 @@ module Puffer
31
31
  end
32
32
 
33
33
  def type
34
- @type ||= options[:type] ? options[:type].to_sym : (Puffer::Fields.offered_type(self) || (column ? column.type : :string))
34
+ @type ||= options[:type] ? options[:type].to_sym : (Puffer::Customs.type_for(self) || (column ? column.type : :string))
35
35
  end
36
36
 
37
37
  def to_s
@@ -50,6 +50,10 @@ module Puffer
50
50
  options[:html] || {}
51
51
  end
52
52
 
53
+ def input builder
54
+ Puffer::Customs.input_for(self).render builder, self
55
+ end
56
+
53
57
  def model
54
58
  @model ||= begin
55
59
  associations = field.split('.')
data/lib/puffer/fields.rb CHANGED
@@ -1,27 +1,6 @@
1
1
  module Puffer
2
2
  class Fields < Array
3
3
 
4
- class_attribute :offers
5
- self.offers = []
6
-
7
- def self.offer_type &block
8
- offers.push block if block_given?
9
- end
10
-
11
- def self.offered_type field
12
- swallow_nil{ offers.detect { |offer| offer.call(field) }.call(field) }
13
- end
14
-
15
- offer_type do |field|
16
- :select if field.options.key?(:select)
17
- end
18
- offer_type do |field|
19
- :password if field.name =~ /password/
20
- end
21
- offer_type do |field|
22
- swallow_nil{ field.reflection.macro }
23
- end
24
-
25
4
  def field *args
26
5
  push Field.new(*args)
27
6
  last
@@ -4,10 +4,14 @@ module Puffer
4
4
 
5
5
  attr_accessor :builder, :template, :field
6
6
 
7
- def initialize builder, template, field
7
+ def self.render *args
8
+ new(*args).render
9
+ end
10
+
11
+ def initialize builder, field
8
12
  @builder = builder
9
13
  @field = field
10
- @template = template
14
+ @template = builder.instance_variable_get :@template
11
15
  end
12
16
 
13
17
  def render
@@ -6,7 +6,7 @@ module Puffer
6
6
  include Rails.application.routes.url_helpers
7
7
 
8
8
  def collection_url *args
9
- polymorphic_url *route_args(route_member(controller_name), *args)
9
+ polymorphic_url *route_args(route_member(model), *args)
10
10
  end
11
11
 
12
12
  def member_url *args
data/lib/puffer.rb CHANGED
@@ -13,6 +13,10 @@ module Puffer
13
13
  yield self
14
14
  end
15
15
 
16
+ def self.customs
17
+ Puffer::Customs
18
+ end
19
+
16
20
  end
17
21
 
18
22
  require 'will_paginate'
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.18"
8
+ s.version = "0.0.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["pyromaniac"]
12
- s.date = %q{2011-02-12}
12
+ s.date = %q{2011-03-01}
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 = [
@@ -68,6 +68,7 @@ Gem::Specification.new do |s|
68
68
  "lib/puffer/controller/helpers.rb",
69
69
  "lib/puffer/controller/mapping.rb",
70
70
  "lib/puffer/controller/mutate.rb",
71
+ "lib/puffer/customs.rb",
71
72
  "lib/puffer/engine.rb",
72
73
  "lib/puffer/extensions/activerecord.rb",
73
74
  "lib/puffer/extensions/controller.rb",
@@ -76,7 +77,6 @@ Gem::Specification.new do |s|
76
77
  "lib/puffer/extensions/mapper.rb",
77
78
  "lib/puffer/fields.rb",
78
79
  "lib/puffer/fields/field.rb",
79
- "lib/puffer/inputs.rb",
80
80
  "lib/puffer/inputs/association.rb",
81
81
  "lib/puffer/inputs/base.rb",
82
82
  "lib/puffer/inputs/boolean.rb",
@@ -94,6 +94,7 @@ Gem::Specification.new do |s|
94
94
  "puffer.gemspec",
95
95
  "spec/dummy/Rakefile",
96
96
  "spec/dummy/app/controllers/admin/categories_controller.rb",
97
+ "spec/dummy/app/controllers/admin/news_controller.rb",
97
98
  "spec/dummy/app/controllers/admin/posts_controller.rb",
98
99
  "spec/dummy/app/controllers/admin/profiles_controller.rb",
99
100
  "spec/dummy/app/controllers/admin/tags_controller.rb",
@@ -104,6 +105,7 @@ Gem::Specification.new do |s|
104
105
  "spec/dummy/app/helpers/application_helper.rb",
105
106
  "spec/dummy/app/models/category.rb",
106
107
  "spec/dummy/app/models/friendship.rb",
108
+ "spec/dummy/app/models/news.rb",
107
109
  "spec/dummy/app/models/post.rb",
108
110
  "spec/dummy/app/models/post_category.rb",
109
111
  "spec/dummy/app/models/profile.rb",
@@ -135,6 +137,7 @@ Gem::Specification.new do |s|
135
137
  "spec/dummy/db/migrate/20101011155830_create_tags.rb",
136
138
  "spec/dummy/db/migrate/20101011160326_create_taggings.rb",
137
139
  "spec/dummy/db/migrate/20110107082706_create_friendships.rb",
140
+ "spec/dummy/db/migrate/20110301072545_create_news.rb",
138
141
  "spec/dummy/db/schema.rb",
139
142
  "spec/dummy/public/404.html",
140
143
  "spec/dummy/public/422.html",
@@ -156,6 +159,7 @@ Gem::Specification.new do |s|
156
159
  "spec/dummy/public/stylesheets/.gitkeep",
157
160
  "spec/dummy/script/rails",
158
161
  "spec/fabricators/categories_fabricator.rb",
162
+ "spec/fabricators/news_fabricator.rb",
159
163
  "spec/fabricators/posts_fabricator.rb",
160
164
  "spec/fabricators/profiles_fabricator.rb",
161
165
  "spec/fabricators/tags_fabricator.rb",
@@ -176,6 +180,7 @@ Gem::Specification.new do |s|
176
180
  s.summary = %q{Admin interface builder}
177
181
  s.test_files = [
178
182
  "spec/dummy/app/controllers/admin/categories_controller.rb",
183
+ "spec/dummy/app/controllers/admin/news_controller.rb",
179
184
  "spec/dummy/app/controllers/admin/posts_controller.rb",
180
185
  "spec/dummy/app/controllers/admin/profiles_controller.rb",
181
186
  "spec/dummy/app/controllers/admin/tags_controller.rb",
@@ -186,6 +191,7 @@ Gem::Specification.new do |s|
186
191
  "spec/dummy/app/helpers/application_helper.rb",
187
192
  "spec/dummy/app/models/category.rb",
188
193
  "spec/dummy/app/models/friendship.rb",
194
+ "spec/dummy/app/models/news.rb",
189
195
  "spec/dummy/app/models/post.rb",
190
196
  "spec/dummy/app/models/post_category.rb",
191
197
  "spec/dummy/app/models/profile.rb",
@@ -213,8 +219,10 @@ Gem::Specification.new do |s|
213
219
  "spec/dummy/db/migrate/20101011155830_create_tags.rb",
214
220
  "spec/dummy/db/migrate/20101011160326_create_taggings.rb",
215
221
  "spec/dummy/db/migrate/20110107082706_create_friendships.rb",
222
+ "spec/dummy/db/migrate/20110301072545_create_news.rb",
216
223
  "spec/dummy/db/schema.rb",
217
224
  "spec/fabricators/categories_fabricator.rb",
225
+ "spec/fabricators/news_fabricator.rb",
218
226
  "spec/fabricators/posts_fabricator.rb",
219
227
  "spec/fabricators/profiles_fabricator.rb",
220
228
  "spec/fabricators/tags_fabricator.rb",
@@ -234,7 +242,7 @@ Gem::Specification.new do |s|
234
242
  s.specification_version = 3
235
243
 
236
244
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
237
- s.add_runtime_dependency(%q<rails>, ["~> 3.0.3"])
245
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0.4"])
238
246
  s.add_runtime_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
239
247
  s.add_runtime_dependency(%q<cells>, ["~> 3.4.4"])
240
248
  s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
@@ -246,7 +254,7 @@ Gem::Specification.new do |s|
246
254
  s.add_development_dependency(%q<jeweler>, [">= 0"])
247
255
  s.add_development_dependency(%q<mongrel>, [">= 0"])
248
256
  else
249
- s.add_dependency(%q<rails>, ["~> 3.0.3"])
257
+ s.add_dependency(%q<rails>, ["~> 3.0.4"])
250
258
  s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
251
259
  s.add_dependency(%q<cells>, ["~> 3.4.4"])
252
260
  s.add_dependency(%q<capybara>, [">= 0.4.0"])
@@ -259,7 +267,7 @@ Gem::Specification.new do |s|
259
267
  s.add_dependency(%q<mongrel>, [">= 0"])
260
268
  end
261
269
  else
262
- s.add_dependency(%q<rails>, ["~> 3.0.3"])
270
+ s.add_dependency(%q<rails>, ["~> 3.0.4"])
263
271
  s.add_dependency(%q<will_paginate>, ["~> 3.0.pre2"])
264
272
  s.add_dependency(%q<cells>, ["~> 3.4.4"])
265
273
  s.add_dependency(%q<capybara>, [">= 0.4.0"])
@@ -0,0 +1,17 @@
1
+ class Admin::NewsController < Puffer::Base
2
+
3
+ setup do
4
+ group :news
5
+ end
6
+
7
+ index do
8
+ field :title
9
+ field :body
10
+ end
11
+
12
+ form do
13
+ field :title
14
+ field :body
15
+ end
16
+
17
+ end
@@ -0,0 +1,2 @@
1
+ class News < ActiveRecord::Base
2
+ end
@@ -1,5 +1,7 @@
1
1
  Dummy::Application.routes.draw do
2
2
 
3
+ match '/admin' => 'puffer/dashboard#index', :as => :admin
4
+
3
5
  namespace :puffer do
4
6
  root :to => 'dashboard#index'
5
7
  resource :session
@@ -25,6 +27,7 @@ Dummy::Application.routes.draw do
25
27
  resources :categories do
26
28
  resources :posts
27
29
  end
30
+ resources :news
28
31
  end
29
32
 
30
33
  end
@@ -0,0 +1,14 @@
1
+ class CreateNews < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :news do |t|
4
+ t.string :title
5
+ t.text :body
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :news
13
+ end
14
+ end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended to check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(:version => 20110107082706) do
13
+ ActiveRecord::Schema.define(:version => 20110301072545) do
14
14
 
15
15
  create_table "categories", :force => true do |t|
16
16
  t.string "title"
@@ -26,6 +26,13 @@ ActiveRecord::Schema.define(:version => 20110107082706) do
26
26
  t.datetime "updated_at"
27
27
  end
28
28
 
29
+ create_table "news", :force => true do |t|
30
+ t.string "title"
31
+ t.text "body"
32
+ t.datetime "created_at"
33
+ t.datetime "updated_at"
34
+ end
35
+
29
36
  create_table "post_categories", :force => true do |t|
30
37
  t.integer "post_id"
31
38
  t.integer "category_id"
@@ -0,0 +1,5 @@
1
+ Fabricator :news do
2
+ title { Forgery::LoremIpsum.sentence }
3
+ body { Forgery::LoremIpsum.paragraphs 3 }
4
+ end
5
+
@@ -19,6 +19,21 @@ describe Puffer::Resource do
19
19
  resource.edit_path(@mock_category).should == edit_admin_category_path(@mock_category)
20
20
  end
21
21
 
22
+ it "regular path with plural model name" do
23
+ @news = Fabricate :news
24
+ @mock_news = mock_model News, :id => 42
25
+
26
+ get admin_news_path(@news)
27
+ resource = Puffer::Resource.new request.params.merge(:controller => 'admin/news', :action => 'show'), request
28
+
29
+ resource.collection_path.should == admin_news_index_path
30
+ resource.member_path.should == admin_news_path(@news)
31
+ resource.member_path(@mock_news).should == admin_news_path(@mock_news)
32
+ resource.new_path.should == new_admin_news_path
33
+ resource.edit_path.should == edit_admin_news_path(@news)
34
+ resource.edit_path(@mock_news).should == edit_admin_news_path(@mock_news)
35
+ end
36
+
22
37
  it "plural path" do
23
38
  @post = Fabricate :post_with_categories
24
39
  @category = @post.categories.first
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 18
10
- version: 0.0.18
9
+ - 19
10
+ version: 0.0.19
11
11
  platform: ruby
12
12
  authors:
13
13
  - pyromaniac
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-12 00:00:00 +03:00
18
+ date: 2011-03-01 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 1
28
+ hash: 15
29
29
  segments:
30
30
  - 3
31
31
  - 0
32
- - 3
33
- version: 3.0.3
32
+ - 4
33
+ version: 3.0.4
34
34
  requirement: *id001
35
35
  prerelease: false
36
36
  name: rails
@@ -242,6 +242,7 @@ files:
242
242
  - lib/puffer/controller/helpers.rb
243
243
  - lib/puffer/controller/mapping.rb
244
244
  - lib/puffer/controller/mutate.rb
245
+ - lib/puffer/customs.rb
245
246
  - lib/puffer/engine.rb
246
247
  - lib/puffer/extensions/activerecord.rb
247
248
  - lib/puffer/extensions/controller.rb
@@ -250,7 +251,6 @@ files:
250
251
  - lib/puffer/extensions/mapper.rb
251
252
  - lib/puffer/fields.rb
252
253
  - lib/puffer/fields/field.rb
253
- - lib/puffer/inputs.rb
254
254
  - lib/puffer/inputs/association.rb
255
255
  - lib/puffer/inputs/base.rb
256
256
  - lib/puffer/inputs/boolean.rb
@@ -268,6 +268,7 @@ files:
268
268
  - puffer.gemspec
269
269
  - spec/dummy/Rakefile
270
270
  - spec/dummy/app/controllers/admin/categories_controller.rb
271
+ - spec/dummy/app/controllers/admin/news_controller.rb
271
272
  - spec/dummy/app/controllers/admin/posts_controller.rb
272
273
  - spec/dummy/app/controllers/admin/profiles_controller.rb
273
274
  - spec/dummy/app/controllers/admin/tags_controller.rb
@@ -278,6 +279,7 @@ files:
278
279
  - spec/dummy/app/helpers/application_helper.rb
279
280
  - spec/dummy/app/models/category.rb
280
281
  - spec/dummy/app/models/friendship.rb
282
+ - spec/dummy/app/models/news.rb
281
283
  - spec/dummy/app/models/post.rb
282
284
  - spec/dummy/app/models/post_category.rb
283
285
  - spec/dummy/app/models/profile.rb
@@ -309,6 +311,7 @@ files:
309
311
  - spec/dummy/db/migrate/20101011155830_create_tags.rb
310
312
  - spec/dummy/db/migrate/20101011160326_create_taggings.rb
311
313
  - spec/dummy/db/migrate/20110107082706_create_friendships.rb
314
+ - spec/dummy/db/migrate/20110301072545_create_news.rb
312
315
  - spec/dummy/db/schema.rb
313
316
  - spec/dummy/public/404.html
314
317
  - spec/dummy/public/422.html
@@ -330,6 +333,7 @@ files:
330
333
  - spec/dummy/public/stylesheets/.gitkeep
331
334
  - spec/dummy/script/rails
332
335
  - spec/fabricators/categories_fabricator.rb
336
+ - spec/fabricators/news_fabricator.rb
333
337
  - spec/fabricators/posts_fabricator.rb
334
338
  - spec/fabricators/profiles_fabricator.rb
335
339
  - spec/fabricators/tags_fabricator.rb
@@ -379,6 +383,7 @@ specification_version: 3
379
383
  summary: Admin interface builder
380
384
  test_files:
381
385
  - spec/dummy/app/controllers/admin/categories_controller.rb
386
+ - spec/dummy/app/controllers/admin/news_controller.rb
382
387
  - spec/dummy/app/controllers/admin/posts_controller.rb
383
388
  - spec/dummy/app/controllers/admin/profiles_controller.rb
384
389
  - spec/dummy/app/controllers/admin/tags_controller.rb
@@ -389,6 +394,7 @@ test_files:
389
394
  - spec/dummy/app/helpers/application_helper.rb
390
395
  - spec/dummy/app/models/category.rb
391
396
  - spec/dummy/app/models/friendship.rb
397
+ - spec/dummy/app/models/news.rb
392
398
  - spec/dummy/app/models/post.rb
393
399
  - spec/dummy/app/models/post_category.rb
394
400
  - spec/dummy/app/models/profile.rb
@@ -416,8 +422,10 @@ test_files:
416
422
  - spec/dummy/db/migrate/20101011155830_create_tags.rb
417
423
  - spec/dummy/db/migrate/20101011160326_create_taggings.rb
418
424
  - spec/dummy/db/migrate/20110107082706_create_friendships.rb
425
+ - spec/dummy/db/migrate/20110301072545_create_news.rb
419
426
  - spec/dummy/db/schema.rb
420
427
  - spec/fabricators/categories_fabricator.rb
428
+ - spec/fabricators/news_fabricator.rb
421
429
  - spec/fabricators/posts_fabricator.rb
422
430
  - spec/fabricators/profiles_fabricator.rb
423
431
  - spec/fabricators/tags_fabricator.rb
data/lib/puffer/inputs.rb DELETED
@@ -1,21 +0,0 @@
1
- module Puffer
2
- module Inputs
3
-
4
- mattr_accessor :mappings
5
- self.mappings = {}
6
-
7
- def self.map_type *args
8
- to = args.extract_options![:to]
9
- args.each { |type| mappings[type] = to }
10
- end
11
-
12
- map_type :belongs_to, :has_one, :to => Puffer::Inputs::Association
13
- map_type :has_many, :has_and_belongs_to_many, :to => Puffer::Inputs::CollectionAssociation
14
- map_type :date, :time, :datetime, :timestamp, :to => Puffer::Inputs::DateTime
15
-
16
- def self.map_field field
17
- mappings[field.type] || ("Puffer::Inputs::#{field.type.to_s.camelize}".constantize rescue Puffer::Inputs::Base)
18
- end
19
-
20
- end
21
- end