サーバー Ruby の sinatra で、適当に GET するとバッテリ状況を保存するサーバー書いた https://gist.github.com/anekos/8255991 一瞬でかけました。 Android 端末 Tasker というアプリを使用。 HTTP Get のアクションを使って http://example.com/level/$devicename/$level を定期的に叩く (普段ネットに繋がないような端末は、WIFI On > Wait (%WIFI = On) > WIFI Off とかするといいっぽい。 ノート C# で適当にプログラム書いた。 こいつをタスクスケジューラで、定期的に実行してやる。 https://gist.github.com/anekos/8256104 割と苦戦したけど、内容は超簡単。 BatteryLifePercent が floa
Twitter authentication with OmniAuth¶ ↑ OmniAuth provides several strategies (released as gems) that provides authentication for a lot of systems, such as Facebook, Google, GitHub, and many more. Each strategy is a Rack middleware, so it's very easy to integrate with Sinatra. This recipe will show you how to add user authentication to your Sinatra application using Twitter as your authentication p
A Sinatra-Sequel-RSpec Template Apr 25 rgraffwork rspec, sequel, sinatra 6 Comments I’m just getting to the fun part of writing an app, the part where I’m actually writing the app and not just trying to get my environment setup. A couple days ago, I would’ve loved to have found a post that explains how to get Sinatra, Sequel, and RSpec working together plus have all the files organized so that I c
Ruby,Rubygems,MongoDBはインストールされているものとする MongoDBのインストールについてはCentOSであれば前にちょっと書いた 過去の記事:CentOS5.5にMongoDBをインストールする - chulip.org インストール Bundlerを使用して必要なGemをインストールする。 なおMongoDBのORMとしてMongoidを使用する $ gem install bundlerGemfile source :rubygems gem 'sinatra' gem 'mongoid' gem 'bson_ext' gem 'SystemTimer' #1.8.7だけ必要だったぽい group :test do gem 'rspec' gem 'rack-test' end$ bundle install bson_extとSystemTimer bson
Heads-up: Dashing still works great, but is no longer maintained. Read up about it over here. You can also use the fork of the project. Dashing is a Sinatra based framework that lets you build beautiful dashboards. Check out a demo over here. Here's another one, optimized for 1080p screens. Key features: Use premade widgets, or fully create your own with scss, html, and coffeescript. Widgets harne
Sleipnir for Mac、Sleipnir Mobile for iPhone/iPad 開発担当の福井です。 今回はモバイルアプリの開発時に役に立つ、Sinatra を紹介させていただきます。 アプリを開発するとき、連携する Web API の実装がまだなくて実装を進められない、API の実装と並行してアプリを実装してはみたけど、API と連携してみると全然動かなかった、そんな経験をしたことはありませんか?Web API が完成していないけど、アプリのリリースは遅らせることができないというのはよくあるシチュエーションだと思います。そんなときは、Sinatra の導入を検討してみてはいかがでしょうか。 Sinatra とは? Sinatra といえばフランク・シナトラ…ではなくて Ruby 製 Web アプリケーションフレームワークです。Ruby で Web アプリケーションという
ためしに、URLを入れるとaタグのhref属性とxy座標と幅と高さが取れる簡単なアプリを作ってみた。herokuでwebkitが動いててサーバー側でいったんページをレンダリングしてるから、座標とかがわかる。 http://phantom-getlinks.herokuapp.com/ ソースコード https://github.com/shokai/sinatra-heroku-phantomjs readmeに書いてある通りやればローカルでもHerokuでもすぐ動かせるのでcloneしてみるとよい。 PhantomJSでページをレンダリングしてからaタグの座標とか読む PhantomJSはプロセス内にwebブラウザ(webkit)を起動して、しかもその中のJavaScriptにアクセスできる → 橋本商会 » PhantomJSでwebページ内のJavaScriptを読む Phantom
以前書いたものの続きです。 rspecと同様ほとんど変りはありません。と言ったら違うか。。 サンプルコード require './hello_world' require 'capybara' require 'capybara/dsl' require 'test/unit' class HelloWorldTest < Test::Unit::TestCase include Capybara::DSL # Capybara.default_driver = :selenium def setup Capybara.app = Sinatra::Application.new end def test_it_works visit '/' assert page.has_content?('Hello World') end end コードの理解 capybaraを使う場合は capy
以前書いたものの続きです。 題名の通りsinatraでrspecを使う基本的なことがらになります。 sinatraだけの設定を考えるとtest/unitと同じです。乱暴に言うとassertがshouldになるだけだと思ってよいと思います。 サンプルコード 前回のサンプルコードをrspecで書く。 require './hello_world' require 'rspec' require 'rack/test' set :environment, :test describe 'The HelloWorld App' do include Rack::Test::Methods def app Sinatra::Application end it "says hello" do get '/' last_response.should be_ok last_response.body.
Testing Sinatra with Rack::Test All examples in the following sections assume that Test::Unit is being used in an attempt to be as general as possible. See the Test Framework Examples for information on using the test helpers in other testing environments. To use the Rack::Test library used when you require rack/test, you’ll need to install the rack-test gem:
「sinatraすげー」って今さら思い、sinatraで何か作ってみようかねーと思い、当然テストのことが気になりました。 そもそも「テスト出来るの?実はrailsと比べて大変じゃないの???」って感じのアホな不安でした。(1週間前までsinatraのことと言えば名前しかしらなかったので。。)テストについてはちゃんと公式ページで解説されています。rspecも使えます。capybaraも使えます。他のテストフレームワークも使えるようです。 参考ページは Testing Sinatra with Rack::Test です。ここの内容を理解していきます。 サンプルコード テスト対象のコード。いつものhello world。 require 'sinatra' get '/' do "Hello World #{params[:name]}".strip end テストコード require '.
先日書いた、麻雀スクリプトをSinatraに乗っけてみました。 ・rubyで麻雀の待ちを出力 - うんたらかんたら日記 ・麻雀スクリプトのテストコード - うんたらかんたら日記 amachang作の↓をみて 清一色メーカー rubyでもsinatra使えばサクッとできる(らしい)よね、 と思い立ちチャレンジしてみました。 ついでに、sinatraでRSpec動かすのと、 ちゃんと使ったことの無いhaml/saasをこれを機に使ってみました。 ソース rochefort/majang_sina - GitHub herokuデプロイ先 麻雀聴牌チェッカー こんなかんじ。 感想 「また、つまらぬものを...」感がありますが、個人的にはいろいろ試せて良かったです。 ほとんどデザイン入れて無いので、haml / saasの醍醐味は味わえてませんが saasはある程度ルール決めれば、cssは結構キレ
Sinatra はRubyの軽量アプリケーションサーバです。 コンソールに出力するのではなく、ブラウザに表示することで、ちょっとした見栄えのいいアプリケーションを書くのに向いています。 Top インストール 簡単な例 (1) 簡単な例 (2) HTMLのページを作る やや複雑なアプリの場合 コンフィギュレーション セッション フォームとpostメソッド フィルタ クラスの構成 設定 コマンド テスト Sinatra::Contrib Extensionの使用 Sinatra::Reloader ApacheとSinatra (Passenger) ApacheとSinatra (FastCGI) インストール インストール方法は、ネットのどこかに詳しく書いてありますが、gemを使いこんな感じでインストールできます。 $ sudo gem install sinatra ちゃんとインストール
Top インストール 簡単な例 (1) 簡単な例 (2) HTMLのページを作る やや複雑なアプリの場合 コンフィギュレーション セッション フォームとpostメソッド フィルタ クラスの構成 設定 コマンド テスト Sinatra::Contrib Extensionの使用 Sinatra::Reloader ApacheとSinatra (Passenger) ApacheとSinatra (FastCGI) クラスの構成 Application クラシックスタイルアプリケーションの実行を受け持つクラス。 Base すべてのSinatraアプリケーションとミドルウェアの基礎となるクラス。 Templates::ContentTyped content_type属性のみを持つモジュール。 Delegator このモジュールを含めることにより、Sinatra::Applicationのすべ
This is a Sinatra extension that provides Linked Data content negotiation for Sinatra applications. http://github.com/datagraph/sinatra-linkeddata Features Implements HTTP content negotiation for RDF content types using the Rack::LinkedData middleware. Supports all RDF.rb-compatible serialization formats. Supports both classic and modular Sinatra applications. Examples Adding Linked Data content n
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く