sproutcore 0.9.11 → 0.9.12

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 (88) hide show
  1. data/History.txt +98 -73
  2. data/Manifest.txt +2 -1
  3. data/README.txt +1 -1
  4. data/Rakefile +8 -8
  5. data/app_generators/sproutcore/USAGE +2 -3
  6. data/app_generators/sproutcore/sproutcore_generator.rb +12 -12
  7. data/app_generators/sproutcore/templates/README +26 -23
  8. data/app_generators/sproutcore/templates/{sc-config.rb → sc-config} +32 -17
  9. data/bin/sc-build +17 -17
  10. data/bin/sc-server +1 -1
  11. data/bin/sproutcore +3 -3
  12. data/clients/sc_test_runner/english.lproj/no_tests.rhtml +0 -1
  13. data/config/hoe.rb +9 -9
  14. data/config/requirements.rb +1 -1
  15. data/frameworks/sproutcore/HISTORY +14 -0
  16. data/frameworks/sproutcore/core.js +1 -1
  17. data/frameworks/sproutcore/english.lproj/theme.css +1 -0
  18. data/frameworks/sproutcore/foundation/binding.js +2 -2
  19. data/frameworks/sproutcore/foundation/timer.js +55 -22
  20. data/frameworks/sproutcore/lib/index.rhtml +2 -3
  21. data/frameworks/sproutcore/models/record.js +204 -63
  22. data/frameworks/sproutcore/tests/models/model.rhtml +360 -0
  23. data/frameworks/sproutcore/views/button/button.js +22 -1
  24. data/frameworks/sproutcore/views/collection/collection.js +6 -2
  25. data/frameworks/sproutcore/views/collection/list.js +1 -0
  26. data/frameworks/sproutcore/views/collection/source_list.js +1 -0
  27. data/frameworks/sproutcore/views/field/text_field.js +11 -2
  28. data/frameworks/sproutcore/views/inline_text_field.js +3 -2
  29. data/frameworks/sproutcore/views/menu_item.js +1 -0
  30. data/frameworks/sproutcore/views/pagination.js +1 -0
  31. data/frameworks/sproutcore/views/view.js +4 -1
  32. data/lib/sproutcore/build_tools/html_builder.rb +36 -36
  33. data/lib/sproutcore/build_tools/resource_builder.rb +55 -54
  34. data/lib/sproutcore/build_tools.rb +12 -12
  35. data/lib/sproutcore/bundle.rb +162 -164
  36. data/lib/sproutcore/bundle_manifest.rb +154 -107
  37. data/lib/sproutcore/generator_helper.rb +23 -23
  38. data/lib/sproutcore/helpers/capture_helper.rb +10 -10
  39. data/lib/sproutcore/helpers/static_helper.rb +39 -26
  40. data/lib/sproutcore/helpers/tag_helper.rb +10 -10
  41. data/lib/sproutcore/helpers/text_helper.rb +36 -36
  42. data/lib/sproutcore/helpers.rb +1 -1
  43. data/lib/sproutcore/jsdoc.rb +10 -10
  44. data/lib/sproutcore/jsmin.rb +14 -14
  45. data/lib/sproutcore/library.rb +135 -87
  46. data/lib/sproutcore/merb/bundle_controller.rb +77 -54
  47. data/lib/sproutcore/merb/router.rb +19 -12
  48. data/lib/sproutcore/merb.rb +1 -1
  49. data/lib/sproutcore/version.rb +1 -1
  50. data/lib/sproutcore/view_helpers.rb +121 -121
  51. data/lib/sproutcore.rb +5 -7
  52. data/sc-config.rb +6 -0
  53. data/sc_generators/client/README +1 -1
  54. data/sc_generators/client/USAGE +1 -2
  55. data/sc_generators/client/client_generator.rb +6 -6
  56. data/sc_generators/client/templates/core.js +2 -2
  57. data/sc_generators/client/templates/english.lproj/body.css +79 -81
  58. data/sc_generators/client/templates/english.lproj/strings.js +1 -2
  59. data/sc_generators/client/templates/main.js +6 -8
  60. data/sc_generators/controller/USAGE +1 -2
  61. data/sc_generators/controller/controller_generator.rb +7 -7
  62. data/sc_generators/controller/templates/controller.js +3 -3
  63. data/sc_generators/controller/templates/test.rhtml +1 -1
  64. data/sc_generators/framework/README +1 -2
  65. data/sc_generators/framework/USAGE +2 -3
  66. data/sc_generators/framework/framework_generator.rb +5 -5
  67. data/sc_generators/framework/templates/core.js +3 -3
  68. data/sc_generators/framework/templates/english.lproj/strings.js +1 -2
  69. data/sc_generators/language/USAGE +1 -2
  70. data/sc_generators/language/language_generator.rb +6 -6
  71. data/sc_generators/language/templates/strings.js +1 -2
  72. data/sc_generators/model/USAGE +1 -2
  73. data/sc_generators/model/model_generator.rb +7 -7
  74. data/sc_generators/model/templates/fixture.js +26 -26
  75. data/sc_generators/model/templates/model.js +5 -5
  76. data/sc_generators/model/templates/test.rhtml +2 -2
  77. data/sc_generators/test/USAGE +1 -2
  78. data/sc_generators/test/templates/test.rhtml +2 -2
  79. data/sc_generators/test/test_generator.rb +6 -6
  80. data/sc_generators/view/USAGE +1 -2
  81. data/sc_generators/view/templates/test.rhtml +2 -2
  82. data/sc_generators/view/templates/view.js +3 -3
  83. data/sc_generators/view/view_generator.rb +7 -7
  84. data/spec/spec.opts +1 -1
  85. data/spec/spec_helper.rb +1 -1
  86. data/spec/sproutcore_spec.rb +3 -3
  87. data/tasks/deployment.rake +4 -4
  88. metadata +4 -3
