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
@@ -13,49 +13,70 @@ $to_html5_manifest_networks = []
13
13
 
14
14
  module SC
15
15
  class Tools
16
-
16
+
17
17
  desc "build [TARGET..]", "Builds one or more targets"
18
- method_options(MANIFEST_OPTIONS)
18
+
19
+ # Standard manifest options. Used by build tool as well.
20
+ method_option :languages, :type => :string,
21
+ :desc => "The languages to build."
22
+
23
+ method_option :symlink, :default => false
24
+
25
+ method_option :buildroot, :type => :string,
26
+ :desc => "The path to build to."
27
+ method_option :stageroot, :type => :string,
28
+ :aliases => %w(--target -t),
29
+ :desc => "The path to stage to."
30
+ method_option :format, :type => :string
31
+ method_option :output, :type => :string
32
+ method_option :all, :type => false
33
+ method_option :build_numbers, :type => :string, :aliases => ['-B'],
34
+ :desc => "The identifier(s) for the build."
35
+ method_option :include_required, :default => false, :aliases => '-r',
36
+ :desc => "Deprecated. All builds build dependencies."
37
+
38
+
19
39
  method_option :entries, :type => :string
20
- method_option :clean, :type => :boolean, :aliases => "-c"
21
- # This is defined in MANIFEST_OPTIONS but I add the aliases here only since we use target elsewhere
22
- method_option :buildroot, :type => :string, :aliases => %w(--target -t)
40
+ method_option :whitelist, :type => :string,
41
+ :desc => "The whitelist to use when building. By default, Whitelist (if present)"
42
+ method_option :blacklist, :type => :string,
43
+ :desc => "The blacklist to use when building. By default, Blacklist (if present)"
44
+ method_option :accept, :type => :string,
45
+ :desc => "The SproutCore Accept file to determine which files to include. By default, Accept (if present)"
46
+ method_option :allow_commented_js, :type => :boolean,
47
+ :desc => "If supplied, commented JS will be allowed into the build."
23
48
  def build(*targets)
49
+ if options.help
50
+ help('build')
51
+ return
52
+ end
53
+
24
54
  t1 = Time.now
25
55
  SC.logger.info 'Starting build process...'
26
56
  # Copy some key props to the env
57
+ SC.env.whitelist_name = options.whitelist
58
+ SC.env.blacklist_name = options.blacklist
59
+ SC.env.accept_name = options.accept
27
60
  SC.env.build_prefix = options.buildroot if options.buildroot
28
61
  SC.env.staging_prefix = options.stageroot if options.stageroot
29
62
  SC.env.use_symlink = options.symlink
30
- SC.env.clean = options.clean
31
63
 
32
64
  # Get entries option
33
65
  entry_filters = nil
34
66
  if options[:entries]
35
67
  entry_filters = options[:entries].split(',')
36
68
  end
37
-
69
+
70
+ # We want Chance to clear files like sprites immediately after they're asked for,
71
+ # because we'll only need them once during a build.
72
+ Chance.clear_files_immediately
73
+
38
74
  # Get the manifests to build
39
- manifests = build_manifests(*targets)
40
-
41
- # First clean all manifests
42
- # Do this before building so we don't accidentally erase already build
43
- # nested targets.
44
- if SC.env.clean
45
- manifests.each do |manifest|
46
- build_root = manifest.target.build_root
47
- info "Cleaning #{build_root}"
48
- FileUtils.rm_r(build_root) if File.directory?(build_root)
49
-
50
- staging_root = manifest.target.staging_root
51
- info "Cleaning #{staging_root}"
52
- FileUtils.rm_r(staging_root) if File.directory?(staging_root)
53
- end
54
- end
55
-
56
- # Now build entries for each manifest...
57
- manifests.each do |manifest|
58
-
75
+ manifests = build_manifests(*targets) do |manifest|
76
+ # This is our own logic to prevent processing a manifest twice
77
+ next if manifest[:built_by_builder]
78
+ manifest[:built_by_builder] = true
79
+
59
80
  # get entries. If "entries" option was specified, use to filter
60
81
  # filename. Must match end of filename.
61
82
  entries = manifest.entries
@@ -71,24 +92,49 @@ module SC
71
92
  end
72
93
 
73
94
  # if there are entries to build, log and build
