Skip to content

Commit

Permalink
EmbeddedRuby.cs now supports application-specific AppBoot.rb, so move…
Browse files Browse the repository at this point in the history
…d Sinatra stram hack into one. Extended File.file? and File.exist? now that Serfs can supply the information
  • Loading branch information
rifraf committed May 3, 2010
1 parent 3147bab commit 10199c9
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions IREmbeddedApp/EmbeddedRuby.cs
Expand Up @@ -78,6 +78,7 @@ public class EmbeddedRuby {
require 'EmbeddedRuby/IOSupport'
require 'EmbeddedRuby/FileSupport'
require 'EmbeddedRuby/Misc'
require 'EmbeddedRuby/AppBoot' if File.exist?('EmbeddedRuby/AppBoot.rb')
load $0.dup if $0
"
, app, argv, _serfs.Read("EmbeddedRuby/RequireSupport.rb"));
Expand Down
15 changes: 2 additions & 13 deletions IREmbeddedApp/EmbeddedRuby/FileSupport.rb
Expand Up @@ -57,17 +57,6 @@ def open(filename, *args, &blk)
return nil unless stream

open_mode.include?('b') ? stream.select_binarymode : stream.select_textmode

# Sinatra hack
class << stream
def each
rewind
while buf = read(8192)
yield buf
end
end
end

stream
end

Expand All @@ -87,12 +76,12 @@ def stat(filename)

alias old_exist? exist?
def exist?(filename)
old_exist?(filename) || !!(filename =~ /^\//) # TEMP!!!
old_exist?(filename) || SerfsInstance.exists(filename) || SerfsInstance.folder_exists(filename)
end

alias old_file? file?
def file?(filename)
old_file?(filename) || !!(SerfsInstance.read_embedded_file(filename))
old_file?(filename) || SerfsInstance.exists(filename)
end

alias old_expand_path expand_path
Expand Down
Binary file modified IREmbeddedApp/Serfs.dll
Binary file not shown.
16 changes: 16 additions & 0 deletions IRSinatra/Applications/EmbeddedRuby/AppBoot.rb
@@ -0,0 +1,16 @@
# Sinatra hack
#
# Sinatra overrides Stream.each to limit blocks to
# 8192 bytes. If we are reading from Serfs, this won't
# affect our stream because it is not a _real_ stream.
# Hence the following patch
#
class System::IO::UnmanagedMemoryStream
def each
rewind
while buf = read(8192)
yield buf
end
end
end

3 changes: 3 additions & 0 deletions IRSinatra/IRSinatra.csproj
Expand Up @@ -77,6 +77,9 @@
<ItemGroup>
<EmbeddedResource Include="Applications\Public\index.html" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Applications\EmbeddedRuby\AppBoot.rb" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file modified IRSinatra/bin/IREmbeddedApp.dll
Binary file not shown.
Binary file modified IRSinatra/bin/IRSinatra.exe
Binary file not shown.
Binary file modified IRSinatra/bin/Serfs.dll
Binary file not shown.
Binary file modified IRSinatra/bin/merge/IRSinatra.exe
Binary file not shown.
6 changes: 3 additions & 3 deletions IRSinatra/status.txt
Expand Up @@ -5,11 +5,11 @@ DONE: Webrick doesn't find the Sinatra 404 image
DONE: Loads of 'unknown:0: warning: already initialized constant RC_BAD_REQUEST' etc
DONE: Serve statics out of public?
DONE: S: really?
DONE: Tabs/spaces cleanup
DONE: Merge assemblies (ilmerge)
Sinatra 'each' issue.

On Firefox, we get occasional 'you have chosen to open...' dialogs when refreshing. Not seen on others.
Look on disk - where?
Sinatra 'each' issue.
Tabs/spaces cleanup
Merge assemblies (ilmerge)
Improve on exist?
Option to prevent disk lookup

0 comments on commit 10199c9

Please sign in to comment.