@@ -1,30 +1,27 @@
1
1
  module SproutCore
2
-
2
+
3
3
  module BuildTools
4
4
 
5
- # Set to override the default behavior (which will follow the build mode)
6
- def self.minify?; @minify.nil? ? (Bundle.build_mode != :development) : @minify; end
7
- def self.minify=(setting); @minify = setting; end
8
-
9
- # The ResourceBuilder can combine all of the source files listed in the passed entry
10
- # including some basic pre-processing. The JavaScriptBuilder extends this to do some
11
- # JavaScript specific rewriting of URLs, etc. as well.
5
+ # The ResourceBuilder can combine all of the source files listed in the
6
+ # passed entry including some basic pre-processing. The JavaScriptBuilder
7
+ # extends this to do some JavaScript specific rewriting of URLs, etc. as
8
+ # well.
12
9
  #
13
- # The ResourceBuilder knows how
10
+ # The ResourceBuilder knows how
14
11
  class ResourceBuilder
15
12
 
16
13
  attr_reader :bundle, :language, :filenames
17
-
14
+
18
15
  # Utility method you can call to get the items sorted by load order
19
16
  def self.sort_entries_by_load_order(entries, language, bundle)
20
17
  filenames = entries.map { |e| e.filename }
21
18
  hashed = {}
22
19
  entries.each { |e| hashed[e.filename] = e }
23
-
20
+
24
21
  sorted = self.new(filenames, language, bundle).required
25
22
  sorted.map { |filename| hashed[filename] }
26
23
  end
27
-
24
+
28
25
  def initialize(filenames, language, bundle)
29
26
  @bundle = bundle; @language = language; @filenames = filenames
30
27
  end
@@ -37,26 +34,26 @@ module SproutCore
37
34
  end
38
35
  return lines
39
36
  end
40
-
37
+
41
38
  # Actually perform the build. Returns the compiled resource as a single string.
42
39
  def build
43
40
 
44
41
  # setup context
45
42
  lines = []
46
43
  required = []
47
-
44
+
48
45
  # process files
49
46
  while filename = next_filename
50
47
  lines, required = _build_one(filename, lines, required)
51
48
  end
52
-
49
+
53
50
  return join(lines)
54
51
  end
55
-
56
- # Join the lines together. This is one last chance to do some prep of
52
+
53
+ # Join the lines together. This is one last chance to do some prep of
57
54
  # the data (such as minifcation and comment stripping)
58
55
  def join(lines); lines.join; end
59
-
56
+
60
57
  # Rewrites any inline content such as static urls. Subclasseses can
61
58
  # override this to rewrite any other inline content.
