Created
June 4, 2010 18:12
-
-
Save achiurizo/425747 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in load_missing_constant | |
# | |
436. begin | |
437. return parent.const_missing(const_name) | |
438. rescue NameError => e | |
439. raise unless e.missing_name? qualified_name_for(parent, const_name) | |
440. raise name_error | |
441. end | |
442. else | |
443. raise name_error | |
444. end | |
445. end | |
446. | |
447. # Remove the constants that have been autoloaded, and those that have been | |
448. # marked for unloading. | |
449. def remove_unloadable_constants! | |
450. autoloaded_constants.each { |const| remove_constant const } | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in const_missing | |
# | |
73. end | |
74. end | |
75. end | |
76. | |
77. # Use const_missing to autoload associations so we don't have to | |
78. # require_association when using single-table inheritance. | |
79. def const_missing_with_dependencies(class_id) | |
80. ActiveSupport::Dependencies.load_missing_constant self, class_id | |
81. end | |
82. | |
83. def unloadable(const_desc = self) | |
84. super(const_desc) | |
85. end | |
86. end | |
87. | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in const_missing | |
# | |
85. end | |
86. end | |
87. | |
88. # Class includes this module | |
89. module ClassConstMissing #:nodoc: | |
90. def const_missing(const_name) | |
91. if [Object, Kernel].include?(self) || parent == self | |
92. super | |
93. else | |
94. begin | |
95. begin | |
96. Dependencies.load_missing_constant self, const_name | |
97. rescue NameError | |
98. parent.send :const_missing, const_name | |
99. end | |
# /Volumes/Storage/Work/Stuck/funnyism/site/test/test_config.rb in nil | |
# | |
3. | |
4. # Heinous hack to allow us to use factory_girl spawn with Mongoid | |
5. Dir[File.dirname(__FILE__) + '/../app/models/*.rb'].each do |model_file| | |
6. model_name = File.basename(model_file, '.rb') | |
7. model_name.camelize.constantize.send(:include, BangBang::Document) | |
8. end | |
9. | |
10. class Riot::Situation | |
11. include Rack::Test::Methods | |
12. | |
13. # The Rack app under test. | |
14. def app | |
15. defined?(@app) ? @app : build_app | |
16. end | |
17. | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in new_constants_in | |
# | |
514. | |
515. constant_watch_stack_mutex.synchronize do | |
516. constant_watch_stack.concat watch_frames | |
517. end | |
518. | |
519. aborting = true | |
520. begin | |
521. yield # Now yield to the code that is to define new constants. | |
522. aborting = false | |
523. ensure | |
524. # Find the new constants. | |
525. new_constants = watch_frames.collect do |mod_name, prior_constants| | |
526. # Module still doesn't exist? Treat it as if it has no constants. | |
527. next [] unless qualified_const_defined?(mod_name) | |
528. | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Volumes/Storage/Work/Stuck/funnyism/site/test/uploader_test.rb in nil | |
# | |
1. require File.expand_path(File.dirname(__FILE__) + '/test_config.rb') | |
2. | |
3. context "Carrierwave Uploader" do | |
4. setup do | |
5. Uploader.enable_processing = true | |
6. @uploader = Uploader.new(Photo.new, :file) | |
7. @uploader.store! File.open(File.expand_path(File.dirname(__FILE__)+'/fixtures/test.png')) | |
8. @uploader | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in new_constants_in | |
# | |
514. | |
515. constant_watch_stack_mutex.synchronize do | |
516. constant_watch_stack.concat watch_frames | |
517. end | |
518. | |
519. aborting = true | |
520. begin | |
521. yield # Now yield to the code that is to define new constants. | |
522. aborting = false | |
523. ensure | |
524. # Find the new constants. | |
525. new_constants = watch_frames.collect do |mod_name, prior_constants| | |
526. # Module still doesn't exist? Treat it as if it has no constants. | |
527. next [] unless qualified_const_defined?(mod_name) | |
528. | |
# /Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb in require | |
# | |
149. rescue Exception => exception # errors from loading file | |
150. exception.blame_file! file | |
151. raise | |
152. end | |
153. | |
154. def require(file, *extras) #:nodoc: | |
155. if Dependencies.load? | |
156. Dependencies.new_constants_in(Object) { super } | |
157. else | |
158. super | |
159. end | |
160. rescue Exception => exception # errors from required file | |
161. exception.blame_file! file | |
162. raise | |
163. end | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in safe_load | |
# | |
123. klasses = ObjectSpace.classes.dup | |
124. files_loaded = $LOADED_FEATURES.dup | |
125. | |
126. # Now we can reload the file ignoring syntax errors | |
127. $LOADED_FEATURES.delete(file) | |
128. | |
129. begin | |
130. require(file) | |
131. rescue SyntaxError => ex | |
132. logger.error "Cannot require #{file} because of syntax error: #{ex.message}" | |
133. ensure | |
134. MTIMES[file] = mtime if mtime | |
135. end | |
136. | |
137. # Store off the details after the file has been loaded | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in reload! | |
# | |
74. # App reloading will also perform safe_load of itself so we can go next | |
75. if File.identical?(app.app_file, file) | |
76. MTIMES[file] = mtime # This prevent a loop | |
77. next | |
78. end | |
79. end | |
80. # Now we can reload our file | |
81. safe_load(file, mtime) | |
82. end | |
83. end | |
84. | |
85. ## | |
86. # Return true if some thing changed and in the meanwhile fill MTIMES cache | |
87. # | |
88. def changed? | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in rotation | |
# | |
181. | |
182. files.map{ |file| | |
183. found, stat = figure_path(file, paths) | |
184. next unless found && stat && mtime = stat.mtime | |
185. | |
186. CACHE[file] = found | |
187. | |
188. yield(found, mtime) | |
189. }.compact | |
190. end | |
191. | |
192. ## | |
193. # Takes a relative or absolute +file+ name, a couple possible +paths+ that | |
194. # the +file+ might reside in. Returns the full path and File::Stat for the | |
195. # path. | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in map | |
# | |
175. # Search Ruby files in your +Padrino.root+ and monitor them for changes. | |
176. # | |
177. def rotation | |
178. paths = Dir[Padrino.root("*")].unshift(Padrino.root).reject { |path| Padrino::Reloader.exclude.include?(path) || !File.directory?(path) } | |
179. | |
180. files = paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten | |
181. | |
182. files.map{ |file| | |
183. found, stat = figure_path(file, paths) | |
184. next unless found && stat && mtime = stat.mtime | |
185. | |
186. CACHE[file] = found | |
187. | |
188. yield(found, mtime) | |
189. }.compact | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in rotation | |
# | |
175. # Search Ruby files in your +Padrino.root+ and monitor them for changes. | |
176. # | |
177. def rotation | |
178. paths = Dir[Padrino.root("*")].unshift(Padrino.root).reject { |path| Padrino::Reloader.exclude.include?(path) || !File.directory?(path) } | |
179. | |
180. files = paths.map { |path| Dir["#{path}/**/*.rb"] }.flatten | |
181. | |
182. files.map{ |file| | |
183. found, stat = figure_path(file, paths) | |
184. next unless found && stat && mtime = stat.mtime | |
185. | |
186. CACHE[file] = found | |
187. | |
188. yield(found, mtime) | |
189. }.compact | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in reload! | |
# | |
56. FILES_LOADED = {} | |
57. LOADED_CLASSES = {} | |
58. | |
59. ## | |
60. # Reload changed files | |
61. # | |
62. def reload! | |
63. rotation do |file, mtime| | |
64. # Retrive the last modified time | |
65. new_file = MTIMES[file].nil? | |
66. previous_mtime = MTIMES[file] ||= mtime | |
67. logger.debug "Detected a new file #{file}" if new_file | |
68. # We skip to next file if it is not new and not modified | |
69. next unless new_file || mtime > previous_mtime | |
70. # If the file is related to their app (i.e. a controller/mailer/helper) | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/loader.rb in reload! | |
# | |
17. Thread.current[:padrino_loaded] = true | |
18. end | |
19. | |
20. ## | |
21. # Method for reloading required applications and their files | |
22. # | |
23. def reload! | |
24. Reloader::Stat.reload! # detects the modified files | |
25. end | |
26. | |
27. ## | |
28. # This adds the ablity to instantiate Padrino.load! after Padrino::Application definition. | |
29. # | |
30. def called_from | |
31. @_called_from || first_caller | |
# /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.10/lib/padrino-core/reloader.rb in call | |
# | |
19. end | |
20. | |
21. def call(env) | |
22. if @cooldown and Time.now > @last + @cooldown | |
23. if Thread.list.size > 1 | |
24. Thread.exclusive { Padrino.reload! } | |
25. else | |
26. Padrino.reload! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment