ラベル Heroku の投稿を表示しています。 すべての投稿を表示
ラベル Heroku の投稿を表示しています。 すべての投稿を表示

2013/04/16

[heroku][node.js][Express]TwitterStreamingAPIを利用したサンプル

とりあえず前回deployまでは試してみたのでExpressでTwitterのStreamingAPIを利用してツイートを垂れ流してみました。

ファイル構成としては以下のようになっています。
  • routes - index.js
  • views - index.ejs
  • .gitignore
  • app.js
  • package.json
  • Procfile

/**
 * Node.js Twitter Streaming API Sample
 */

var express = require('express')
  , routes = require('./routes')
  , https = require('https')
  , socketIO = require('socket.io');

//twitterのAPI情報
var twitterApi = {
 host : 'stream.twitter.com',
 port : 443,
 path : '/1/statuses/filter.json?language=ja&locations=127.441,25.720,150.820,46.679',
 auth : 'XXX_username_XXX:XXX_password_XXX'
};

//Server設定
var app = express.createServer();
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.get('/', routes.index);

//Herokuの環境変数よりポート番号を取得、localhostでは3000を使用
var io = socketIO.listen(app.listen(process.env.PORT || 3000));
//HerokuではWebSocketが利用できないためpollingで対応 
io.configure(function () {
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10); 
  io.set('log level', 1);
});

//Twitter から Streaming API で取得したデータを
//クライアント側へ Socket.IO 経由で送信
var req = https.get(twitterApi).on('response', function(res) {
 res.on('data', function(chunk) {
  try{
   var tweet = JSON.parse(chunk);
   io.sockets.emit('tweet', {
    id: tweet.id,
    name: tweet.user.name,
    text: tweet.text,
    time: tweet.created_at,
    img : tweet.user.profile_image_url,
    place : tweet.place
   });
  } catch(e) { 
   console.log('-----response ERROR-----');
   console.log(e);
   console.log(chunk);
  }
 });
}).on('error', function(e){
 console.log(e);
});

//例外処理
process.on('uncaughtException', function (err) {
 console.log('uncaughtException => ' + err);
});
最初の5行目からは読み込むモジュールを記述。expressとroutesはさておき、TwitterのAPIを読み込むためhttpsモジュールを追加します。
socket.ioについて、node.jsで双方向通信を行うため非常に便利なモジュールです。具体的にはIE9などWebSocketをサポートしていないブラウザに対して代替手段を用いてリアルタイム通信を実現してくれるモジュールです。(WebSocket、Adobe® Flash® Socket、AJAX long polling、AJAX multipart streaming、Forever Iframe、JSONP Pollingの順序で使用中のブラウザが対応する通信手段を識別します)
10行目からはTwitterAPIのエンドポイント等の設定です。今回は位置情報を条件にセットし、日本語のツイートのみ対象としています。またStreamingAPIではベーシック認証を利用するのでUser/Pwは適せん変更してください。
19行目からはServerにアクセスしてきた時のサーバー情報です。サンプルは1ページしかないのでroutesのindex.jsを利用する必要はあまりないのですが今後の拡張を考えExpressの方式どおりrenderします。
25行目からはsocket.ioの設定です。herokuの環境変数を読み込み、存在しない場合はport:3000で接続します。(localhostの場合などで利用) またsocket.ioの通信方式について、heroku(Cedar stack)では内部のリソース制御のためか、xhr-pollingのみ利用可能となっています。詳細は公式を参照してください。
35行目からはTwitterのデータを取得しクライアントに送信しています。socket.ioではemitメソッドを利用してイベントを発生させ、クライアント側で検知して処理を行います。第1引数がイベント名、第2引数がデータとなります。
57行目の例外処理は、try~catchで検知できなかった場合のエラー処理となります。エラーでクラッシュした場合、サーバを稼動させ続けるためにこのような記述をしています。
exports.index = function(req, res){
  res.render('index', {});
};

<!DOCTYPE html>
<html>
<head>
<title>Node.js Twitter Streaming API Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<style type="text/css">
* {
    margin: 0;
    padding: 0;
}