74
- if entries.size > 0
75
- info "Building entries for #{manifest.target.target_name}:#{manifest.language}..."
76
-
77
- target_build_root = Pathname.new(manifest.target.project.project_root)
78
- entries.each do |entry|
79
- dst = Pathname.new(entry.build_path).relative_path_from(target_build_root)
80
- info " #{entry.filename} -> #{dst}"
81
- entry.build!
82
- end
83
-
84
- end
95
+ build_entries_for_manifest manifest, options.allow_commented_js
96
+
97
+ # Build dependencies
98
+ target = manifest.target
99
+ required = target.expand_required_targets :theme => true,
100
+ :debug => target.config.load_debug,
101
+ :tests => target.config.load_tests,
102
+
103
+ # Modules are not 'required' technically, as they may be loaded
104
+ # lazily. However, we want to know all targets that should be built,
105
+ # so we'll include modules as well.
106
+ :modules => true
107
+
108
+
109
+ required.each {|t|
110
+ m = t.manifest_for (manifest.variation)
111
+
112
+
113
+ # And, yes, the same as above. We're just building entries for all required targets.
114
+ # We're also going to mark them as fully-built so they don't get built again.
115
+ next if m[:built_by_builder]
116
+ m[:built_by_builder] = true
117
+ m.build!
118
+
119
+ build_entries_for_manifest m, options.allow_commented_js
120
+
121
+
122
+ }
123
+
124
+ # Clean up
125
+ manifest.reset!
126
+ Chance::ChanceFactory.clear_instances
85
127
  end
86
128
 
87
- if $to_html5_manifest.length > 0
88
- $to_html5_manifest.each do |entry|
89
- SC::Helpers::HTML5Manifest.new.build(entry)
90
- end
91
- end
129
+ # The HTML5 manifest generator does not work properly; it is unstable (can cause crashes)
130
+ # and won't pick up modules. We need an alternative implemenation, preferably one that uses
131
+ # Abbot's own manifests to figure out what files are required. This is non-trivial, however.
132
+ #
133
+ # if $to_html5_manifest.length > 0
134
+ # $to_html5_manifest.each do |entry|
135
+ # SC::Helpers::HTML5Manifest.new.build(entry)
136
+ # end
137
+ # end
92
138
 
93
139
  SC::Helpers::Minifier.wait
94
140
 
@@ -98,5 +144,7 @@ module SC
98
144
  seconds = seconds%60
99
145
  puts 'Build time '+minutes.floor.to_s+ ' minutes '+seconds.floor.to_s+' secs'
100
146
  end
147
+
101
148
  end
149
+
102
150
  end
@@ -50,12 +50,11 @@ module SC
50
50
  desc "gen generator Namespace[.ClassName] [--target=TARGET_NAME] [--filename=FILE_NAME]",
51
51
  "Generates SproutCore components"
52
52
 
53
- method_options(
54
- MANIFEST_OPTIONS.merge(:help => :string,
53
+ method_options(:help => :string,
55
54
  :filename => :string,
56
55
  :target => :string,
57
56
  '--dry-run' => false,
58
- :force => false))
57
+ :force => false)
59
58
 
60
59
  def gen(*arguments)
61
60
  return show_help if arguments.empty?
@@ -8,23 +8,29 @@
8
8
  module SC
9
9
  class Tools
10
10
 
11
- # Standard manifest options. Used by build tool as well.
12
- MANIFEST_OPTIONS = { :symlink => false,
13
- :stageroot => :string,
14
- :format => :string,
15
- :output => :string,
16
- :all => false,
17
- :buildroot => :string,
18
- ['--languages', '-L'] => :string,
19
- ['--build-numbers', '-B'] => :string,
20
- ['--include-required', '-r'] => false }
21
-
22
11
  desc "manifest [TARGET..]", "Generates a manifest for the specified targets"
23
- method_options(MANIFEST_OPTIONS.merge(
24
- :format => :string,
25
- :only => :string,
26
- :except => :string,
27
- :hidden => false ))
12
+
13
+ # Standard manifest options. Used by build tool as well.
14
+ method_option :languages, :type => :string,
15
+ :desc => "The languages to build."
16
+ method_option :symlink, :default => false
17
+ method_option :buildroot, :type => :string,
18
+ :desc => "The path to build to."
19
+ method_option :stageroot, :type => :string,
20
+ :desc => "The path to stage to."
21
+ method_option :format, :type => :string
22
+ method_option :output, :type => :string
23
+ method_option :all, :type => false
24
+
25
+ method_option :build_numbers, :type => :string, :aliases => ['-B'],
26
+ :desc => "The identifier(s) for the build."
27
+ method_option :include_required, :default => false, :aliases => '-r',
28
+ :desc => "Deprecated. All builds build dependencies."
29
+
30
+ method_option :format => :string
31
+ method_option :only => :string
32
+ method_option :except => :string
33
+ method_option :hidden => false
28
34
  def manifest(*targets)