62
59
  #
@@ -67,8 +64,8 @@ module SproutCore
67
64
  static_url(entry.nil? ? '' : entry.url)
68
65
  end
69
66
  end
70
-
71
- # Tries to build a single resource. This may call itself recursively to
67
+
68
+ # Tries to build a single resource. This may call itself recursively to
72
69
  # handle requires.
73
70
  #
74
71
  # ==== Returns
@@ -83,51 +80,52 @@ module SproutCore
83
80
  puts "WARNING: Could not find require file: #{filename}"
84
81
  return [lines, required]
85
82
  end
86
-
83
+
87
84
  file_lines = []
88
85
  io = (entry.source_path.nil? || !File.exists?(entry.source_path)) ? [] : File.new(entry.source_path)
89
86
  io.each do | line |
90
-
91
- # check for requires. Only follow a require if the require is in
87
+
88
+ # check for requires. Only follow a require if the require is in
92
89
  # the list of filenames.
93
- required_file = _require_for(filename, line)
90
+ required_file = _require_for(filename, line)
94
91
  unless required_file.nil? || !filenames.include?(required_file)
95
92
  lines, required = _build_one(required_file, lines, required, link_only)
96
93
  end
97
-
98
- file_lines << rewrite_inline_code(line, filename) unless link_only
94
+
95
+ file_lines << rewrite_inline_code(line, filename) unless link_only
99
96
  end
100
97
 
101
- # The list of already required filenames is slightly out of order from
102
- # the actual load order. Instead, we use the lines array to hold the
98
+ # The list of already required filenames is slightly out of order from
99
+ # the actual load order. Instead, we use the lines array to hold the
103
100
  # list of filenames as they are processed.
104
101
  if link_only
105
102
  lines << filename
106
-
103
+
107
104
  elsif file_lines.size > 0
108
- lines += file_lines
109
- lines << "\n"
105
+ lines << "/* Start ----------------------------------------------------- " << filename << "*/\n\n"
106
+ lines += file_lines
107
+ lines << "\n\n/* End ------------------------------------------------------- " << filename << "*/\n\n"
110
108
  end
111
-
109
+
112
110
  return [lines, required]
113
111
  end
114
112
 
115
113
  # Overridden by subclasses to choose first filename.
116
114
  def next_filename; filenames.delete(filenames.first); end
117
115
 
118
- # Overridden by subclass to handle static_url() in a language specific
116
+ # Overridden by subclass to handle static_url() in a language specific
119
117
  # way.
120
118
  def static_url(url); "url('#{url}')"; end
121
-
119
+
122
120
  # check line for required() pattern. understands JS and CSS.
123
121
  def _require_for(filename,line)