div.media{
    border-bottom:1px solid #ddd;
    background-color: #ffffff;
    margin:0;
    padding:10px;
    font-size:10pt;
    line-height: 15px;
}

pre {
    padding:0;
    margin:0;
    border:none;
    background-color:#ffffff;
}
span.tweet_time,span.tweet_place{
    margin:0px 20px;
    color:#999999;
}
</style>
</head>
<body>
    <h1>Node.js Twitter Streaming API Sample</h1>
    <div id="tweetWrap">
        <script id="tweet" type="text/x-jquery-tmpl">
            <div class="media" id="${feedId}">
                <a class="pull-left" href="javascript:void(0)">
                    <img class="media-object" width="45px" src="${userImg}" />
                </a>
                <div class="media-body">
                    <h5 class="media-heading">${userNm}</h5>
                    <pre> ${body}</pre>
                    <span class="tweet_time">${time}</span>
                    <span class="tweet_place">${place}</span>
                </div>
            </div>
        </script>
    </div>
   
    <script src="/socket.io/socket.io.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
    <script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
    <script>
    $(function(){
        // ioオブジェクトチェック
        if (typeof io=="undefined") {
            $("#tweetWrap").html("<b>ioオブジェクトが作成できません[socket.io.jsエラー]</b>");
            return;
        }

        //サーバーに接続
        var socket = io.connect('/', {
            'reconnect': true,
            'reconnection delay': 1000,
            'reconnection limit': 1000,
            'max reconnection attempts': Infinity,
        });

        //ツイート受信のタイミングでフィードを追加
        socket.on('tweet', function(tweet) {
           var tweet ={
                feedId:tweet.id,
                userImg:tweet.img,
                userNm:tweet.name,
                body:tweet.text,
                time:tweet.time,
                place:(typeof tweet.place!="undefined")?tweet.place.full_name:""
            };
            //受信フィードを表示
            $("#tweet").tmpl(tweet).prependTo("#tweetWrap").hide().show("fast");
            //15件を超えたらフィードを削除
            (15<$("#tweetWrap").children().length) && $("div.media:last").remove();
        });
    });
    </script>

</body>
</html>

クライアント側の流れとしては、ツイートデータを受信したらjquery-tmplを利用して画面に追加しています。また見栄えをちょっとよくする為にbootstrapも利用しています。データはどんどん流れてくるため15件を超えたら一番古いデータ(一番下にあるデータ)を消しています。
57行目でsocket.ioのクライアント側のライブラリを読み込んでいます。この時点でioオブジェクトが作成されます。63行目で念のためioオブジェクトの存在チェックを行っています。
70行目でsocket.ioでサーバへの接続および再接続方法の設定を行っています。現在の設定は再接続は1秒毎に行い、無制限に再接続処理を行います。
※オプション詳細はこちら
78行目ではサーバでemitにより発生させたイベントを検知しています。検知の際はonメソッドを利用します。後はjquery-tmpl用にデータをパースして画面に表示します。(直接jquery-tmplに渡す形でデータ設計をしても良かったのですが、分かりやすくするためちょっと変えました)
{
  "name": "nodejs_twitter_steraming",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.1.1",
    "ejs": "*",
    "socket.io": "0.9.6"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}
socket.ioを追記しています。
node_modules
localでnpm installを実行した場合、node_modulesにモジュールファイルがインストールされます。これらをherokuにアップロードしないために当ファイルを作成します。
実際のサンプルはこちらです。これらのソースはGitHubに公開しています。 これまでのようにsocket.ioを利用する事で簡単にリアルタイム通信が実装できる事が分かりました。 またちょっと応用してこんなのを作ってみました。次回は双方向を試してみます。

2013/01/06

[heroku][node.js][Express]Deployまでの準備

node.jsもdeployしてみたので取り敢えずメモ
まーheorkuの公式に書いてあることをやってみただけ。。。

用意したのは下記4ファイル(expressコマンド -e で作成し必要なファイルのみ抜粋)
・views - index.ejs
・package.json
・Procfile
・web.js


中身はこんな感じ


