kitsune 0.0.19 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
 
3
3
  gem_spec = Gem::Specification.new do |gem_spec|
4
4
  gem_spec.name = "kitsune"
5
- gem_spec.version = "0.0.19"
5
+ gem_spec.version = "0.1.0"
6
6
  gem_spec.summary = "Integrated Rails Content Management System."
7
7
  gem_spec.email = "matt@toastyapps.com"
8
8
  gem_spec.homepage = "http://github.com/toastyapps/kitsune"
@@ -7,4 +7,5 @@
7
7
  = link_to key, value
8
8
 
9
9
  = render :partial => 'list', :locals => { :model => @model, :records => @records, :parent => nil }
10
- = will_paginate @records
10
+ - if defined? will_paginate
11
+ = will_paginate @records
data/lib/kitsune.rb CHANGED
@@ -8,7 +8,7 @@ module Kitsune
8
8
  autoload :Page, 'kitsune/page'
9
9
  class << self
10
10
  def version
11
- '0.0.19'
11
+ '0.1.0'
12
12
  end
13
13
 
14
14
  def model_paths # abstract this to something else
@@ -29,7 +29,11 @@ module Kitsune
29
29
  Dir.glob(path+'/*').each do |file|
30
30
  begin
31
31
  klass = File.basename(file).gsub(/^(.+).rb/, '\1').classify.constantize
32
- models << klass if klass.ancestors.include?(::ActiveRecord::Base)
32
+ if defined? ::ActiveRecord
33
+ models << klass if klass.ancestors.include?(::ActiveRecord::Base)
34
+ else defined? ::MongoMapper
35
+ models << klass if klass.ancestors.include?(::MongoMapper::Document)
36
+ end
33
37
  rescue Exception => e
34
38
  # not valid
35
39
  end
@@ -1,11 +1,8 @@
1
1
  module Kitsune
2
2
  class FauxColumn
3
- attr_accessor :name, :type
4
- def initialize(name, type)
5
- @name, @type = name, type
6
- end
7
- def primary
8
- false
3
+ attr_accessor :name, :type, :primary
4
+ def initialize(name, type, primary = false)
5
+ @name, @type, @primary = name, type, primary
9
6
  end
10
7
  end
11
8
  end
@@ -38,7 +38,11 @@ module Kitsune
38
38
  end
39
39
 
40
40
  def is_sti_child?
41
- @object.ancestors[1] != ::ActiveRecord::Base
41
+ if defined? ::ActiveRecord
42
+ @object.ancestors[1] != ::ActiveRecord::Base
43
+ else
44
+ false
45
+ end
42
46
  end
43
47
 
44
48
  def sti_column
@@ -132,7 +136,7 @@ module Kitsune
132
136
  else
133
137
  kitsune_admin[:fields][column.name.to_sym][:type]
134
138
  end
135
- elsif column.name =~ /_id$/
139
+ elsif column.name =~ /._id$/
136
140
  :select
137
141
  else
138
142
  case column.type
@@ -175,7 +179,7 @@ module Kitsune
175
179
  end
176
180
 
177
181
  def display_for(record, method, *args, &block)
178
- if method.to_s =~ /_id$/
182
+ if method.to_s =~ /._id$/
179
183
  associated_record = record.send(method.to_s.gsub(/_id$/, '').to_sym, *args, &block)
180
184
  label_method = detect_label(associated_record)
181
185
  associated_record.send(label_method.to_sym)
@@ -202,7 +206,7 @@ module Kitsune
202
206
 
203
207
  if field_type(field) == :select
204
208
  [field_options(field), {:include_blank => true}]
205
- elsif column.name =~ /_id$/
209
+ elsif column.name =~ /._id$/
206
210
  id = :id
207
211
  collection = find_association_class(column).all
208
212
  name = detect_label(collection)
@@ -0,0 +1,49 @@
1
+ require 'kitsune/builder'
2
+
3
+ module Kitsune
4
+ module MongoMapper
5
+ def setup_admin
6
+ self.class_eval do
7
+ class_inheritable_hash :kitsune_admin
8
+ self.kitsune_admin = {
9
+ :no_admin => false,
10
+ :multipart => false,
11
+ :display => {},
12
+ :edit => {},
13
+ :reflections => {},
14
+ :fields => {},
15
+ :tabs => {},
16
+ :is_sti => false,
17
+ :disabled => [],
18
+ :versioned => false,
19
+ :order_by => nil,
20
+ :media => nil # class to store images into
21
+ }
22
+ end
23
+ end
24
+
25
+ def admin &block
26
+ setup_admin unless self.respond_to?(:kitsune_admin)
27
+ Kitsune::Builder.generate(self, &block) unless self.kitsune_admin[:no_admin]
28
+ end
29
+
30
+ def no_admin
31
+ setup_admin
32
+ self.kitsune_admin[:no_admin] = true
33
+ end
34
+ TRANSPOSE = {String => :string}
35
+ def columns
36
+ self.keys.map do |key, value|
37
+ FauxColumn.new(key, TRANSPOSE[value.type], key == '_id')
38
+ end
39
+ end
40
+
41
+ def reflections
42
+ {}
43
+ end
44
+
45
+ def class_name
46
+ self.to_s
47
+ end
48
+ end
49
+ end
data/rails/init.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'kitsune'
2
2
  require 'haml' # From gem
3
- ActiveRecord::Base.extend(Kitsune::ActiveRecord)
3
+ if defined? ::ActiveRecord
4
+ ActiveRecord::Base.extend(Kitsune::ActiveRecord)
5
+ end
4
6
  Haml.init_rails(binding) if defined?(Haml)
5
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitsune
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Mongeau <matt@toastyapps.com>
@@ -350,6 +350,7 @@ files:
350
350
  - lib/kitsune/faux_column.rb
351
351
  - lib/kitsune/form_helper_ext.rb
352
352
  - lib/kitsune/inspector.rb
353
+ - lib/kitsune/mongo_mapper.rb
353
354
  - lib/kitsune/page.rb
354
355
  - lib/kitsune.rb
355
356
  - rails/init.rb