sproutcore 1.6.0.1 → 1.7.1.beta

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 (143) hide show
  1. data/CHANGELOG +21 -0
  2. data/Gemfile +5 -0
  3. data/Rakefile +26 -13
  4. data/VERSION.yml +2 -2
  5. data/lib/Buildfile +43 -4
  6. data/lib/buildtasks/build.rake +10 -0
  7. data/lib/buildtasks/helpers/file_rule.rb +22 -0
  8. data/lib/buildtasks/helpers/file_rule_list.rb +137 -0
  9. data/lib/buildtasks/manifest.rake +133 -122
  10. data/lib/frameworks/sproutcore/CHANGELOG.md +69 -2
  11. data/lib/frameworks/sproutcore/apps/tests/english.lproj/strings.js +1 -0
  12. data/lib/frameworks/sproutcore/frameworks/bootstrap/system/browser.js +28 -22
  13. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/array.js +9 -5
  14. data/lib/frameworks/sproutcore/frameworks/core_foundation/controllers/controller.js +1 -1
  15. data/lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js +18 -13
  16. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/bind.js +5 -3
  17. data/lib/frameworks/sproutcore/frameworks/core_foundation/ext/handlebars/collection.js +2 -0
  18. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/action_support.js +80 -0
  19. data/lib/frameworks/sproutcore/frameworks/core_foundation/mixins/template_helpers/text_field_support.js +84 -116
  20. data/lib/frameworks/sproutcore/frameworks/core_foundation/panes/pane.js +8 -5
  21. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/event.js +157 -157
  22. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/platform.js +5 -3
  23. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/root_responder.js +6 -6
  24. data/lib/frameworks/sproutcore/frameworks/core_foundation/system/sparse_array.js +10 -7
  25. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/mixins/action_support.js +106 -0
  26. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/collection.js +18 -0
  27. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/template/handlebars.js +71 -1
  28. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/attribute_bindings_test.js +38 -0
  29. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/class_name_bindings_test.js +47 -0
  30. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutChildViews.js +18 -18
  31. data/lib/frameworks/sproutcore/frameworks/core_foundation/tests/views/view/layoutStyle.js +42 -10
  32. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/keyboard.js +26 -1
  33. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view/layout_style.js +14 -8
  34. data/lib/frameworks/sproutcore/frameworks/core_foundation/views/view.js +158 -1
  35. data/lib/frameworks/sproutcore/frameworks/datastore/models/record.js +15 -2
  36. data/lib/frameworks/sproutcore/frameworks/datastore/models/record_attribute.js +108 -108
  37. data/lib/frameworks/sproutcore/frameworks/datastore/system/query.js +1 -1
  38. data/lib/frameworks/sproutcore/frameworks/datastore/system/record_array.js +2 -4
  39. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/record/error_methods.js +2 -2
  40. data/lib/frameworks/sproutcore/frameworks/datastore/tests/models/single_attribute.js +26 -0
  41. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/query/builders.js +7 -0
  42. data/lib/frameworks/sproutcore/frameworks/datastore/tests/system/record_array/error_methods.js +1 -1
  43. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/system/datetime.js +4 -1
  44. data/lib/frameworks/sproutcore/frameworks/datetime/frameworks/core/tests/system/datetime.js +6 -0
  45. data/lib/frameworks/sproutcore/frameworks/desktop/panes/menu.js +26 -5
  46. data/lib/frameworks/sproutcore/frameworks/desktop/panes/picker.js +97 -96
  47. data/lib/frameworks/sproutcore/frameworks/desktop/system/drag.js +4 -3
  48. data/lib/frameworks/sproutcore/frameworks/desktop/tests/panes/menu/ui.js +17 -4
  49. data/lib/frameworks/sproutcore/frameworks/desktop/views/collection.js +7 -7
  50. data/lib/frameworks/sproutcore/frameworks/desktop/views/menu_item.js +7 -5
  51. data/lib/frameworks/sproutcore/frameworks/desktop/views/scroll.js +12 -3
  52. data/lib/frameworks/sproutcore/frameworks/desktop/views/web.js +23 -14
  53. data/lib/frameworks/sproutcore/frameworks/experimental/Buildfile +5 -1
  54. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/render_delegates/menu_scroller.js +28 -0
  55. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/tests/menu/scroll.js +235 -0
  56. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroll.js +363 -0
  57. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/menu/views/menu/scroller.js +250 -0
  58. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/desktop_scroller.js +92 -0
  59. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/native_scroll.js +25 -0
  60. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/scroll.js +33 -0
  61. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/render_delegates/touch_scroller.js +76 -0
  62. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/integration.js +50 -0
  63. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/methods.js +143 -0
  64. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/tests/scroll/ui.js +258 -0
  65. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroll.js +1164 -0
  66. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/core_scroller.js +332 -0
  67. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js +236 -0
  68. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/desktop/scroller.js +347 -0
  69. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroll.js +15 -0
  70. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/scroller.js +10 -0
  71. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroll.js +804 -0
  72. data/lib/frameworks/sproutcore/frameworks/experimental/frameworks/scroll_view/views/touch/scroller.js +133 -0
  73. data/lib/frameworks/sproutcore/frameworks/foundation/resources/text_field.css +3 -3
  74. data/lib/frameworks/sproutcore/frameworks/foundation/validators/number.js +3 -1
  75. data/lib/frameworks/sproutcore/frameworks/foundation/views/text_field.js +3 -3
  76. data/lib/frameworks/sproutcore/frameworks/media/views/audio.js +2 -1
  77. data/lib/frameworks/sproutcore/frameworks/media/views/controls.js +2 -1
  78. data/lib/frameworks/sproutcore/frameworks/media/views/media_slider.js +2 -4
  79. data/lib/frameworks/sproutcore/frameworks/media/views/mini_controls.js +2 -4
  80. data/lib/frameworks/sproutcore/frameworks/media/views/simple_controls.js +2 -4
  81. data/lib/frameworks/sproutcore/frameworks/media/views/video.js +2 -2
  82. data/lib/frameworks/sproutcore/frameworks/routing/system/routes.js +29 -3
  83. data/lib/frameworks/sproutcore/frameworks/runtime/core.js +2 -2
  84. data/lib/frameworks/sproutcore/frameworks/runtime/debug/test_suites/array/replace.js +1 -1
  85. data/lib/frameworks/sproutcore/frameworks/runtime/private/property_chain.js +2 -1
  86. data/lib/frameworks/sproutcore/frameworks/runtime/system/binding.js +3 -3
  87. data/lib/frameworks/sproutcore/frameworks/runtime/system/index_set.js +2 -2
  88. data/lib/frameworks/sproutcore/frameworks/runtime/system/object.js +1 -1
  89. data/lib/frameworks/sproutcore/themes/ace/resources/collection/normal/list_item.css +2 -2
  90. data/lib/frameworks/sproutcore/themes/legacy_theme/english.lproj/segmented.css +1 -1
  91. data/lib/gen/app/templates/apps/@target_name@/Buildfile +3 -5
  92. data/lib/gen/app/templates/apps/@target_name@/resources/_theme.css +18 -0
  93. data/lib/gen/project/templates/@filename@/Buildfile +2 -2
  94. data/lib/sproutcore/builders/chance_file.rb +9 -16
  95. data/lib/sproutcore/builders/html.rb +2 -1
  96. data/lib/sproutcore/builders/minify.rb +4 -35
  97. data/lib/sproutcore/builders/module.rb +38 -1
  98. data/lib/sproutcore/builders/split.rb +63 -0
  99. data/lib/sproutcore/builders/strings.rb +7 -1
  100. data/lib/sproutcore/builders.rb +1 -0
  101. data/lib/sproutcore/helpers/css_split.rb +190 -0
  102. data/lib/sproutcore/helpers/entry_sorter.rb +2 -0
  103. data/lib/sproutcore/helpers/minifier.rb +40 -16
  104. data/lib/sproutcore/helpers/static_helper.rb +35 -17
  105. data/lib/sproutcore/helpers.rb +1 -1
  106. data/lib/sproutcore/models/manifest.rb +26 -0
  107. data/lib/sproutcore/models/target.rb +12 -1
  108. data/lib/sproutcore/rack/proxy.rb +244 -225
  109. data/lib/sproutcore/rack/restrict_ip.rb +67 -0
  110. data/lib/sproutcore/rack/service.rb +8 -2
  111. data/lib/sproutcore/rack.rb +1 -0
  112. data/lib/sproutcore/tools/build.rb +91 -43
  113. data/lib/sproutcore/tools/gen.rb +2 -3
  114. data/lib/sproutcore/tools/manifest.rb +22 -16
  115. data/lib/sproutcore/tools/server.rb +21 -0
  116. data/lib/sproutcore/tools.rb +102 -46
  117. data/lib/sproutcore.rb +30 -5
  118. data/spec/buildtasks/helpers/accept_list +22 -0
  119. data/spec/buildtasks/helpers/accept_list.rb +128 -0
  120. data/spec/buildtasks/helpers/list.json +11 -0
  121. data/spec/buildtasks/manifest/prepare_build_tasks/chance_2x_spec.rb +1 -39
  122. data/spec/buildtasks/manifest/prepare_build_tasks/chance_spec.rb +0 -38
  123. data/spec/buildtasks/manifest/prepare_build_tasks/combine_spec.rb +4 -4
  124. data/spec/buildtasks/manifest/prepare_build_tasks/module_spec.rb +2 -2
  125. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_indirect_spec.rb +7 -16
  126. data/spec/buildtasks/manifest/prepare_build_tasks/packed_2x_spec.rb +7 -17
  127. data/spec/buildtasks/manifest/prepare_build_tasks/packed_spec.rb +11 -6
  128. data/spec/fixtures/builder_tests/Buildfile +2 -1
  129. data/spec/fixtures/builder_tests/apps/module_test/modules/required_module/core.js +0 -0
  130. data/spec/lib/builders/module_spec.rb +1 -1
  131. data/spec/spec_helper.rb +1 -0
  132. data/sproutcore.gemspec +4 -9
  133. data/vendor/chance/lib/chance/factory.rb +45 -0
  134. data/vendor/chance/lib/chance/instance/data_url.rb +0 -29
  135. data/vendor/chance/lib/chance/instance/slicing.rb +57 -4
  136. data/vendor/chance/lib/chance/instance/spriting.rb +112 -21
  137. data/vendor/chance/lib/chance/instance.rb +173 -28
  138. data/vendor/chance/lib/chance/parser.rb +80 -52
  139. data/vendor/chance/lib/chance.rb +25 -6
  140. data/vendor/sproutcore/SCCompiler.jar +0 -0
  141. data/vendor/sproutcore/lib/args4j-2.0.12.jar +0 -0
  142. data/vendor/sproutcore/lib/yuicompressor-2.4.2.jar +0 -0
  143. metadata +97 -38