<!DOCTYPE html>
<html>
  <head>
    <title><%= title %></title>
    <link rel='stylesheet' href='/stylesheets/style.css' />
  </head>
  <body>
    <h1><%= title %></h1>
    <p>Welcome to <%= title %></p>
  </body>
</html>

{
  "name": "test-ex",
  "version": "0.0.1",
  "dependencies": {
    "express": "2.5.x",
    "ejs": "*"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}
web: node web.js
※Herokuでnode.jsを動かす際にはProcfileを用意して、起動jsを記述する必要がある。
公式参照
var express = require('express');

var app = express.createServer(express.logger());

app.get('/', function(request, response) {
  //response.send('Hello World!');
  //せっかくなのでテンプレの内容を表示
  response.render('index.ejs', { title: 'Express' , layout: false });
});

var port = process.env.PORT || 5000;
app.listen(port, function() {
  console.log("Listening on " + port);
});


上記を用意した後、下記git、herokuコマンドを実施
>git init

>git add .

>git commit -m "1st commit"

>heroku create test-ex  ← git initをやった後の方が楽

>git push heroku master

>heroku open ← ブラウザが起動しデプロイしたWebアプリが表示される





2012/09/20

[Heroku]1台のPCで複数アカウントを利用する方法

複数アカウントを利用する際は、鍵ファイルも複数アカウント分必要になる。
なので、先ず鍵を作成。

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/yoshiroma/.ssh/id_rsa): /home/ yoshiroma /.ssh/id_oth_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/yoshiroma/.ssh/id_oth_rsa.
Your public key has been saved in /home/yoshiroma/.ssh/id_oth_rsa.pub.
The key fingerprint is:
XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX yoshiroma@ip-XX-XX-XX-XX


作成した鍵ファイルを使用してherokuにログインし直す
(loginコマンドの存在を知りませんでした・・・)

>heroku login
Enter your Heroku credentials.
Email:  yoshiroma@oth.com
Password (typing will be hidden):
Found the following SSH public keys:
1) id_rsa.pub
2) id_oth_rsa.pub
Which would you like to use with your Heroku account? 2
Uploading SSH public key /id_oth_rsa.pub... done
Authentication successful.


また.sshフォルダ内にconfigファイルがなければ作成し下記設定が必要


Host heroku.com
 User git
 port 22
 Hostname heroku.com
 IdentityFile ~/.ssh/id_oth_rsa
 TCPKeepAlive yes
 IdentitiesOnly yes




2012/07/03

[Heroku]環境構築(windows7) sec.4 - Herokuへのデプロイ


・railsアプリの作成(今回はdummypjというプロジェクトをDドライブ直下に作成)
コマンドプロンプトにて下記コマンドを入力
rails new dummypj

d:\>rails new dummypj
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/images/rails.png
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/mailers
      create  app/models
      create  app/views/layouts/application.html.erb
      create  app/mailers/.gitkeep
      create  app/models/.gitkeep
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  lib/assets
      create  lib/assets/.gitkeep
      create  log
      create  log/.gitkeep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/index.html
      create  public/robots.txt
      create  script
      create  script/rails
      create  test/fixtures
      create  test/fixtures/.gitkeep
      create  test/functional
      create  test/functional/.gitkeep
      create  test/integration
      create  test/integration/.gitkeep
      create  test/unit
      create  test/unit/.gitkeep
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.gitkeep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.gitkeep
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
         run  bundle install
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.3.6)
Using activesupport (3.2.6)
Using builder (3.0.0)
Using activemodel (3.2.6)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.6)
Using mime-types (1.19)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.6)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.6)
Using activeresource (3.2.6)
Using bundler (1.1.4)
Installing coffee-script-source (1.3.3)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.3)
Using rdoc (3.12)
Using thor (0.15.4)
Using railties (3.2.6)
Installing coffee-rails (3.2.2)
Installing jquery-rails (2.0.2)
Using rails (3.2.6)
Installing sass (3.1.20)
Installing sass-rails (3.2.5)
Installing sqlite3 (1.3.6)
Installing uglifier (1.2.6)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

d:\>


D:\dummypj\config\routes.rbの最下行に下記を追記
root :to => "products#index"


