Permalink
Browse files

materialized path working correctly

  • Loading branch information...
1 parent 0b48236 commit 035e1bbc86d30cb2b45784c689f89a99e87b3233 @herbdaily committed Apr 1, 2012
Showing with 16 additions and 20 deletions.
  1. +1 −5 lib/marley/joints/forum.rb
  2. +4 −4 lib/marley/plugins/orm_materialized_path.rb
  3. +1 −1 marley.gemspec
  4. +1 −2 rdoc/forum_joint.rb
  5. +8 −7 rdoc/forum_load.rb
  6. +1 −1 reggae.ebnf
View
6 lib/marley/joints/forum.rb
@@ -36,11 +36,7 @@ module InstanceMethods
def thread_vals;values_tree;end
def thread; tree;end
def write_cols
- new? ? super.push(:topic_id, :path) : super
- end
- def before_save
- super
- self.topic_id||=self.class.max(:topic_id).to_i+1
+ new? ? super.push(:path) : super
end
def reply
new_child(:title => "re: #{title}")
View
8 lib/marley/plugins/orm_materialized_path.rb
@@ -33,15 +33,15 @@ def depth; path_arr.length; end
def rest_cols;super - [PATH_COL];end
def tree
- res=block_given? ? (yield self) : [self,[]]
+ res=[block_given? ? (yield self) : [self,[]]]
tree_ds.all.sort {|x,y| x.children_path_arr <=> y.children_path_arr}.each do |node|
- node.path_arr.inject(res) {|arr,i| arr[-1]} << (block_given? ? (yield node) : [node,[]])
+ (1..(node.path_arr.length*2)).inject(res) {|arr,i| arr[-1]} << (block_given? ? (yield node) : [node,[]])
end
- res
+ res[0]
end
def values_tree
tree do |n|
- foo=n.rest_cols.map{|c| n.send(c)} << []
+ n.rest_cols.map{|c| n.send(c)} << []
end
end
end
View
2 marley.gemspec
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = %q{marley}
- s.version = "0.8.1"
+ s.version = "0.8.2"
s.summary = %q{Irie default restful routes for models and other objects}
s.description = %q{Marley is a framework for quickly building RESTful web services and applications. Development is fast for two reasons: Marley implements lots of sensible defaults, all of which can be overridden and most of which can be overridden easily. And Marley servers exchange only data and metadata with clients. }
s.authors = ["Herb Daily"]
View
3 rdoc/forum_joint.rb
@@ -13,13 +13,12 @@
end
DB.create_table :messages do
primary_key :id
- integer :topic_id, :index => true
text :path, :index => true
integer :user_id, :index => true
datetime :date_created, :index => true
text :message_type, :index => true
text :title, :index => true,:null => false
- clob :content
+ clob :message
end
DB.create_table :messages_users do
primary_key :id
View
15 rdoc/forum_load.rb
@@ -6,11 +6,11 @@
Sequel::Model.send(:alias_method, :save!, :save)
USERS=5
-TOPICS=5
+TOPICS=40
TAGS=3
-REPLIES=[4,2]
+REPLIES=4
FactoryGirl.define do
- [:name,:title,:tag,:content].each do |seq|
+ [:name,:title,:tag,:message].each do |seq|
sequence seq do |n|
"#{seq.to_s}#{n}"
end
@@ -23,15 +23,15 @@
factory :post,:class => MR::PublicMessage do |n|
user
title
- content
+ message
_public_tags ''
_private_tags ''
end
factory :private_message,:class => MR::PrivateMessage do |n|
user
recipients ''
title
- content
+ message
_private_tags ''
end
factory :public_tag,:class => MR::PublicTag do |n|
@@ -50,10 +50,11 @@
end
end
end
-REPLIES.each do |r|
+REPLIES.times do
MR::PublicMessage.all.each do |m|
rep=m.reply
- rep.user_id=m[:id].modulo USERS
+ rep.user_id=m[:id].modulo(USERS) + 1
+ rep.message='asdfasdfasdfasdfasdfasdf'
rep.save
end
end
View
2 reggae.ebnf
@@ -35,7 +35,7 @@ new_rec_value ::= boolean_value
search_value ::= boolean_value
-schema_value ::= '[' col_spec | schema_value (',' colspec | schema_value)? ']'
+schema_value ::= '[' col_spec | instance_value | instance_list_value (',' colspec | instance_value | instance_list_value)? ']'
items_value ::= '[' '[' col_value (',' col_value)* ']' (',' '[' col_value (',' col_value)* ']')* ']'

0 comments on commit 035e1bb

Please sign in to comment.