@@ -23,15 +23,6 @@
23
23
  # - :theme: a selector that will make up the initial value of the $theme
24
24
  # variable. For example: :theme => "ace.test-controls"
25
25
  #
26
- # - :compress: if true, the slice names in the CSS will be shortened.
27
- # This has two drawbacks: 1) the slice names will not be helpful for
28
- # debugging, and 2) if using Chance in a standalone way and committing
29
- # the output to a source control system, the output can change dramatically
30
- # between runs, even if the input CSS is unchanged.
31
- #
32
- # As the most common use of Chance is as part of the SC build tools,
33
- # and this debugging support is usually only required to debug Chance
34
- # itself, :compress defaults to true
35
26
  #
36
27
  # How Slice & Slices work
37
28
  # -------------------------------
@@ -56,16 +47,15 @@ module Chance
56
47
  BEGIN_SCOPE = /\{/
57
48
  END_SCOPE = /\}/
58
49
  THEME_DIRECTIVE = /@theme\s*/
59
- SELECTOR_THEME_VARIABLE = /\$theme\./
50
+ SELECTOR_THEME_VARIABLE = /\$theme(?=[^\w:-])/
60
51
  INCLUDE_SLICES_DIRECTIVE = /@include\s+slices\s*/
61
52
  INCLUDE_SLICE_DIRECTIVE = /@include\s+slice\s*/