D:\dummypj\Gemfileのsqlite3に関する部分を修正
8行目周辺の「gem 'sqlite3'」を削除し下記を追記
(herokuではsqlite3のコンパイルでエラーとなるので開発環境のみで利用。
また本番デプロイ時にproductionの部分は自動的に書き換えられるためなくてもよい)
group :production do
  gem 'pg'
  gem 'therubyracer-heroku'
end
group :development, :test do
  gem 'sqlite3'
end


下記コマンドを実施
bundle --without production
(therubyracer-herokuでエラーとなるため。herokuにpushしたタイミングでheroku側でbundle installが走るのでローカルの確認では不要)
bundle exec rake assets:precompile RAILS_ENV=production(本番環境でRakeタスクを直接実行し、プリコンパイル済みのアセットを作成する やらないとエラーとなった)


D:\dummypj\config\environments\production.rb
falseからtrueに変更(18行目らへん)
# Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = true


ここからがデプロイ準備作業(下記コマンドを実施)
git init
git add .
git commit -m "New Create"
heroku create
git push heroku master
heroku open

ブラウザが起動し下記画面が表示されたら成功



※Gitのインストール後、鍵生成の作業が必要。参考サイトは下記
http://blog.infinity-dimensions.com/2012/01/git-gui-create-public-key.html


またデプロイ手順はこちらを参考にしました。
http://d.hatena.ne.jp/language_and_engineering/20110914/p1



[Heroku]環境構築(windows7) sec.1 - rubyのインストール
[Heroku]環境構築(windows7) sec.2 - 必要ファイルの更新
[Heroku]環境構築(windows7) sec.3 - Herokuの登録、gitのインストール
[Heroku]環境構築(windows7) sec.4 - Herokuへのデプロイ

2012/07/02

[Heroku]環境構築(windows7) sec.3 - Herokuの登録、gitのインストール

下記サイトでサインアップを行い手順に従ってherokuアカウントの登録を行う
https://api.heroku.com/signup



下記サイトからGitをダウンロードしexeを起動
http://code.google.com/p/msysgit/downloads/list



基本的にはそのまま「Next」でOKだが下記の画面でラジオボタンの変更を行う





全て終わったらコマンドプロンプトを起動し下記コマンド入力で動作確認

C:\>git --version
git version 1.7.11.msysgit.0

heroku関連のgemをコマンドプロンプトから下記2コマンドでインストール開始
gem search -r heroku
gem install heroku bundler



[Heroku]環境構築(windows7) sec.1 - rubyのインストール
[Heroku]環境構築(windows7) sec.2 - 必要ファイルの更新
[Heroku]環境構築(windows7) sec.3 - Herokuの登録、gitのインストール
[Heroku]環境構築(windows7) sec.4 - Herokuへのデプロイ

2012/06/30

[heroku]稼動/障害状況の確認

herokuで作成したWebアプリ等が動作しない場合は下記でheroku自体の稼動/障害状況を確認できます。
https://status.heroku.com/


ちなみに今日は2時間以上落ちてる orz=3

2012/06/29

[Heroku]環境構築(windows7) sec.2 - 必要ファイルの更新

コマンドプロンプトを起動して下記コマンドを実行


・Rubyのインストールフォルダに移動
cd C:\Ruby193

・RubyGems の更新
gem install rubygems-update
update_rubygems

・rspec, rspec-rails, gitのインストール
gem update
gem install rspec
gem install rspec-rails
gem install git

・Ruby on Railsのインストール
gem install pkg-config
gem install rails


■コマンド実行時のログ


c:\Ruby193>gem install rubygems-update
Fetching: rubygems-update-1.8.24.gem (100%)
Successfully installed rubygems-update-1.8.24
1 gem installed
Installing ri documentation for rubygems-update-1.8.24...
unable to convert U+0160 from UTF-8 to Windows-31J for History.txt, skipping
Installing RDoc documentation for rubygems-update-1.8.24...
unable to convert U+0160 from UTF-8 to Windows-31J for History.txt, skipping