29
35
 
30
36
  # Copy some key props to the env
@@ -16,11 +16,32 @@ module SC
16
16
  :host => :string,
17
17
  :irb => false,
18
18
  :filesystem => true
19
+
20
+ method_option :whitelist, :type => :string,
21
+ :desc => "The whitelist to use when building. By default, Whitelist (if present)"
22
+ method_option :blacklist, :type => :string,
23
+ :desc => "The blacklist to use when building. By default, Blacklist (if present)"
24
+ method_option :accept, :type => :string,
25
+ :desc => "The SproutCore Accept file to determine which files to include. By default, Accept (if present)"
26
+
27
+
28
+ method_option :allow_from_ips,
29
+ :default => "127.0.0.1",
30
+ :desc => "One or more (comma-separated) masks to accept requests from. " +
31
+ "For example: 10.*.*.*,127.0.0.1"
19
32
  def server
33
+ if options.help
34
+ help('server')
35
+ return
36
+ end
37
+
20
38
  prepare_mode!('debug') # set mode again, using debug as default
21
39
 
22
40
  SC.env[:build_prefix] = options[:buildroot] if options[:buildroot]
23
41
  SC.env[:staging_prefix] = options[:stageroot] if options[:stageroot]
42
+ SC.env[:whitelist_name] = options.whitelist
43
+ SC.env[:blacklist_name] = options.blacklist
44
+ SC.env[:accept_name] = options.accept
24
45
 
25
46
  # get project and start service.
26
47
  project = requires_project!
@@ -32,17 +32,27 @@ module SC
32
32
 
33
33
  # All sproutcore tools can take some standard options. These are
34
34
  # processed automatically when the tool is loaded
35
- class_option "project", :type => :string
36
- class_option "mode", :type => :string
37
- class_option "logfile", :type => :string
38
- class_option "build", :type => :string, :aliases => "-b"
39
- class_option "build-targets", :type => :string
40
- class_option "yui-minification", :type => :boolean
41
- class_option "dont-minify", :type => :boolean
42
- class_option "verbose", :type => :boolean, :aliases => "-v"
43
- class_option "very-verbose", :type => :boolean, :aliases => "-V"
44
- class_option "library", :type => :string #deprecated
45
- class_option "environment", :type => :string #deprecated
35
+ class_option "project", :type => :string
36
+ class_option "mode", :type => :string
37
+ class_option "logfile", :type => :string
38
+ class_option "build", :type => :string, :aliases => "-b"
39
+ class_option "build-targets",:type => :string,
40
+ :desc => "Targets to build (excluding their dependencies)"
41
+
42
+ class_option "yui-minification", :type => :boolean,
43
+ :desc => "Deprecated. Does nothing."
44
+
45
+ class_option "dont-minify", :type => :boolean,
46
+ :desc => "Disables minification for the build."
47
+
48
+ class_option "verbose", :type => :boolean, :aliases => "-v"
49
+ class_option "very-verbose", :type => :boolean, :aliases => "-V"
50
+
51
+ class_option "library", :type => :string, #deprecated
52
+ :desc => "Deprecated."
53
+ class_option "environment", :type => :string, #deprecated
54
+ :desc => "Deprecated."
55
+ class_option "help", :type => :boolean
46
56
 
47
57
  default_task :banner
48
58
 
@@ -199,6 +209,20 @@ module SC
199
209
  end
200
210
  end
201
211
 
212
+ # This is the root project, so we must also load the "include targets" used to
213
+ # make additional frameworks available to SC apps.
214
+ SC.include_targets.each {|target|
215
+ target_path = File.expand_path target[:path]
216
+ target_name = File.join "/", target[:name]
217
+
218
+ # Note: target names must begin with / to be valid.
219
+ t = ret.add_target target_name, :framework, { :source_root => target_path }
220
+
221
+ if t.config[:allow_nested_targets]
222
+ ret.find_targets_for(target_path, target_name, t.config)
223
+ end
224
+ }
225
+
202
226
  info "Loaded project at: #{ret.project_root}" unless ret.nil?