62
53
  CHANCE_FILE_DIRECTIVE = /@_chance_file /
63
54
  NORMAL_SCAN_UNTIL = /[^{}@$]+/
64
55
 
65
- @@uid = 0
66
56
 
67
57
  def initialize(string, opts = {})
68
- @opts = { :theme => "", :compress => true }
58
+ @opts = { :theme => "" }
69
59
  @opts.merge!(opts)
70
60
  @path = ""
71
61
 
@@ -77,9 +67,6 @@ module Chance
77
67
 
78
68
  @theme = @opts[:theme]
79
69
 
80
- @@uid += 1
81
- @uid = @@uid
82
-
83
70
  end
84
71
 
85
72
  # SLICE MANAGEMENT
@@ -135,12 +122,8 @@ module Chance
135
122
  slice[:max_offset_x] = [slice[:max_offset_x], opts[:offset_x]].max
136
123
  slice[:max_offset_y] = [slice[:max_offset_y], opts[:offset_y]].max
137
124
  else
138
- parts = slice_path.split("/")
139
- css_name = "__slice_" + parts.join("_")
140
-
141
- if @opts[:compress]
142
- css_name = "__s" + @uid.to_s + "_" + @slices.length.to_s
143
- end
125
+ modified_path = @opts[:instance_id].to_s.gsub(/[^a-zA-Z0-9]/, '_') + "_" + slice_path.gsub(/[^a-zA-Z0-9]/, '_')
126
+ css_name = "__chance_slice_#{modified_path}"
144
127
 