c:\Ruby193>update_rubygems
RubyGems 1.8.24 installed
unable to convert U+0160 from UTF-8 to Windows-31J for History.txt, skipping
unable to convert U+0160 from UTF-8 to Windows-31J for History.txt, skipping

== 1.8.24 / 2012-04-27

* 1 bug fix:

  * Install the .pem files properly. Fixes #320
  * Remove OpenSSL dependency from the http code path


------------------------------------------------------------------------------

RubyGems installed the following executables:
        C:/Ruby193/bin/gem


c:\Ruby193>gem update
Updating installed gems
Updating json
Fetching: json-1.7.3.gem (100%)
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed json-1.7.3
Updating minitest
Fetching: minitest-3.2.0.gem (100%)
Successfully installed minitest-3.2.0
Updating rdoc
Fetching: rdoc-3.12.gem (100%)
Depending on your version of ruby, you may need to install ruby rdoc/ri data:

<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Successfully installed rdoc-3.12
Gems updated: json, minitest, rdoc
Installing ri documentation for json-1.7.3...
Installing ri documentation for minitest-3.2.0...
Installing ri documentation for rdoc-3.12...
unable to convert U+00A9 from UTF-8 to Windows-31J for lib/rdoc/text.rb, skipping
unable to convert "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for History.rdoc, skipping
Installing RDoc documentation for json-1.7.3...
Installing RDoc documentation for minitest-3.2.0...
Installing RDoc documentation for rdoc-3.12...
unable to convert U+00A9 from UTF-8 to Windows-31J for lib/rdoc/text.rb, skipping
unable to convert "\xD0" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for History.rdoc, skipping

c:\Ruby193>gem install rspec
Fetching: rspec-core-2.10.1.gem (100%)
Fetching: diff-lcs-1.1.3.gem (100%)
Fetching: rspec-expectations-2.10.0.gem (100%)
Fetching: rspec-mocks-2.10.1.gem (100%)
Fetching: rspec-2.10.0.gem (100%)
Successfully installed rspec-core-2.10.1
Successfully installed diff-lcs-1.1.3
Successfully installed rspec-expectations-2.10.0
Successfully installed rspec-mocks-2.10.1
Successfully installed rspec-2.10.0
5 gems installed
Installing ri documentation for rspec-core-2.10.1...
Installing ri documentation for diff-lcs-1.1.3...
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for License.rdoc, skipping
Installing ri documentation for rspec-expectations-2.10.0...
Installing ri documentation for rspec-mocks-2.10.1...
Installing ri documentation for rspec-2.10.0...
Installing RDoc documentation for rspec-core-2.10.1...
Installing RDoc documentation for diff-lcs-1.1.3...
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for License.rdoc, skipping
Installing RDoc documentation for rspec-expectations-2.10.0...
Installing RDoc documentation for rspec-mocks-2.10.1...
Installing RDoc documentation for rspec-2.10.0...