203
227
  @project = ret
204
228
  end
@@ -269,26 +293,6 @@ module SC
269
293
  targets = tar
270
294
  end
271
295
 
272
- # If include required was specified, merge in all required bundles as
273
- # well. Note that we do this whether --build-targets is specified or not.
274
- if options[:'include-required']
275
- tar = targets.clone
276
- targets.each do |target|
277
- required = target.expand_required_targets :theme => true,
278
- :debug => target.config.load_debug,
279
- :tests => target.config.load_tests
280
-
281
- required.each {|t|
282
- t.config[:minify_javascript] = false if not targets.include? t
283
- }
284
-
285
- tar += required
286
- end
287
-
288
- targets = tar.flatten.uniq.compact
289
- end
290
-
291
-
292
296
  targets
293
297
 
294
298
  end
@@ -342,35 +346,87 @@ module SC
342
346
  SC.logger.info "Using build numbers: #{numbers.map { |k,v| "#{k}: #{v}" }.join(',')}"
343
347
  end
344
348
  end
345
-
346
- # Core method to process command line options and then build a manifest.
347
- # Shared by sc-manifest, sc-build and sc-docs commands.
348
- def build_manifests(*targets)
349
-
349
+
350
+ def each_manifest_for_targets(*targets)
350
351
  # setup build numbers
351
352
  find_build_numbers(*targets)
352
353
 
353
354
  requires_project! # get project
355
+
354
356
  targets = find_targets(*targets) # get targets
355
- languages = find_languages(*targets) # get languages
356
357
 
357
358
  # log output
358
359
  SC.logger.info "Building targets: #{targets.map { |t| t.target_name } * ","}"
360
+
361
+ languages = find_languages(*targets) # get languages
359
362
  SC.logger.info "Building languages: #{ languages * "," }"
363
+
364
+ index = 1
365
+ count = targets.length * languages.length
366
+ SC.logger.info "Total target/language combinations to build: #{count}"
367
+
368
+ targets.each {|target|
369
+ languages.each {|l|
370
+ manifest = target.manifest_for :language => l
371
+ SC.logger.info "Creating manifest #{index} of #{count} for: #{manifest.target.target_name}:#{manifest.language}"
372
+
373
+ yield manifest
374
+
375
+ index += 1
376
+ }
377
+ }
378
+
379
+ end
360
380
 
361
- # Now fetch the manifests to build. One per target/language
362
- manifests = targets.map do |target|
363
- languages.map { |l| target.manifest_for :language => l }
364
- end
365
- manifests.flatten!
366
-
381
+ # Core method to process command line options and then build a manifest.
382
+ # Shared by sc-manifest, sc-build and sc-docs commands.
383
+ def build_manifests(*targets)
367
384
  # Build'em
368
- manifests.each do |manifest|
369
- SC.logger.info "Building manifest for: #{manifest.target.target_name}:#{manifest.language}"
385
+ each_manifest_for_targets(*targets) do |manifest|
370
386
  manifest.build!
387
+
388
+ yield manifest
371
389
  end
390
+ end
391
+
392
+ # Loops over all of the manifest's entries and builds all essential entries.
393
+ # Entries such as javascript.js are considered non-essential because they will
394
+ # not actually be used in a fully built app (except for modules).
395
+ #
396
+ # It also does a check to ensure that all JS being written is minified.
397
+ def build_entries_for_manifest(manifest, allow_comments)
398
+ if manifest.entries.size > 0
399
+ target = manifest.target
400
+ info "Building entries for #{target.target_name}:#{manifest.language}..."
401
+
402
+ # we ONLY generate non-packed javascript.js files for modules, which may need
403
+ # to lazily load them. Otherwise: NOPE!
404
+ generate_javascript = false
405
+ if target[:target_type] === :module
406
+ generate_javascript = true
407
+ end
372
408
 
