togo 0.6.4 → 0.7.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/lib/togo.rb CHANGED
@@ -8,5 +8,10 @@ module Togo
8
8
 
9
9
  end
10
10
 
11
+ begin
12
+ require 'extlib'
13
+ rescue
14
+ require 'active_support'
15
+ end
11
16
  require 'togo/model'
12
17
  require 'togo/support'
@@ -62,12 +62,12 @@ module Togo
62
62
  end
63
63
 
64
64
  get '/edit/:model/:id' do
65
- @content = @model.get(params[:id])
65
+ @content = @model.first(:id => params[:id].to_i)
66
66
  erb :edit
67
67
  end
68
68
 
69
69
  post '/update/:model/:id' do
70
- @content = @model.stage_content(@model.get(params[:id]),params)
70
+ @content = @model.stage_content(@model.first(:id => params[:id].to_i),params)
71
71
  begin
72
72
  raise "Could not save content" if not @content.save
73
73
  redirect params[:return_url] || "/#{@model.name}"
@@ -30,7 +30,7 @@ module Togo
30
30
  @view_path = opts[:view_path] || 'views'
31
31
  @path_prefix = opts[:path_prefix]
32
32
  @path_prefix_regexp = Regexp.new("^#{@path_prefix}")
33
- ENV['RACK_ENV'] = (opts[:environment] || :development) if not ENV['RACK_ENV']
33
+ #ENV['RACK_ENV'] = (opts[:environment] || :development) if not ENV['RACK_ENV']
34
34
  end
35
35
 
36
36
  def symbolize_keys(hash)
@@ -50,7 +50,7 @@ module Togo
50
50
  end
51
51
 
52
52
  def update_content!(id,attrs)
53
- stage_content(get(id),attrs).save
53
+ stage_content(first(:id => id),attrs).save
54
54
  end
55
55
 
56
56
  def create_content!(attrs)
@@ -59,8 +59,8 @@ module Togo
59
59
 
60
60
  def stage_content(content,attrs)
61
61
  content.attributes = properties.inject({}){|m,p| attrs[p.name.to_sym] ? m.merge!(p.name.to_sym => attrs[p.name.to_sym]) : m}
62
- relationships.each do |r|
63
- val = attrs["related_#{r[0]}".to_sym]
62
+ relationships.each do |r|
63
+ val = attrs["related_#{r.name}".to_sym]
64
64
  next if not val or val == 'unset'
65
65
  content = RelationshipManager.create(content, r, :ids => val).relate
66
66
  end
@@ -126,7 +126,7 @@ module Togo
126
126
  when ::DataMapper::Associations::OneToMany::Relationship
127
127
  'has_n'
128
128
  when ::DataMapper::Property
129
- class_variable_get(:@@inflector).demodulize(property.type || property.class).downcase # type seems to be deprecated in 1.0
129
+ class_variable_get(:@@inflector).demodulize(property.class).downcase # type seems to be deprecated in 1.0
130
130
  else
131
131
  'string'
132
132
  end
@@ -163,18 +163,18 @@ module Togo
163
163
  end
164
164
 
165
165
  def shown_properties
166
- skip = relationships.values.collect{|r| r.through if r.respond_to?(:through) }.compact.uniq # don't include join models
167
- properties.select{|p| not BLACKLIST.include?(p.name) and not p.name =~ /_id$/} + relationships.values.select{|r| not skip.include?(r)}
166
+ skip = relationships.to_a.collect{|r| r.through if r.respond_to?(:through) }.compact.uniq # don't include join models
167
+ properties.select{|p| not BLACKLIST.include?(p.name) and not p.name =~ /_id$/} + relationships.to_a.select{|r| not skip.include?(r)}
168
168
  end
169
169
 
170
170
  def search_properties
171
171
  # Support dm 0.10.x and 1.x by checking for deprecated(?) types