c:\Ruby193>gem install rspec-rails
Fetching: i18n-0.6.0.gem (100%)
Fetching: multi_json-1.3.6.gem (100%)
Fetching: activesupport-3.2.6.gem (100%)
Fetching: builder-3.0.0.gem (100%)
Fetching: activemodel-3.2.6.gem (100%)
Fetching: rack-1.4.1.gem (100%)
Fetching: rack-cache-1.2.gem (100%)
Fetching: rack-test-0.6.1.gem (100%)
Fetching: journey-1.0.4.gem (100%)
Fetching: hike-1.2.1.gem (100%)
Fetching: tilt-1.3.3.gem (100%)
Fetching: sprockets-2.1.3.gem (100%)
Fetching: erubis-2.7.0.gem (100%)
Fetching: actionpack-3.2.6.gem (100%)
Fetching: rack-ssl-1.3.2.gem (100%)
Fetching: thor-0.15.4.gem (100%)
Fetching: railties-3.2.6.gem (100%)
Fetching: rspec-rails-2.10.1.gem (100%)
Successfully installed i18n-0.6.0
Successfully installed multi_json-1.3.6
Successfully installed activesupport-3.2.6
Successfully installed builder-3.0.0
Successfully installed activemodel-3.2.6
Successfully installed rack-1.4.1
Successfully installed rack-cache-1.2
Successfully installed rack-test-0.6.1
Successfully installed journey-1.0.4
Successfully installed hike-1.2.1
Successfully installed tilt-1.3.3
Successfully installed sprockets-2.1.3
Successfully installed erubis-2.7.0
Successfully installed actionpack-3.2.6
Successfully installed rack-ssl-1.3.2
Successfully installed thor-0.15.4
Successfully installed railties-3.2.6
Successfully installed rspec-rails-2.10.1
18 gems installed
Installing ri documentation for i18n-0.6.0...
unable to convert U+00C0 from UTF-8 to Windows-31J for lib/i18n/backend/transliterator.rb, skipping
unable to convert U+00E4 from UTF-8 to Windows-31J for lib/i18n/tests/interpolation.rb, skipping
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for lib/i18n.rb, skipping
Installing ri documentation for multi_json-1.3.6...
Installing ri documentation for activesupport-3.2.6...
Installing ri documentation for builder-3.0.0...
Installing ri documentation for activemodel-3.2.6...
Installing ri documentation for rack-1.4.1...
Installing ri documentation for rack-cache-1.2...
Installing ri documentation for rack-test-0.6.1...
Installing ri documentation for journey-1.0.4...
Installing ri documentation for hike-1.2.1...
Installing ri documentation for tilt-1.3.3...
Installing ri documentation for sprockets-2.1.3...
Installing ri documentation for erubis-2.7.0...
Installing ri documentation for actionpack-3.2.6...
Installing ri documentation for rack-ssl-1.3.2...
Installing ri documentation for thor-0.15.4...
Installing ri documentation for railties-3.2.6...
Installing ri documentation for rspec-rails-2.10.1...
Installing RDoc documentation for i18n-0.6.0...
unable to convert U+00C0 from UTF-8 to Windows-31J for lib/i18n/backend/transliterator.rb, skipping
unable to convert U+00E4 from UTF-8 to Windows-31J for lib/i18n/tests/interpolation.rb, skipping
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for lib/i18n.rb, skipping
Installing RDoc documentation for multi_json-1.3.6...
Installing RDoc documentation for activesupport-3.2.6...
Installing RDoc documentation for builder-3.0.0...
Installing RDoc documentation for activemodel-3.2.6...
Installing RDoc documentation for rack-1.4.1...
Installing RDoc documentation for rack-cache-1.2...
Installing RDoc documentation for rack-test-0.6.1...
Installing RDoc documentation for journey-1.0.4...
Installing RDoc documentation for hike-1.2.1...
Installing RDoc documentation for tilt-1.3.3...
Installing RDoc documentation for sprockets-2.1.3...
Installing RDoc documentation for erubis-2.7.0...
Installing RDoc documentation for actionpack-3.2.6...
Installing RDoc documentation for rack-ssl-1.3.2...
Installing RDoc documentation for thor-0.15.4...
Installing RDoc documentation for railties-3.2.6...
Installing RDoc documentation for rspec-rails-2.10.1...

c:\Ruby193>gem install git
Fetching: git-1.2.5.gem (100%)
Successfully installed git-1.2.5
1 gem installed
Installing ri documentation for git-1.2.5...
Installing RDoc documentation for git-1.2.5...

c:\Ruby193>gem install pkg-config
Fetching: pkg-config-1.1.3.gem (100%)
Successfully installed pkg-config-1.1.3
1 gem installed
Installing ri documentation for pkg-config-1.1.3...
Installing RDoc documentation for pkg-config-1.1.3...