145
128
  slice = opts.merge({
146
129
  :name => slice_path,
@@ -151,12 +134,16 @@ module Chance
151
134
  :max_offset_x => opts[:offset_x],
152
135
  :max_offset_y => opts[:offset_y],
153
136
  :imaged_offset_x => 0, # the imaging process will re-define these.
154
- :imaged_offset_y => 0
137
+ :imaged_offset_y => 0,
138
+
139
+ :used_by => []
155
140
  })
156
141
 
157
142
  @slices[slice_path] = slice
158
143
  end
159
144
 
145
+ slice[:used_by] << { :path => @path }
146
+
160
147
  return slice
161
148
  end
162
149
 
@@ -358,7 +345,7 @@ module Chance
358
345
  scanner = @scanner
359
346
  scanner.scan SELECTOR_THEME_VARIABLE
360
347
 
361
- output = "\#{$theme}."
348
+ output = "\#{$theme}"
362
349
 
363
350
  return output
364
351
  end
@@ -486,7 +473,7 @@ module Chance
486
473
 
487
474
  # We prefix with -chance; this should let everything be passed through more
488
475
  # or less as-is. Postprocessing will turn it into -background-position.
489
- output += "-chance-offset: \"#{slice[:name]}\" #{slice[:offset_x]} #{slice[:offset_y]};"
476
+ output += "-chance-offset: \"#{slice[:name]}\" #{offset[0]} #{offset[1]};"
490
477
  output += "background-repeat: " + slice[:repeat]
491
478
  return output
492
479
  end
@@ -564,17 +551,25 @@ module Chance
564
551
  fill_width = Integer(fill[0])
565
552
  fill_height = Integer(fill[1])
566
553
 
567
- skip_top_left = values.include? 'skip-top-left'
568
- skip_top = values.include? 'skip-top'
569
- skip_top_right = values.include? 'skip-top-right'
554
+ # skip control
555
+ skip = arguments[:skip]
556
+ if skip.nil?
557
+ skip = []
558
+ else
559
+ skip = skip.split /\s+/
560
+ end
561
+
562
+ skip_top_left = skip.include? 'top-left'
563
+ skip_top = skip.include? 'top'
564
+ skip_top_right = skip.include? 'skip-top-right'
570
565
 
571
- skip_left = values.include? 'skip-left'
572
- skip_middle = values.include? 'skip-middle'
573
- skip_right = values.include? 'skip-right'
566
+ skip_left = skip.include? 'left'
567
+ skip_middle = skip.include? 'middle'
568
+ skip_right = skip.include? 'right'
574
569
 
575
- skip_bottom_left = values.include? 'skip-bottom-left'
576
- skip_bottom = values.include? 'skip-bottom'
577
- skip_bottom_right = values.include? 'skip-bottom-right'
570
+ skip_bottom_left = skip.include? 'bottom-left'
571
+ skip_bottom = skip.include? 'bottom'
572
+ skip_bottom_right = skip.include? 'bottom-right'
578
573
 
579
574
  filename = parse_string(arguments[0])
580
575
 
@@ -645,7 +640,7 @@ module Chance
645
640
  :sprite_padding => arguments[:"middle-padding"],
646
641
  :offset => arguments[:"middle-offset"],
647
642
  :filename => filename,