373
- return manifests
409
+ target_build_root = Pathname.new(manifest.target.project.project_root)
410
+ manifest.entries.each do |entry|
411
+ # Skip combined JS when it is a target that doesn't need it.
412
+ # We can't just skip all non-packed JS, because you can use sc_resource to split
413
+ # the JS out, and that won't work properly. :combine, likewise, is used for sc_resource.
414
+ # So, we skip the entry IF it is javascript.js--because that is how the pack task itself
415
+ # knows the difference.
416
+ next if not generate_javascript and entry[:filename] == 'javascript.js'
417
+
418
+ # For security, skip AND WARN about files which are not minified
419
+ if not SC.env[:dont_minify] and not allow_comments and entry[:entry_type] == :javascript and not entry[:minified]
420
+ SC.logger.fatal "SECURITY: Entry not minified: #{entry[:filename]}; target: #{target[:target_name]}"
421
+ SC.logger.fatal "All entries must be minified in a final build UNLESS --allow-commented-js argument is supplied."
422
+ exit(1)
423
+ end
424
+
425
+ dst = Pathname.new(entry.build_path).relative_path_from(target_build_root)
426
+ info " #{entry.filename} -> #{dst}"
427
+ entry.build!
428
+ end
429
+ end
374
430
  end
375
431
 
376
432
  # Logs the contents of the passed file path to the logger
data/lib/sproutcore.rb CHANGED
@@ -47,7 +47,12 @@ module SproutCore
47
47
  # where you will find the build mode among other things set by sc-build.
48
48
  #
49
49
  def self.env
50
- @env ||= HashStruct.new(:build_mode => :debug, :buildfile_names => %w(Buildfile sc-config sc-config.rb))
50
+ @env ||= HashStruct.new(
51
+ :build_mode => :debug,
52
+ :buildfile_names => %w(Buildfile sc-config sc-config.rb),
53
+ :whitelist_name => "Whitelist",
54
+ :blacklist_name => "Blacklist"
55
+ )
51
56
  end
52
57
  def self.env=(hash); @env = HashStruct.new(hash); end
53
58
 
@@ -116,10 +121,30 @@ module SproutCore
116
121
  end
117
122
  end
118
123
 
119
- def self.yui_jar
120
- @yui_jar ||= begin
121
- yui_root = File.expand_path("../../vendor/sproutcore/lib", __FILE__)
122
- File.join(yui_root, 'yuicompressor-2.4.6.jar')
124
+ # Additional targets to be included in the project. Each item is a hash
125
+ # with :path and :name attributes
126
+ def self.include_targets
127
+ @include_targets ||= []
128
+ end
129
+
130
+ # Adds a target to be included in the project SproutCore builds.
131
+ #
132
+ # This is useful to make additional frameworks available to SproutCore apps.
133
+ def self.include_target(target_name, target_path)
134
+ include_targets << { :name => target_name, :path => target_path }
135
+ end
136
+
137
+ def self.html_jar
138
+ @html_jar ||= begin
139
+ yui_root = File.expand_path("../../vendor/sproutcore", __FILE__)
140
+ File.join(yui_root, 'SCCompiler.jar')
141
+ end
142
+ end
143
+
144
+ def self.js_jar
145
+ @js_jar ||= begin
146
+ yui_root = File.expand_path("../../vendor/sproutcore", __FILE__)
147
+ File.join(yui_root, 'lib/yuicompressor-2.4.6.jar')
123
148
  end
124
149
  end
125
150
 
