sinatra

Sinatra with Figaro Gem

…衆ロ難τιáo~ 提交于 2019-12-02 11:34:40
I m trying to use Figaro gem with Sinatra. I have installed Figaro and it created the following file/ folder... /config/application.yml On this file I have added some environment variables... ENV['GMAIL_USERNAME'] ENV['GMAIL_PASSWORD'] Then on my my "app.rb" file I am trying to include the yml file like... require 'config/application.yml' How can I have access to my "ENV['BIG_SECRET']" in my app.rb file? Mail.defaults do delivery_method :smtp, { :address => 'smtp.gmail.com', :port => '587', :domain => 'mydomain.com', :user_name => ENV['GMAIL_USERNAME'], :password => ENV['GMAIL_PASSWORD'],

Sinatra doesn't know this ditty even when default route is implemented with modular style

…衆ロ難τιáo~ 提交于 2019-12-02 11:34:21
问题 I'm running MacOS mavericks whith jruby and am trying to write a basic modular sinatra app. Here's what my config.ru looks like require 'app/app' run Sinatra::Application I invoke it like this with rackup , you can see the 404 errors - rackup -s puma -p 8080 Puma 2.10.2 starting... * Min threads: 0, max threads: 16 * Environment: development * Listening on tcp://localhost:8080 127.0.0.1 - - [17/Jan/2015:18:32:37 -0500] "GET / HTTP/1.1" 404 437 0.0290 127.0.0.1 - - [17/Jan/2015:18:32:37 -0500]

Posting JSON params from java to sinatra service

ⅰ亾dé卋堺 提交于 2019-12-02 07:39:21
I have an android app posting to my sinatra service. Earlier I was not able to read parameters on my sinatra service. However, after I set content type to "x-www-form-urlencoded". I was able to see params but not quite how I wanted. I am getting something this as my params of the request at my sinatra service. {"{\"user\":{\"gender\":\"female\"},\"session_id\":\"7a13fd20-9ad9-45c2-b308- 8f390b4747f8\"}"=> nil, "splat"=>["update_profile.json"], "captures"=>["update_profile.json"]} This is how I am making request from my app. StringEntity se; se = new StringEntity(getJsonObjectfromNameValueList

Why Sinatra request takes EM thread?

不打扰是莪最后的温柔 提交于 2019-12-02 04:33:06
Sinatra app receives requests for long running tasks and EM.defer them, launching them in EM's internal pool of 20 threads. When there are more than 20 EM.defer running, they are stored in EM's threadqueue by EM.defer. However, it seems Sinatra won't service any requests until there is an EM thread available to handle them. My question is, isn't Sinatra suppose to use the reactor of the main thread to service all requests? Why am I seeing an add on the threadqueue when I make a new request? Steps to reproduce: Access /track/ Launch 30 /sleep/ reqs to fill the threadqueue Access /ping/ and

Running Ruby app on Apache

若如初见. 提交于 2019-12-02 03:46:21
问题 I have been learning Ruby lately, and I want to upload a test web application to my server. But I can't figure out how to get it to run on my shared hosting. My Hosting Details Shared Hosting with JustHost (see here for list of features) OS: Linux Apache: 2.2.11 cPanel: 11.25.0-STABLE No SSH access. Can install Ruby Gems. Can't install Apache modules. Can " Manage Ruby on Rails Applications " through cPanel. Mongrel gem is installed. I built the following simple HelloWorld Ruby Rack app using

Styling a sudoku grid

偶尔善良 提交于 2019-12-02 02:50:17
I’ve created a sudoku puzzle creator / solver and need a bit of help with some CSS to style it. Typically they are styled like this: . Some naming I’m using. Cell - each individual cell which contains a single number. Box - one of the 9 boxes each containing 3 x 3 cells Grid - the entire 9x9 playing area. My html is partially generated by my ruby / Sinatra app (at least the repeating DIV’s are) and structured as such : #game { margin-left: auto; margin-right: auto; width: 360px; } .cell input { display: inline-block; float: left; width: 40px; height: 40px; border-style: solid; border-width:

Running Ruby app on Apache

痴心易碎 提交于 2019-12-02 02:40:31
I have been learning Ruby lately, and I want to upload a test web application to my server. But I can't figure out how to get it to run on my shared hosting. My Hosting Details Shared Hosting with JustHost (see here for list of features ) OS: Linux Apache: 2.2.11 cPanel: 11.25.0-STABLE No SSH access. Can install Ruby Gems. Can't install Apache modules. Can " Manage Ruby on Rails Applications " through cPanel. Mongrel gem is installed. I built the following simple HelloWorld Ruby Rack app using Sinatra : #!/usr/bin/ruby ruby require 'rubygems' require 'sinatra' get '/hi' do "Hello World!" end I

reading parameters on Sinatra post

自古美人都是妖i 提交于 2019-12-01 23:50:20
I'm working on my first Sinatra app and I have an hard time getting parameters from a post request. I'm using MiniTest::Spec and my spec looks like payload = File.read("./spec/support/fixtures/payload.json") post "/api/v1/verify_payload", { payload: payload }, { "CONTENT_TYPE" => "application/json" } last_response.body.must_eql payload And this is my route namespace '/api/v1' do post '/verify_payload' do MultiJson.load(params[:payload]) end end The spec fails because last_response.body is empty. Am I missing something here? I also tried to return the entire params from verify_payload but also

Mongo find by regex: return only matching string

随声附和 提交于 2019-12-01 20:43:30
My application has the following stack: Sinatra on Ruby -> MongoMapper -> MongoDB The application puts several entries in the database. In order to crosslink to other pages, I've added some sort of syntax. e.g.: Coffee is a black, caffeinated liquid made from beans. {Tea} is made from leaves. Both drinks are sometimes enjoyed with {milk} In this example {Tea} will link to another DB entry about tea. I'm trying to query my mongoDB about all 'linked terms'. Usually in ruby I would do something like this: /{([a-zA-Z0-9])+}/ where the () will return a matched string. In mongo however I get the

Error when starting Sinatra: “tried to create Proc object without a block”

只愿长相守 提交于 2019-12-01 20:43:21
I am very new to ruby / rails and have an issue that I have not been able to figure out but feel it should be relatively simple to fix. Command: ruby app.rb Error: /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1144:in `define_method': tried to create Proc object without a block (ArgumentError) from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1144:in `compile!' from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1129:in `route' from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1111:in `get' from /Library/Ruby/Gems/1.8/gems