Skip to content

Commit

Permalink
Todoアプリケーション2.0.0で利用するライブラリ
Browse files Browse the repository at this point in the history
  • Loading branch information
k2works committed Dec 5, 2015
1 parent 6df1f31 commit 7721d8e
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ RUN apt-get update -y && apt-get install -y \
sqlite3 \
curl

RUN gem install bundler rack
RUN gem install bundler rack sinatra haml

WORKDIR /app

VOLUME /app

EXPOSE 9292
EXPOSE 9292 4567

ENTRYPOINT ["/bin/bash"]

2 changes: 2 additions & 0 deletions attr_sample.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%form{action: '/TASKS'.downcase} Rubyスクリプトを解釈する
%form(action='/tasks') HTML属性風の指定
9 changes: 2 additions & 7 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
require 'rack'
require './sinatra_modular'

class RackApplication
def call(env)
[200, {'Content-Type' => 'text/plain'},['Hello!']]
end
end

run RackApplication.new
run Application
4 changes: 4 additions & 0 deletions div_sample.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.error
エラー
#error_message
エラーメッセージ
2 changes: 2 additions & 0 deletions multi_class.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.foo_class.bar_class
hi
4 changes: 4 additions & 0 deletions ruby_sample.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
%ul
- %w(alice bob carol).each do |name|
%li
= name
5 changes: 5 additions & 0 deletions sample.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%hml
%body
%h1.error エラーメッセージ
%p#error_message
エラー内容
5 changes: 5 additions & 0 deletions sinatra_classic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'sinatra'

get '/' do
'Classic Style Sinatra!'
end
17 changes: 17 additions & 0 deletions sinatra_configure.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'sinatra'

configure do
puts 'default configure'
end

configure :production do
puts 'production configure'
end

configure :development, :test do
puts 'development,test configure'
end

get '/' do
'configure sample'
end
9 changes: 9 additions & 0 deletions sinatra_env_sample.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'sinatra'

get '/' do
puts "settings.production? => #{settings.production?}"
puts "settings.development? => #{settings.development?}"
puts "settings.test? => #{settings.test?}"

"configure sample"
end
9 changes: 9 additions & 0 deletions sinatra_modular.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'sinatra/base'

class Application < Sinatra::Base
get '/' do
'Modular Style Sinatra!'
end
end

#Application.run!
9 changes: 9 additions & 0 deletions sinatra_request.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'sinatra'

get '/' do
puts "params => #{params}"
puts "params.class => #{request.inspect}"
puts "request => #{request.class.ancestors}"

'request sample'
end
11 changes: 11 additions & 0 deletions sinatra_response.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'sinatra'

get '/' do
'response sample'
end

get '/response' do
status 404
headers 'Content-Type' => 'text/plain'
body 'response sample'
end
9 changes: 9 additions & 0 deletions sinatra_routing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'sinatra'

get '/:name' do
"Hi #{params[:name]}"
end

get '/profile' do # こちらには処理が到達しない
'profile'
end
14 changes: 14 additions & 0 deletions sinatra_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'sinatra'

get '/' do
erb :index
end

__END__

@@ index
<html>
<body>
<h1>Ruby Version = <%= RUBY_VERSION %></h1>
</body>
</html>

0 comments on commit 7721d8e

Please sign in to comment.