@@ -0,0 +1,22 @@
1
+ TARGET /target1/abc
2
+ file[0-9].js
3
+
4
+ DENY
5
+ # This will deny the files we don't want, and one we do
6
+ file[2-9].js
7
+
8
+ # This will add one back
9
+ allow file4.js
10
+
11
+ # this will remove it again
12
+ file4.js
13
+
14
+ # And finally, add back the one we want.
15
+ ALLOW
16
+ file2.js
17
+
18
+
19
+ TARGET /target1/def
20
+ allow all
21
+
22
+ deny file2.js
@@ -0,0 +1,128 @@
1
+ require "spec_helper"
2
+
3
+ WHITELIST_PATH = File.dirname(__FILE__) + '/list.json'
4
+ ACCEPT_LIST_PATH = File.dirname(__FILE__) + '/accept_list'
5
+
6
+
7
+ module FileRuleListSpec
8
+ class YesRule
9
+ def include?(f)
10
+ true
11
+ end
12
+ end
13
+
14
+ class NoRule
15
+ def include?(f)
16
+ false
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "FileRuleList" do
22
+ it "includes if ignore_list has not been unset" do
23
+ list = SproutCore::FileRuleList.new
24
+ list.include?("target1", "some_file.js").should be_true
25
+ end
26
+
27
+ it "does not include when there are no rules" do
28
+ list = SproutCore::FileRuleList.new
29
+ list.ignore_list = false
30
+ list.include?("target1", "some_file.js").should be_false
31
+ end
32
+
33
+ it "includes when there is an allow rule" do
34
+ list = SproutCore::FileRuleList.new
35
+ list.add_rule("target1", FileRuleListSpec::YesRule.new)
36
+ list.include?("target1", "some_file.js").should be_true
37
+ end
38
+
39
+ it "does not include when there is both a yes and a no rule" do
40
+ list = SproutCore::FileRuleList.new
41
+ list.add_rule("target1", FileRuleListSpec::YesRule.new)
42
+ list.add_rule("target1", FileRuleListSpec::NoRule.new)
43
+ list.include?("target1", "some_file.js").should be_false
44
+ end
45
+
46
+ it "includes when there is a yes rule, followed by a no, followed by a yes" do
47
+ list = SproutCore::FileRuleList.new
48
+ list.add_rule("target1", FileRuleListSpec::YesRule.new)
49
+ list.add_rule("target1", FileRuleListSpec::NoRule.new)
50
+ list.add_rule("target1", FileRuleListSpec::YesRule.new)
51
+ list.include?("target1", "some_file.js").should be_true
52
+ end
53
+
54
+ it "maintains separate lists for each target" do
55
+ list = SproutCore::FileRuleList.new
56
+ list.add_rule("target1", FileRuleListSpec::YesRule.new)
57
+ list.add_rule("target2", FileRuleListSpec::NoRule.new)
58
+ list.include?("target1", "some_file.js").should be_true
59
+ list.include?("target2", "some_file.js").should be_false
60
+ end
61
+
62
+ it "obeys allow_by_default" do
63
+ list = SproutCore::FileRuleList.new
64
+ list.allow_by_default = true
65
+ list.include?("target1", "some_file.js").should be_true
66
+ end
67
+
68
+ it "always allows the ALWAYS_ACCEPTED_FILE_TYPES, no matter what" do
69
+ list = SproutCore::FileRuleList.new
70
+ list.add_rule("target1", FileRuleListSpec::NoRule.new)
71
+
72
+ [
73
+ '.manifest',
74
+ '.htm',
75
+ '.html',
76
+ '.rhtml',
77
+ '.png',
78
+ '.jpg',
79
+ '.jpeg',
80
+ '.gif'
81
+ ].each {|name|
82
+ list.include?("target1", "a_file#{name}").should be_true
83
+ }
84
+
85
+ list.include?("target1", "some_file.js").should be_false
86
+ end
87
+
88
+
89
+
90
+
91
+ describe "#read_json" do
92
+ it "reads in allow mode properly" do
93
+ list = SproutCore::FileRuleList.new
94
+ list.read_json(WHITELIST_PATH, :allow)
95
+
96
+ list.include?("/target1/abc", "file1.js").should be_true
97
+ list.include?("/target1/abc", "file3.js").should be_false
98
+ list.include?("/target1/def", "file2.js").should be_false
99
+ list.include?("/target1/def", "file4.js").should be_true
100
+ end
101
+
102
+ it "reads in deny mode properly" do
103
+ list = SproutCore::FileRuleList.new
104
+ list.allow_by_default = true
105
+ list.read_json(WHITELIST_PATH, :deny)
106
+
107
+ list.include?("/target1/abc", "file1.js").should be_false
108
+ list.include?("/target1/abc", "file3.js").should be_true
109
+ list.include?("/target1/def", "file2.js").should be_true
110
+ list.include?("/target1/def", "file4.js").should be_false
111
+ end
112
+ end
113
+
114
+ describe "#read" do
115
+ it "reads the list properly" do
116
+ list = SproutCore::FileRuleList.new
117
+ list.read(ACCEPT_LIST_PATH)
118
+
119
+ list.include?("/target1/abc", "file1.js").should be_true
120
+ list.include?("/target1/abc", "file3.js").should be_false
121
+
122
+ # Target1/def denies exactly one file: file2.js. Everything else is allowed.
123
+ list.include?("/target1/def", "file2.js").should be_false
124
+ list.include?("/target1/def", "fadjfhakljdf.js").should be_true
125
+ end
126
+ end
127
+ end
128
+
@@ -0,0 +1,11 @@
1
+ {
2
+ "/target1/abc": [
3
+ "file1.js",
4
+ "file2.js"
5
+ ],
6
+
7
+ "/target1/def": [
8
+ "file3.js",
9
+ "file4.js"
10
+ ]
11
+ }