goat 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. data/lib/goat.rb +35 -12
  2. metadata +4 -4
data/lib/goat.rb CHANGED
@@ -589,7 +589,7 @@ module Goat
589
589
  id = req['_id']
590
590
  pg = active_pages[id]
591
591
 
592
- # active_page_gc # we do GC here since a slight delay in opening channel is better than in loading page
592
+ active_page_gc # we do GC here since a slight delay in opening channel is better than in loading page
593
593
 
594
594
  if pg
595
595
  pg.mark_alive!
@@ -623,7 +623,12 @@ module Goat
623
623
  if pg
624
624
  comp = pg.components.detect{|x| x.id == compid}
625
625
  Logger.error :req, "Couldn't find component #{compid.inspect}" unless comp
626
- yield comp if comp
626
+
627
+ if comp
628
+ yield comp
629
+ else
630
+ respond_failed
631
+ end
627
632
  else
628
633
  Logger.error(:req, "Couldn't find page #{id}")
629
634
 
@@ -778,15 +783,15 @@ module Goat
778
783
  app.class.add_active_page(pg)
779
784
  resp = pg.response
780
785
 
781
- app.class.active_page_gc
786
+ # app.class.active_page_gc
782
787
 
783
788
  action_hashes = 0
784
789
 
785
790
  ObjectSpace.each_object do |obj|
786
791
  if obj.kind_of?(Page) && obj.class != Class
787
- puts "Page: #{obj.glimpse}"
792
+ #puts "Page: #{obj.glimpse}"
788
793
  elsif obj.kind_of?(Component) && obj.class != Class
789
- puts "Component: #{obj.glimpse}"
794
+ #puts "Component: #{obj.glimpse}"
790
795
  elsif obj.kind_of?(ActionProc) && obj.class != Class
791
796
  action_hashes += 1
792
797
  end
@@ -805,7 +810,7 @@ module Goat
805
810
  @params = IndifferentHash.from_hash(request.params)
806
811
  end
807
812
 
808
- def components; @canvas.components; end
813
+ def components; @canvas.all_components; end
809
814
 
810
815
  def empty_response
811
816
  Rack::Response.new
@@ -855,10 +860,8 @@ module Goat
855
860
  comp_classes
856
861
  end
857
862
 
858
- def script
859
- cs = all_component_classes.to_a.reject do |cls|
860
- Goat.setting(:press) && Goat::Static.pressed?(cls)
861
- end
863
+ def ordered_component_classes
864
+ cs = all_component_classes.to_a
862
865
 
863
866
  i = 0
864
867
  # invariant: left of i has no superclasses to right
@@ -872,6 +875,18 @@ module Goat
872
875
  end
873
876
  end
874
877
 
878
+ cs
879
+ end
880
+
881
+ def unpressed_component_classes
882
+ ordered_component_classes.to_a.reject do |cls|
883
+ Goat.setting(:press) && Goat::Static.pressed?(cls)
884
+ end
885
+ end
886
+
887
+ def script
888
+ cs = unpressed_component_classes
889
+
875
890
  [
876
891
  cs.map(&:__script),
877
892
  @canvas.all_components.select{|c| c.class.wired?}.map(&:wire_script),
@@ -880,7 +895,7 @@ module Goat
880
895
  end
881
896
 
882
897
  def style
883
- @canvas.all_components.map(&:class).uniq.select(&:__css).map(&:scoped_css).join
898
+ unpressed_component_classes.select(&:__css).map(&:scoped_css).join
884
899
  end
885
900
  end
886
901
 
@@ -1061,8 +1076,16 @@ module Goat
1061
1076
  App.send(:define_method, "rpc_#{name}", blk)
1062
1077
  end
1063
1078
 
1079
+ def component_name_hierarchy(cls=self.class)
1080
+ if cls == Component
1081
+ []
1082
+ else
1083
+ component_name_hierarchy(cls.superclass) + [cls.name]
1084
+ end
1085
+ end
1086
+
1064
1087
  def component(body)
1065
- [:div, {:id => id, :class => self.class.name}, body]
1088
+ [:div, {:id => id, :class => component_name_hierarchy.join(' ')}, body]
1066
1089
  end
1067
1090
 
1068
1091
  def html; make_me; end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Collison
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-20 00:00:00 +00:00
18
+ date: 2010-09-22 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies: []
21
21