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
# Steps to repro: | |
# | |
# Set up two XMPP accounts: | |
# "account1@yourserver.org" and "account2@yourserver.org" | |
# Both with password "password" | |
# | |
# Start the sinatra webserver server using: | |
# | |
# ruby -rubygems xmpp4r_harness.rb | |
# |
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
require 'rubygems' | |
require 'xmpp4r' | |
require 'sinatra' | |
# Doing XMPP connectivity like this has terrible performance: | |
# | |
# https://gist.github.com/1197232 | |
# | |
# Here's a better way. | |
# |
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
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV) | |
require File.expand_path('../../config/boot', __FILE__) | |
require 'minitest/matchers' | |
require 'valid_attribute' | |
require 'valid_attribute/minitest' | |
require PADRINO_ROOT + '/test/blueprints' | |
class MiniTest::Spec |
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
require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb') | |
describe "User Model" do | |
# Associations | |
# | |
it "has_many videos" do | |
v1 = Video.make | |
v2 = Video.make | |
user = User.make |
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
/* Here's the first way, the "view" version: When your code calls request.pathInfo, the compiler says, | |
"HttpServletRequest doesn't have pathInfo. But it can implicitly convert to RichRequest. | |
I'm going to call RichRequest.servletRequestToRichRequest, and then call pathInfo on the result of that." */ | |
class RichRequest(req: HttpServletRequest) extends Request { | |
def pathInfo = req.getPathInfo | |
} | |
object RichRequest { | |
implicit def servletRequestToRichRequest(req: HttpServletRequest) = new RichRequest(request) |
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
The current Scalatra book structure is as follows. Personally I find it confusing that some information can be found in more than one part of the book. | |
Table of Contents | |
Introduction | |
What is Scalatra? | |
Introduction | |
Git clone alternative | |
Dependencies | |
Building | |
Hello World Application |
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
// This action receives the file upload. | |
post("/upload") { | |
processFile(fileParams("somefile")) | |
} | |
// This method processes the uploaded file in some way. | |
private def processFile(upload:FileItem) = { | |
val filePath:String = "/some/place/to/store/the/file" | |
val file:File = new File(filePath + upload.getName) | |
upload.write(file); |
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
# Startup completes successfully. Hitting the first URL, the following error is thrown: | |
# java package `org.jruby.rack.name.name.name' does not have a method `split' | |
# this has also happened on javax.security.name.name.name | |
# Reading the stack trace, we can see that it's somehow related to | |
https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/reloader.rb#L106 | |
# The code in question is the "split" method call on the first line of lock!: |
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
> compile | |
[info] Compiling 6 Scala sources to /home/dave/workspace/manning-book/swagger-sample-app/target/scala-2.9.2/classes... | |
[error] /home/dave/workspace/manning-book/swagger-sample-app/src/main/scala/Bootstrap.scala:3: LifeCycle is not a member of org.scalatra | |
[error] import org.scalatra.LifeCycle | |
[error] ^ | |
[error] /home/dave/workspace/manning-book/swagger-sample-app/src/main/scala/Bootstrap.scala:5: not found: type LifeCycle | |
[error] class ScalatraBootstrap extends LifeCycle { | |
[error] ^ | |
[error] /home/dave/workspace/manning-book/swagger-sample-app/src/main/scala/Bootstrap.scala:10: value mount is not a member of javax.servlet.ServletContext | |
[error] context mount (new PetServlet, "/pet") |
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
servlet_name [MyScalatraServlet]: Flowers | |
scala_version [2.9.2]: | |
version [0.1.0-SNAPSHOT]: | |
missing region "; do | |
case $@end$ tag | |
Can't parse chunk: (grep ^sbt.version project/build.properties) | |
versionString=${versionLine##sbt.version=} | |
echo " | |
line 1:7: unexpected char: '^' | |
at org.antlr.stringtemplate.language.ActionLexer.nextToken(ActionLexer.java:220) |
OlderNewer