124
122
  new_file = line.scan(/require\(['"](.*)['"]\)/)
125
- ret = (new_file.size > 0) ? new_file.first.first : nil
123
+ ret = (new_file.size > 0) ? new_file.first.first : nil
126
124
  ret.nil? ? nil : filename_for_require(ret)
127
125
  end
128
-
126
+
129
127
  def filename_for_require(ret); "#{ret}.css"; end
130
-
128
+
131
129
  end
132
130
 
133
131
  class JavaScriptResourceBuilder < ResourceBuilder
@@ -138,7 +136,7 @@ module SproutCore
138
136
  if bundle.minify?
139
137
  # first suck out any comments that should be retained
140
138
  comments = []
141
- include_line = false
139
+ include_line = false
142
140
  lines.each do | line |
143
141
  is_mark = (line =~ /@license/)
144
142
  unless include_line
@@ -152,34 +150,37 @@ module SproutCore
152
150
 
153
151
  # now minify and prepend any static
154
152
  comments.push "\n" unless comments.empty?
155
- comments.push SproutCore::JSMin.run(lines * '')
153
+ comments.push SproutCore::JSMin.run(lines * '')
156
154
  lines = comments
157
155
  end
158
-
156
+
159
157
  lines.join
160
158
  end
161
-
159
+
162
160
  # If the file is a strings.js file, then remove server-side strings...
163
161
  def rewrite_inline_code(line, filename)
164
162
  if filename == 'strings.js'
165
163
  line = line.gsub(/["']@@.*["']\s*?:\s*?["'].*["'],\s*$/,'')
164
+
165
+ else
166
+ line = line.gsub(/sc_super\((.*)\)/, 'arguments.callee.base.apply(this, \1)')
166
167
  end
167
-
168
+
168
169
  super(line, filename)
169
170
  end
170
-
171
+
171
172
  def static_url(url); "'#{url}'"; end
172
173
  def filename_for_require(ret); "#{ret}.js"; end
173
-
174
+
174
175
  def next_filename
175
176
  filenames.delete('strings.js') || filenames.delete('core.js') || filenames.delete('Core.js') || filenames.delete('utils.js') || filenames.delete(filenames.first)
176
177
  end
177
-
178
+
178
179
  end
179
-
180
+
180
181
  def self.build_stylesheet(entry, bundle)
181
- filenames = entry.composite.nil? ? [entry.filename] : entry.composite
182
- builder = ResourceBuilder.new(filenames, entry.language, bundle)
182
+ filenames = entry.composite? ? entry.composite_filenames : [entry.filename]
183
+ builder = ResourceBuilder.new(filenames, entry.language, bundle)
183
184
  if output = builder.build
184
185
  FileUtils.mkdir_p(File.dirname(entry.build_path))
185
186
  f = File.open(entry.build_path, 'w')
@@ -189,8 +190,8 @@ module SproutCore
189
190
  end
190
191
 
191
192
  def self.build_javascript(entry, bundle)
192
- filenames = entry.composite.nil? ? [entry.filename] : entry.composite
193
- builder = JavaScriptResourceBuilder.new(filenames, entry.language, bundle)
193
+ filenames = entry.composite? ? entry.composite_filenames : [entry.filename]
194
+ builder = JavaScriptResourceBuilder.new(filenames, entry.language, bundle)
194
195
  if output = builder.build
195
196
  FileUtils.mkdir_p(File.dirname(entry.build_path))
196
197
  f = File.open(entry.build_path, 'w')
@@ -198,9 +199,9 @@ module SproutCore
198
199
  f.close
199
200
  end
200
201
  end
201
-
202
+
202
203
  def self.build_fixture(entry, bundle); build_javascript(entry, bundle); end
203
-
204
+
204
205
  end
205
-
206
- end
206
+
207
+ end
@@ -7,9 +7,9 @@ module SproutCore
7
7
  # You can add your own build tools to the system here .
8
8
  #
9
9
  module BuildTools
10
-
11
- # Resources are sometimes accessed through a symlink while running in devmode. This
12
- # method should simply ensure that symlink exists.
10
+
11
+ # Resources are sometimes accessed through a symlink while running in
12
+ # devmode. This method should simply ensure that symlink exists.
13
13
  #
14
14
  def self.build_symlink(entry, bundle)
15
15
  symlink_path = File.join(bundle.build_root, '_src')
@@ -19,26 +19,26 @@ module SproutCore
19
19
  FileUtils.ln_sf(source_path, symlink_path)
20
20
  end
21
21
  end
22
-
23
- # Regular resources and tests are simply copied. Note that normally in development mode,
24
- # these resources will be accessed via a symlink
22
+
23
+ # Regular resources and tests are simply copied. Note that normally in
24
+ # development mode, these resources will be accessed via a symlink
25
25
  def self.copy_resource(entry, bundle)
26
26
  FileUtils.mkdir_p(File.dirname(entry.build_path))
27
-
27
+
28
28
  # Make the source file exists
29
29
  unless File.exists?(entry.source_path)
30
30
  raise "Could not copy resource #{entry.filename} because source: #{entry.source_path} does not exist!"
31
31
  end
32
-
32
+
33
33
  # Now do the copy
34
34
  FileUtils.cp_r(entry.source_path, entry.build_path)
35
35
  end
36
-
36
+
37
37
  def self.build_resource(entry, bundle); copy_resource(entry, bundle); end
38
-
38
+
39
39
  end
40
-
40
+
41
41
  end
42
42
 
43
43
  # Load other build tools. The above are the simple ones.
44
- Dir.glob(File.join(File.dirname(__FILE__),'build_tools','**','*.rb')).each { |x| require x }
44
+ Dir.glob(File.join(File.dirname(__FILE__),'build_tools','**','*.rb')).each { |x| require x }