648
- :repeat => fill_height != 0 ? (fill_width != 0 ? "repeat-both" : "repeat-y") : (fill_width != 0 ? "repeat-x" : nil)
643
+ :repeat => fill_height != 0 ? (fill_width != 0 ? "repeat" : "repeat-y") : (fill_width != 0 ? "repeat-x" : nil)
649
644
 
650
645
 
651
646
  # fill in width, height or right, bottom depending on fill settings
@@ -734,9 +729,18 @@ module Chance
734
729
  output = ""
735
730
 
736
731
  # LEFT
737
- if should_include_slice?(top_left_slice) and not skip_top_left
732
+ # NOTE: we write it even if we are supposed to skip; we only wrap the slice include portion in
733
+ if should_include_slice?(top_left_slice)
738
734
  output += "& > .top-left {\n"
739
- output += generate_slice_include(top_left_slice) + ";"
735
+
736
+ # IF we are skipping the top left slice, we don't want the actual slice include-- but the layout
737
+ # information we still want. So, only bracket the generate_slice_include.
738
+ #
739
+ # Potential issue: slice_layout doesn't handle repeat settings. In theory, this should rarely be
740
+ # an issue (because you aren't setting a background for the skipped slice.
741
+ if not skip_top_left
742
+ output += generate_slice_include(top_left_slice) + ";"
743
+ end
740
744
 
741
745
  output += "\nposition: absolute;\n"
742
746
  output += slice_layout(top_left_slice)
@@ -744,9 +748,12 @@ module Chance
744
748
  output += "}\n"
745
749
  end
746
750
 
747
- if should_include_slice?(left_slice) and not skip_left
751
+ if should_include_slice?(left_slice)
748
752
  output += "& > .left {\n"
749
- output += generate_slice_include(left_slice) + ";"
753
+
754
+ if not skip_left
755
+ output += generate_slice_include(left_slice) + ";"
756
+ end
750
757
 
751
758
  output += "\nposition: absolute;\n"
752
759
  output += slice_layout(left_slice.merge({ :bottom => bottom }))
@@ -754,9 +761,12 @@ module Chance
754
761
  output += "}\n"
755
762
  end
756
763
 
757
- if should_include_slice?(bottom_left_slice) and not skip_bottom_left
764
+ if should_include_slice?(bottom_left_slice)
758
765
  output += "& > .bottom-left {\n"
759
- output += generate_slice_include(bottom_left_slice) + ";"
766
+
767
+ if not skip_bottom_left
768
+ output += generate_slice_include(bottom_left_slice) + ";"
769
+ end
760
770
 
761
771
  output += "\nposition: absolute;\n"
762
772
  output += slice_layout(bottom_left_slice)
@@ -765,9 +775,12 @@ module Chance
765
775
  end
766
776
 
767
777
  # MIDDLE
768
- if should_include_slice?(top_slice) and not skip_top
778
+ if should_include_slice?(top_slice)
769
779
  output += "& > .top {\n"
770
- output += generate_slice_include(top_slice) + ";"
780
+
781
+ if not skip_top
782
+ output += generate_slice_include(top_slice) + ";"
783
+ end
771
784
 
772
785
  output += "\nposition: absolute;\n"
773
786
  output += slice_layout(top_slice.merge({ :right => right }))
@@ -775,9 +788,12 @@ module Chance
775
788
  output += "}\n"
776
789
  end
777
790
 
778
- if should_include_slice?(middle_slice) and not skip_middle
791
+ if should_include_slice?(middle_slice)
779
792
  output += "& > .middle {\n"
780
- output += generate_slice_include(middle_slice) + ";"
793
+
794
+ if not skip_middle
795
+ output += generate_slice_include(middle_slice) + ";"
796
+ end
781
797
 
782
798
  output += "\nposition: absolute;\n"
783
799
  output += slice_layout(middle_slice.merge({ :bottom => bottom, :right => right }))
@@ -786,9 +802,12 @@ module Chance
786
802
  output += "}\n"
787
803
  end
788
804
 
789
- if should_include_slice?(bottom_slice) and not skip_bottom
805
+ if should_include_slice?(bottom_slice)
790
806
  output += "& > .bottom {\n"
791
- output += generate_slice_include(bottom_slice) + ";"
807
+
808
+ if not skip_bottom
809
+ output += generate_slice_include(bottom_slice) + ";"
810
+ end
792
811
 
793
812
  output += "\nposition: absolute;\n"