c:\Ruby193>gem install rails
Fetching: arel-3.0.2.gem (100%)
Fetching: tzinfo-0.3.33.gem (100%)
Fetching: activerecord-3.2.6.gem (100%)
Fetching: activeresource-3.2.6.gem (100%)
Fetching: mime-types-1.19.gem (100%)
Fetching: polyglot-0.3.3.gem (100%)
Fetching: treetop-1.4.10.gem (100%)
Fetching: mail-2.4.4.gem (100%)
Fetching: actionmailer-3.2.6.gem (100%)
Fetching: bundler-1.1.4.gem (100%)
Fetching: rails-3.2.6.gem (100%)
Successfully installed arel-3.0.2
Successfully installed tzinfo-0.3.33
Successfully installed activerecord-3.2.6
Successfully installed activeresource-3.2.6
Successfully installed mime-types-1.19
Successfully installed polyglot-0.3.3
Successfully installed treetop-1.4.10
Successfully installed mail-2.4.4
Successfully installed actionmailer-3.2.6
Successfully installed bundler-1.1.4
Successfully installed rails-3.2.6
11 gems installed
Installing ri documentation for arel-3.0.2...
Installing ri documentation for tzinfo-0.3.33...
Installing ri documentation for activerecord-3.2.6...
Installing ri documentation for activeresource-3.2.6...
Installing ri documentation for mime-types-1.19...
unable to convert U+2013 from UTF-8 to Windows-31J for lib/mime/types.rb, skipping
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for Licence.rdoc, skipping
Installing ri documentation for polyglot-0.3.3...
Installing ri documentation for treetop-1.4.10...
Installing ri documentation for mail-2.4.4...
unable to convert U+00E9 from UTF-8 to Windows-31J for lib/mail/multibyte/chars.rb, skipping
Installing ri documentation for actionmailer-3.2.6...
Installing ri documentation for bundler-1.1.4...
Installing ri documentation for rails-3.2.6...
Installing RDoc documentation for arel-3.0.2...
Installing RDoc documentation for tzinfo-0.3.33...
Installing RDoc documentation for activerecord-3.2.6...
Installing RDoc documentation for activeresource-3.2.6...
Installing RDoc documentation for mime-types-1.19...
unable to convert U+2013 from UTF-8 to Windows-31J for lib/mime/types.rb, skipping
unable to convert "\xE2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to Windows-31J for Licence.rdoc, skipping
Installing RDoc documentation for polyglot-0.3.3...
Installing RDoc documentation for treetop-1.4.10...
Installing RDoc documentation for mail-2.4.4...
unable to convert U+00E9 from UTF-8 to Windows-31J for lib/mail/multibyte/chars.rb, skipping
Installing RDoc documentation for actionmailer-3.2.6...
Installing RDoc documentation for bundler-1.1.4...
Installing RDoc documentation for rails-3.2.6...

c:\Ruby193>


●下記サイトを参考にしました
http://www.kkaneko.com/rinkou/ruby/rubyinstaller.html


[Heroku]環境構築(windows7) sec.1 - rubyのインストール
[Heroku]環境構築(windows7) sec.2 - 必要ファイルの更新
[Heroku]環境構築(windows7) sec.3 - Herokuの登録、gitのインストール
[Heroku]環境構築(windows7) sec.4 - Herokuへのデプロイ

[Heroku]環境構築(windows7) sec.1 - rubyのインストール


■下記ページでrubyのインストーラーとDevKitをダウンロード
http://rubyinstaller.org/





■rubyのインストール




インストール先のパスはcドライブの直下
Add Ruby executables to your PATHにチェック




■DevKitのインストール
ダウンロードしたexeファイル(例:DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe)を起動すると
ファイルが展開される(後でファイル移動するので、新規フォルダを作ってその中で起動するのがおすすめ)※展開すると下記イメージのような感じ


上記のすべてのファイルを「C:\Ruby193」rubyのインストール先に移動
( 下記イメージのような感じ )


コマンドプロンプトを起動し、下記コマンドを実行

cd C:\Ruby193

ruby dk.rb init
ruby dk.rb install


上記まで終わったら下記コマンドで動作確認
ruby --version

●下記サイトを参考にしました
http://www.kkaneko.com/rinkou/ruby/rubyinstaller.html


[Heroku]環境構築(windows7) sec.1 - rubyのインストール
[Heroku]環境構築(windows7) sec.2 - 必要ファイルの更新
[Heroku]環境構築(windows7) sec.3 - Herokuの登録、gitのインストール
[Heroku]環境構築(windows7) sec.4 - Herokuへのデプロイ