172
- only_properties = [String, ::DataMapper::Types::Text]
172
+ only_properties = [String]
173
173
  begin # rescue exception when not using dm-core 1.0, these don't exist in the 0.10.x series
174
174
  only_properties.concat([::DataMapper::Property::String, ::DataMapper::Property::Text])
175
175
  rescue
176
176
  end
177
- properties.select{|p| only_properties.include?(p.type || p.class)} # type seems to be depracated in 1.0
177
+ properties.select{|p| only_properties.include?(p.class)} # type seems to be depracated in 1.0
178
178
  end
179
179
 
180
180
  end
@@ -3,7 +3,7 @@ module Togo
3
3
  class RelationshipManager
4
4
 
5
5
  def self.create(content, relationship, opts = {})
6
- case relationship[1]
6
+ case relationship
7
7
  when ::DataMapper::Associations::ManyToOne::Relationship
8
8
  ManyToOne.new(content, relationship, opts)
9
9
  when ::DataMapper::Associations::OneToMany::Relationship
@@ -13,8 +13,8 @@ module Togo
13
13
 
14
14
  def initialize(content, relationship, opts = {})
15
15
  @content = content
16
- @relationship = relationship[1]
17
- @relationship_name = relationship[0]
16
+ @relationship = relationship
17
+ @relationship_name = relationship.name
18
18
  @ids = (opts[:ids] || '').split(',').map(&:to_i)
19
19
  end
20
20
 
metadata CHANGED
@@ -1,48 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: togo
3
- version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 6
9
- - 4
10
- version: 0.6.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matt King
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-11-21 00:00:00 -08:00
12
+ date: 2011-06-30 00:00:00.000000000 -07:00
19
13
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: erubis
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2165171020 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">"
28
- - !ruby/object:Gem::Version
29
- hash: 31
30
- segments:
31
- - 0
32
- - 0
33
- - 0
19
+ requirements:
20
+ - - ! '>'
21
+ - !ruby/object:Gem::Version
34
22
  version: 0.0.0
35
23
  type: :runtime
36
- version_requirements: *id001
37
- description: With a few lines of code in your Ruby ORMs, you get a highly configurable and extensive content management tool (CMS).
24
+ prerelease: false
25
+ version_requirements: *2165171020
26
+ description: With a few lines of code in your Ruby ORMs, you get a highly configurable
27
+ and extensive content management tool (CMS).
38
28
  email: matt@mking.me
39
- executables:
29
+ executables:
40
30
  - togo-admin
41
31
  extensions: []
42
-
43
32
  extra_rdoc_files: []
44
-
45
- files:
33
+ files:
46
34
  - README.md
47
35
  - Changelog
48
36
  - LICENSE
@@ -99,39 +87,29 @@ files:
99
87
  has_rdoc: true
100
88
  homepage: http://github.com/mattking17/Togo/
101
89
  licenses: []
102
-
103
90
  post_install_message:
104
91
  rdoc_options: []
105
-
106
- require_paths:
92
+ require_paths:
107
93
  - lib
108
94
  - lib/togo/model
109
95
  - lib/togo/dispatch
110
96
  - lib/togo/admin
111
- required_ruby_version: !ruby/object:Gem::Requirement
97
+ required_ruby_version: !ruby/object:Gem::Requirement
112
98
  none: false
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- hash: 3
117
- segments:
118
- - 0
119
- version: "0"
120
- required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
104
  none: false
122
- requirements:
123
- - - ">="
124
- - !ruby/object:Gem::Version
125
- hash: 3
126
- segments:
127
- - 0
128
- version: "0"
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
129
109
  requirements: []
130
-
131
110
  rubyforge_project:
132
- rubygems_version: 1.3.7
111
+ rubygems_version: 1.6.2
133
112
  signing_key:
134
113
  specification_version: 3
135
114
  summary: CMS Framework for Ruby ORMs
136
115
  test_files: []
137
-