794
813
  output += slice_layout(bottom_slice.merge({ :right => right }))
@@ -798,9 +817,12 @@ module Chance
798
817
  end
799
818
 
800
819
  # RIGHT
801
- if should_include_slice?(top_right_slice) and not skip_top_right
820
+ if should_include_slice?(top_right_slice)
802
821
  output += "& > .top-right {\n"
803
- output += generate_slice_include(top_right_slice) + ";"
822
+
823
+ if not skip_top_right
824
+ output += generate_slice_include(top_right_slice) + ";"
825
+ end
804
826
 
805
827
  output += "\nposition: absolute;\n"
806
828
  output += slice_layout(top_right_slice)
@@ -808,9 +830,12 @@ module Chance
808
830
  output += "}\n"
809
831
  end
810
832
 
811
- if should_include_slice?(right_slice) and not skip_right
833
+ if should_include_slice?(right_slice)
812
834
  output += "& > .right {\n"
813
- output += generate_slice_include(right_slice) + ";"
835
+
836
+ if not skip_right
837
+ output += generate_slice_include(right_slice) + ";"
838
+ end
814
839
 
815
840
  output += "\nposition: absolute;\n"
816
841
  output += slice_layout(right_slice.merge({ :bottom => bottom }))
@@ -818,9 +843,12 @@ module Chance
818
843
  output += "}\n"
819
844
  end
820
845
 
821
- if should_include_slice?(bottom_right_slice) and not skip_bottom_right
846
+ if should_include_slice?(bottom_right_slice)
822
847
  output += "& > .bottom-right {\n"
823
- output += generate_slice_include(bottom_right_slice) + ";"
848
+
849
+ if not skip_bottom_right
850
+ output += generate_slice_include(bottom_right_slice) + ";"
851
+ end
824
852
 
825
853
  output += "\nposition: absolute;\n"
826
854
  output += slice_layout(bottom_right_slice)
@@ -1,4 +1,5 @@
1
1
  require "chance/instance"
2
+ require "chance/factory"
2
3
 
3
4
  require 'sass'
4
5
 
@@ -19,8 +20,10 @@ module Chance
19
20
 
20
21
  @files = {}
21
22
 
23
+ @clear_files_immediately = false
24
+
22
25
  class << self
23
- attr_accessor :files, :_current_instance
26
+ attr_accessor :files, :_current_instance, :clear_files_immediately
24
27
 
25
28
  def add_file(path, content=nil)
26
29
  mtime = 0
@@ -29,9 +32,7 @@ module Chance
29
32
  end
30
33
 
31
34
  if @files[path]
32
- mtime = File.mtime(path).to_f
33
- update_file(path, content) if mtime > @files[path][:mtime]
34
- return
35
+ return update_file_if_needed(path, content)
35
36
  end
36
37
 
37
38
  file = {
@@ -67,6 +68,21 @@ module Chance
67
68
  puts "Updated " + path if Chance::CONFIG[:verbose]
68
69
  end
69
70
 
71
+ # if the path is a valid filesystem path and the mtime has changed, this invalidates
72
+ # the file. Returns the mtime if the file was updated.
73
+ def update_file_if_needed(path, content=nil)
74
+ if @files[path]
75
+ mtime = File.mtime(path).to_f
76
+ if mtime > @files[path][:mtime]
77
+ update_file(path, content)
78
+ end
79
+
80
+ return mtime
81
+ else
82
+ return false
83
+ end
84
+ end
85
+
70
86
  def remove_file(path)
71
87
  if not @files.has_key? path
72
88
  puts "Could not remove " + path + " because it is not in system."
@@ -144,10 +160,13 @@ module Chance
144
160
  content = file[:content]
145
161
 
146
162
  requires = []
147
- content = content.gsub(/sc_require\(['"]?(.*?)['"]?\);?/) {|match|
148
- requires.push $1
163
+ content = content.gsub(/(sc_)?require\(['"]?(.*?)['"]?\);?/) {|match|
164
+ requires.push $2
149
165
  ""
150
166
  }
167
+
168
+ # sc_resource will already be handled by the build tool. We just need to ignore it.
169
+ content.gsub!(/sc_resource\(['"]?(.*?)['"]?\);?/, '')
151
170
 
152
171
  file[:requires] = requires
153
172
  file[:content] = content
Binary file