GitHub
 - [ https://github.com/shu0115/paypal-scaffold ]

RubyGems.org
 - [ https://rubygems.org/gems/paypal-scaffold ]

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

◆作業ディレクトリ移動
cd ~/labo

◆Jewelerインストール
gem install jeweler

◆GitHubユーザ/トークン設定
git config --global github.user shu0115
git config --global github.token 6ef8395fecf207165f1a82178ae1b984
-----
※ダミー=>「6ef8395fecf207165f1a82178ae1b984」
 参考:Issue #230: No github.user found -- no github token because github API moving!! · technicalpickles/jeweler
   => [ https://github.com/technicalpickles/jeweler/issues/230 ]

◆RubyGems.org作成予定パッケージ名未登録確認
http://rubygems.org/
 => Search gems... [ paypal-scaffold ]
-----
search for paypal-scaffold
No entries found
-----

◆パッケージ雛形作成
jeweler --rspec paypal-scaffold

◆ディレクトリ移動
cd paypal-scaffold

◆Gemfile編集
※「bundler」「rcov」コメントアウト
-----
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
#   gem "activesupport", ">= 2.3.5"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
  gem "rspec", "~> 2.8.0"
  gem "rdoc", "~> 3.12"
#  gem "bundler", "~> 1.0.0"
  gem "jeweler", "~> 1.8.3"
#  gem "rcov", ">= 0"
end
-----

◆bundleインストール
bundle install

◆バージョンファイル作成
rake version:write
-----
Updated version: 0.0.0
-----

◆マイナーバージョンアップ
rake version:bump:minor
-----
Current version: 0.0.0
Updated version: 0.1.0
-----

◆Rakefile修正
-----
  gem.license = "MIT"
  gem.summary = %Q{TODO: one-line summary of your gem}
  gem.description = %Q{TODO: longer description of your gem}
-----
-----
  gem.license = "CC BY-NC-SA 2.1"
  gem.summary = "PayPal Scaffold"
  gem.description = "Scaffold for PayPal."
-----

◆パッケージビルド
rake build

◆.gitignore編集
※「Gemfile.lock」追加
-----
Gemfile.lock
-----

◆GitHubリポジトリ作成
https://github.com/new
-----
Repository name:[ paypal-scaffold ]
Description (optional):[ Scaffold for PayPal. ]
-----

◆コミット/プッシュ
git add . && git commit -m "create new gem"
git push -u origin master

◆Gem内部コード作成
https://github.com/shu0115/paypal-scaffold

◆Gemリビルド
rake build

◆gemspec作成(※未コミットファイルはgemspecファイルのパスに書き込まれない)
git add . && git commit -m "update"
rake gemspec

◆GitHubプッシュ
git add . && git commit -m "update"
git push

◆ローカルGemインストール
gem install -l pkg/paypal-scaffold-0.1.0.gem
-----
Successfully installed paypal-scaffold-0.1.0
1 gem installed
-----

◆RubyGems公開
rake release

◆RubyGems.orgページ
https://rubygems.org/gems/paypal-scaffold

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

[ Railsアプリ組み込み ]
◆ローカルGemアンインストール
gem uninstall paypal-scaffold

◆Railsアプリ作成
rails new sample01
cd sample01

◆Gemfile編集
Gemfile
-----
gem 'paypal-scaffold'
-----

◆Gemインストール
bundle install

◆ヘルプ確認
rails g -h
-----
Paypal:
  paypal:scaffold
-----

◆paypal:scaffold実行
rails g paypal:scaffold
-----
      create  app/models/paypal_api.rb
      create  config/initializers/local_setting.rb
-----

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

[ Gemローカルインストール ]
git add . && git commit -m "update"
rake build
gem uninstall paypal-scaffold
gem install -l pkg/paypal-scaffold-0.1.0.gem

[rails g再実行]
bundle update
rails g paypal:scaffold

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

[ Gemアップデートリリース ]
◆コミット
git add . && git commit -m "update"

◆パッチバージョンアップ
rake version:bump:patch

◆Gemリリース
rake release

◆RubyGems.orgページ確認
https://rubygems.org/gems/paypal-scaffold

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

◆トラブルシューティング(文字コードエラー対応)
[ エラー ]
/Users/shu/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.14.6/lib/thor/actions/inject_into_file.rb:100:in `include?': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)

[ scaffold_generator.rb ]
-----
append_file "config/initializers/local_setting.rb", content.force_encoding('ASCII-8BIT')
-----

◆Rubyバージョン
ruby -v
-----
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]
-----

◆Railsバージョン
rails -v
-----
Rails 3.2.3
-----

----------

◆作業ディレクトリ移動
cd ~/labo

◆Railsアプリ作成
rails new lein
cd lein

◆Gemfile編集
vi Gemfile
---
G 文末へ
$ 行末へ
-----
# For Heroku
gem 'thin'

group :production do
  gem 'pg'
end

# Utility
gem 'kaminari'
gem 'omniauth-twitter'
gem 'twitter'

group :development do
  gem 'omniauth-scaffold'
  gem 'custom-template'
end
-----

◆Gemインストール
bundle install --without production

◆OmniAuth用スキャフォールド作成
rails g omniauth:scaffold
-----
      create  config/initializers/omniauth.rb
      create  config/initializers/local_setting.rb
      create  config/initializers/constants.rb
      insert  config/routes.rb
      insert  config/routes.rb
      insert  config/routes.rb
      insert  config/application.rb
      insert  config/application.rb
      create  config/locales/ja.yml
      create  db/migrate/20000101000000_create_users.rb
      create  app/models/user.rb
      create  app/controllers/sessions_controller.rb
    conflict  app/controllers/application_controller.rb
Overwrite /Users/shu/labo/lein/app/controllers/application_controller.rb? (enter "h" for help) [Ynaqdh] h
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
Overwrite /Users/shu/labo/lein/app/controllers/application_controller.rb? (enter "h" for help) [Ynaqdh] a
       force  app/controllers/application_controller.rb
      create  app/controllers/top_controller.rb
    conflict  app/views/layouts/application.html.erb
       force  app/views/layouts/application.html.erb
      create  app/views/top/index.html.erb
      create  app/assets/stylesheets/base.css.scss
      create  app/assets/stylesheets/scaffolds.css.scss
      remove  public/index.html
      remove  README.rdoc
      create  README.md
      insert  .gitignore
-----

◆scaffoldカスタムテンプレート生成
rails g custom:template

◆アプリ名設定
vi config/initializers/constants.rb
-----
APP_NAME = "Lein"
-----

◆ローカル用Twitterキー設定
https://dev.twitter.com/apps
vi config/initializers/local_setting.rb
-----
# Twitter
ENV['TWITTER_KEY'] = "YOUR_CONSUMER_KEY"
ENV['TWITTER_SECRET'] = "YOUR_CONSUMER_SECRET"
-----

◆アセットパイプラインログ無効設定
vi config/environments/development.rb
-----
  # Expands the lines which load the assets
#  config.assets.debug = true
  config.assets.debug = false
-----

◆マイグレーション
rake db:migrate
-----
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0031s
==  CreateUsers: migrated (0.0042s) ===========================================
-----

◆Railsサーバ起動
rails s
-----
=> Booting Thin
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
-----

◆ローカルサイト確認
http://0.0.0.0:3000/

◆Gitリポジトリ作成
git init
-----
Initialized empty Git repository in /Users/shu/labo/lein/.git/
-----

◆コミット
git add . && git commit -m "first commit"
git status
-----
# On branch master
nothing to commit (working directory clean)
-----

◆Herokuアプリ作成
heroku create lein
-----
Creating lein... done, stack is bamboo-mri-1.9.2
http://lein.heroku.com/ | git@heroku.com:lein.git
Git remote heroku added
-----

◆リモートリポジトリ確認
git remote -v
-----
heroku git@heroku.com:lein.git (fetch)
heroku git@heroku.com:lein.git (push)
-----

◆プリコンパイル
rake assets:precompile RAILS_ENV=production

◆コミット
git add . && git commit -m "update"

◆Herokuプッシュ
git push heroku master
-----
To git@heroku.com:lein.git
 * [new branch]      master -> master
-----

◆Herokuマイグレーション
heroku rake db:migrate

◆Twitterアプリ登録
https://dev.twitter.com/apps/new
-----
Name: *
[ Lein ]

Description: *
[ Cloud Supporter System. ]

WebSite: *
[ https://lein.heroku.com/ ]

Callback URL:
[ https://lein.heroku.com/ ]
-----
※必須マークが無いが「Callback URL:」も登録しないと動かない

◆Heroku環境変数設定
heroku config:add TWITTER_KEY=(Consumer key)
heroku config:add TWITTER_SECRET=(Consumer secret)

◆Heroku設定確認
heroku config list | grep TWITTER
-----
TWITTER_KEY         => (Consumer key)
TWITTER_SECRET   => (Consumer secret)
-----

◆Herokuアドオンインストール(FREE-Only)
heroku addons:add stillalive:basic
heroku addons:add pgbackups:auto-month
heroku addons:add newrelic:standard
heroku addons:add loggly:mole
-----
https://addons.heroku.com/stillalive
https://addons.heroku.com/pgbackups
https://addons.heroku.com/newrelic
https://addons.heroku.com/loggly

heroku addons
-----
loggly:mole
newrelic:standard
pgbackups:auto-month
shared-database:5mb
stillalive:basic
-----

◆Herokuページオープン
heroku open

◆GitHubリポジトリ作成
https://github.com/repositories/new
-----
Project Name
[ lein ]

Description (optional)
[ Cloud Supporter System. ]

Homepage URL (optional)
[ https://lein.heroku.com/ ]
-----

◆GitHubリポジトリプッシュ
git remote add origin git@github.com:shu0115/lein.git
git push -u origin master

◆GitHubリポジトリ
https://github.com/shu0115/lein

◆Heroku公開サイト
https://lein.heroku.com/

----------

[ 更新フロー ]
git add . && git commit -m "update"
git push origin master
git push heroku master

[ プリコンパイル ]
rake assets:precompile RAILS_ENV=production
git add . && git commit -m "update"
git push origin master
git push heroku master

[ マイグレーション ]
git add . && git commit -m "update"
git push origin master
git push heroku master
heroku rake db:migrate

◆rubygems-updateインストール
gem install rubygems-update

◆gemsアップデート
update_rubygems
---
 sudo /Users/raisondetre0115/.gem/ruby/1.8/bin/update_rubygems

/Users/raisondetre0115/.gem/ruby/1.8/bin/update_rubygems
/Users/raisondetre0115/.gem/ruby/1.8/gems/rubygems-update-1.4.2/bin/update_rubygems

----------

gem update –system でアップデートをしようとしたが、 どうやらバグのようである。

    * gem install rubygems-update
    * update_rubygems

上記の方法で、無事アップデート終了

◆Rubyバージョン
ruby -v
-----
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]
-----

◆Railsバージョン
rails -v
-----
Rails 3.2.3
-----

----------

◆作業ディレクトリ移動
cd ~/labo

◆Railsアプリ作成
rails new weego
cd weego

◆Gemfile編集
vi Gemfile
-----
# For Heroku
gem 'thin'

group :production do
  gem 'pg'
end

# Utility
gem 'kaminari'
gem 'omniauth-scaffold'
gem 'omniauth-twitter'
gem 'twitter'
gem 'custom-template'
-----

◆Gemインストール
bundle install --without production

◆OmniAuth用スキャフォールド作成
rails g omniauth:scaffold
-----
      create  config/initializers/omniauth.rb
      create  config/initializers/local_setting.rb
      create  config/initializers/constants.rb
      insert  config/routes.rb
      insert  config/routes.rb
      insert  config/routes.rb
      create  db/migrate/20000101000000_create_users.rb
      create  app/models/user.rb
      create  app/controllers/sessions_controller.rb
    conflict  app/controllers/application_controller.rb
Overwrite /Users/shu/labo/weego/app/controllers/application_controller.rb? (enter "h" for help) [Ynaqdh] a
       force  app/controllers/application_controller.rb
      create  app/controllers/top_controller.rb
    conflict  app/views/layouts/application.html.erb
       force  app/views/layouts/application.html.erb
      create  app/views/top/index.html.erb
      remove  public/index.html
      remove  README.rdoc
      create  README.md
      insert  .gitignore
-----

scaffoldカスタムテンプレート生成
rails g custom:template

◆アプリ名設定
config/initializers/constants.rb
-----
APP_NAME = "Weego"
-----

◆ローカル用Twitterキー設定
config/initializers/local_setting.rb
-----
# Twitter
ENV['TWITTER_KEY'] = "YOUR_CONSUMER_KEY"
ENV['TWITTER_SECRET'] = "YOUR_CONSUMER_SECRET"
-----

◆アセットパイプラインログ無効設定
config/environments/development.rb
-----
  # Expands the lines which load the assets
#  config.assets.debug = true
  config.assets.debug = false
-----

◆マイグレーション
rake db:migrate
-----
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0111s
==  CreateUsers: migrated (0.0112s) ===========================================
-----

◆Railsサーバ起動
rails s
-----
=> Booting Thin
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
-----

◆ローカルサイト確認
http://0.0.0.0:3000/

◆Gitリポジトリ作成
git init
-----
Initialized empty Git repository in /Users/shu/labo/weego/.git/
-----

◆プリコンパイル
rake assets:precompile RAILS_ENV=production

◆コミット
git add . && git commit -m "first commit"

git status
-----
# On branch master
nothing to commit (working directory clean)
-----

◆Herokuアプリ作成
heroku create weego
-----
Creating weego... done, stack is bamboo-mri-1.9.2
http://weego.heroku.com/ | git@heroku.com:weego.git
Git remote heroku added
-----

◆リモートリポジトリ確認
git remote -v
-----
heroku git@heroku.com:weego.git (fetch)
heroku git@heroku.com:weego.git (push)
-----

◆Herokuプッシュ
git push heroku master
-----
To git@heroku.com:weego.git
 * [new branch]      master -> master
-----

◆Herokuマイグレーション
heroku rake db:migrate

◆Twitterアプリ登録
https://dev.twitter.com/apps/new
-----
Name: *
[ Weego ]

Description: *
[ Simple Attend App. ]

WebSite: *
[ https://weego.heroku.com/ ]

Callback URL:
[ https://weego.heroku.com/ ]
-----
※必須マークが無いが「Callback URL:」も登録しないと動かない

◆Heroku環境変数設定
heroku config:add TWITTER_KEY=(Consumer key)
heroku config:add TWITTER_SECRET=(Consumer secret)

◆Heroku設定確認
heroku config list | grep TWITTER
-----
TWITTER_KEY         => (Consumer key)
TWITTER_SECRET   => (Consumer secret)
-----

◆Herokuページオープン
heroku open

◆GitHubリポジトリ作成
https://github.com/repositories/new
-----
Project Name
[ weego ]

Description (optional)
[ Simple Attend App. ]

Homepage URL (optional)
[ https://weego.heroku.com/ ]
-----

◆GitHubリポジトリプッシュ
git remote add origin git@github.com:shu0115/weego.git
git push -u origin master

◆GitHubリポジトリ
https://github.com/shu0115/weego

◆Heroku公開サイト
https://weego.heroku.com/

◆作業ディレクトリ移動
cd ~/labo

◆Jewelerインストール
gem install jeweler
-----
Successfully installed jeweler-1.8.3
1 gem installed
-----

◆GitHubユーザ/トークン設定
git config --global github.user shu0115
git config --global github.token 6ef8395fecf207165f1a82178ae1b984
-----
※ダミー=>「6ef8395fecf207165f1a82178ae1b984」
 参考:Issue #230: No github.user found -- no github token because github API moving!! · technicalpickles/jeweler
   => [ https://github.com/technicalpickles/jeweler/issues/230 ]

◆rubygems.org作成予定パッケージ名未登録確認
http://rubygems.org/
 => Search gems... [ custom-template ]
-----
search for custom-template
No entries found
-----

◆パッケージ雛形作成
jeweler --rspec custom-template
-----
create .gitignore
create Rakefile
create Gemfile
create LICENSE.txt
create README.rdoc
create .document
create lib
create lib/custom-template.rb
create spec
create spec/spec_helper.rb
create spec/custom-template_spec.rb
create .rspec
-----

◆ディレクトリ移動
cd custom-template

◆Gemfile編集
※「bundler」「rcov」コメントアウト
-----
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
#   gem "activesupport", ">= 2.3.5"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
  gem "rspec", "~> 2.8.0"
  gem "rdoc", "~> 3.12"
#  gem "bundler", "~> 1.0.0"
  gem "jeweler", "~> 1.8.3"
#  gem "rcov", ">= 0"
end
-----

◆bundleインストール
bundle install
-----
Fetching gem metadata from http://rubygems.org/......
Fetching gem metadata from http://rubygems.org/..
Using rake (0.9.2.2) 
Using bundler (1.1.3) 
Using diff-lcs (1.1.3) 
Using git (1.2.5) 
Using json (1.6.6) 
Using rdoc (3.12) 
Using jeweler (1.8.3) 
Using rspec-core (2.8.0) 
Using rspec-expectations (2.8.0) 
Using rspec-mocks (2.8.0) 
Using rspec (2.8.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
-----

◆バージョンファイル作成
rake version:write
-----
Updated version: 0.0.0
-----

◆マイナーバージョンアップ
rake version:bump:minor
-----
Current version: 0.0.0
Updated version: 0.1.0
-----

◆Rakefile修正
-----
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
-----
-----
gem.summary = "Custom Scaffold Template"
gem.description = "Custom Template for Scaffold."
-----

◆パッケージビルド
rake build
-----
  Successfully built RubyGem
  Name: custom-template
  Version: 0.1.0
  File: custom-template-0.1.0.gem
-----

◆.gitignore編集
※「Gemfile.lock」追加
-----
Gemfile.lock
-----

◆GitHubリポジトリ作成
https://github.com/new
-----
Repository name:[ custom-template ]
Description (optional):[ Custom Template for Scaffold. ]
-----

◆コミット/プッシュ
git add . && git commit -m "create new gem"
git push -u origin master

◆Gem内部コード作成
https://github.com/shu0115/custom-template
-----
custom-template
  lib
    generators
      custom
        template
          templates
            erb
            rails
          template_generator.rb
-----

◆Gemリビルド
rake build

◆gemspec作成(※未コミットファイルはgemspecファイルのパスに書き込まれない)
git add . && git commit -m "update"
rake gemspec
-----
Generated: custom-template.gemspec
custom-template.gemspec is valid.
-----

◆GitHubプッシュ
git add . && git commit -m "update"
git push

◆ローカルGemインストール
gem install -l pkg/custom-template-0.1.0.gem
-----
Successfully installed custom-template-0.1.0
1 gem installed
-----

[ インストールリスト ]
gem list custom-template
-----
*** LOCAL GEMS ***

custom-template (0.1.0)
-----

◆RubyGems.orgアカウント作成
https://rubygems.org/users/new

◆RubyGems公開
rake release
-----
rm -r pkg/custom-template-0.1.0.gem
Committing custom-template.gemspec
Pushing master to origin
Tagging v0.1.0
Pushing v0.1.0 to origin
Generated: custom-template.gemspec
custom-template.gemspec is valid.
  Successfully built RubyGem
  Name: custom-template
  Version: 0.1.0
  File: custom-template-0.1.0.gem
Executing "gem push ./pkg/custom-template-0.1.0.gem":
gem push ./pkg/custom-template-0.1.0.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: custom-template (0.1.0)
-----

◆RubyGems.orgページ
https://rubygems.org/gems/custom-template

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

[ Railsアプリ組み込み ]
◆ローカルGemアンインストール
gem uninstall custom-template
-----
Successfully uninstalled custom-template-0.1.0
-----

◆Railsアプリ作成
rails new sample01
cd sample01

◆Gemfile編集
Gemfile
-----
gem 'custom-template'
-----

◆Gemインストール
bundle install
-----
Installing custom-template (0.1.0) 
-----

◆ヘルプ確認
rails g -h
-----
Custom:
  custom:template
-----

◆custom:template実行
rails g custom:template
-----
      create  lib/templates/erb
      create  lib/templates/erb/controller/view.html.erb
      create  lib/templates/erb/mailer/view.text.erb
      create  lib/templates/erb/scaffold/_form.html.erb
      create  lib/templates/erb/scaffold/edit.html.erb
      create  lib/templates/erb/scaffold/index.html.erb
      create  lib/templates/erb/scaffold/new.html.erb
      create  lib/templates/erb/scaffold/show.html.erb
      create  lib/templates/rails
      create  lib/templates/rails/controller/controller.rb
      create  lib/templates/rails/helper/helper.rb
      create  lib/templates/rails/scaffold_controller/controller.rb
      create  lib/templates/rails/stylesheets/scaffold.css
-----

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

[ Gemアップデート ]
◆コミット
git add . && git commit -m "update"

◆パッチバージョンアップ
rake version:bump:patch
-----
Current version: 0.1.0
Updated version: 0.1.1
-----

◆Gemリリース
rake release
-----
rm -r pkg/custom-template-0.1.0.gem
Pushing master to origin
Tagging v0.1.1
Pushing v0.1.1 to origin
Generated: custom-template.gemspec
custom-template.gemspec is valid.
  Successfully built RubyGem
  Name: custom-template
  Version: 0.1.1
  File: custom-template-0.1.1.gem
Executing "gem push ./pkg/custom-template-0.1.1.gem":
gem push ./pkg/custom-template-0.1.1.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: custom-template (0.1.1)
-----

◆RubyGems.orgページ確認
https://rubygems.org/gems/custom-template


GitHub
 - [ https://github.com/shu0115/omniauth-scaffold ]

RubyGems.org
 - [ https://rubygems.org/gems/omniauth-scaffold ]

-----

参考ページ:
Rubyist Magazine - Jeweler で作る Rails 用 RubyGems パッケージとそのテストについて
 - [ http://jp.rubyist.net/magazine/?0037-CreateRailsPlugin ]

seyhunak/twitter-bootstrap-rails
 - [ https://github.com/seyhunak/twitter-bootstrap-rails ]

Module: Thor::Actions(Rails::Generators::Baseの継承元)
 - [ http://textmate.rubyforge.org/thor/Thor/Actions.html ]

wycats/thor
 - [ https://github.com/wycats/thor ]

-----

◆作業ディレクトリ移動
cd ~/labo

◆Jewelerインストール
gem install jeweler
-----
Fetching: jeweler-1.8.3.gem (100%)
Successfully installed jeweler-1.8.3
1 gem installed
-----

◆GitHubユーザ/トークン設定
git config --global github.user shu0115
git config --global github.token 6ef8395fecf207165f1a82178ae1b984
-----
※ダミー=>「6ef8395fecf207165f1a82178ae1b984」
 参考:Issue #230: No github.user found -- no github token because github API moving!! · technicalpickles/jeweler
   => [ https://github.com/technicalpickles/jeweler/issues/230 ]

◆rubygems.org作成予定パッケージ名未登録確認
http://rubygems.org/
 => Search gems... [ omniauth-scaffold ]
-----
search for omniauth-scaffold
No entries found
-----

◆パッケージ雛形作成
jeweler --rspec omniauth-scaffold
-----
create .gitignore
create Rakefile
create Gemfile
create LICENSE.txt
create README.rdoc
create .document
create lib
create lib/omniauth-scaffold.rb
create spec
create spec/spec_helper.rb
create spec/omniauth-scaffold_spec.rb
create .rspec
Jeweler has prepared your gem in ./omniauth-scaffold
-----

◆ディレクトリ移動
cd omniauth-scaffold

◆Gemfile編集
※「bundler」「rcov」コメントアウト
-----
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
#   gem "activesupport", ">= 2.3.5"
gem 'omniauth-twitter'
gem 'omniauth-github'
gem 'omniauth-facebook'

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
  gem "rspec", "~> 2.8.0"
  gem "rdoc", "~> 3.12"
#  gem "bundler", "~> 1.0.0"
  gem "jeweler", "~> 1.8.3"
#  gem "rcov", ">= 0"
end
-----

◆bundleインストール
bundle install

◆バージョンファイル作成
rake version:write
-----
Updated version: 0.0.0
-----

◆マイナーバージョンアップ
rake version:bump:minor
-----
Current version: 0.0.0
Updated version: 0.1.0
-----

◆Rakefile修正
-----
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
-----
-----
gem.summary = "OmniAuth Scaffold"
gem.description = "Scaffold to use OmniAuth."
-----

◆パッケージビルド
rake build
-----
  Successfully built RubyGem
  Name: omniauth-scaffold
  Version: 0.1.0
  File: omniauth-scaffold-0.1.0.gem
-----

◆.gitignore編集
※「Gemfile.lock」追加
-----
Gemfile.lock
-----

◆GitHubリポジトリ作成
https://github.com/new
-----
Repository name:[ omniauth-scaffold ]
Description (optional):[ Scaffold for OmniAuth. ]
-----

◆コミット
git add . && git commit -m "create new gem"

◆GitHubへプッシュ
git push -u origin master

◆Gem内部コード作成
https://github.com/shu0115/omniauth-scaffold/tree/master/lib/generators
-----
omniauth-scaffold
  lib
    generators
      omniauth
        scaffold
          templates
            app
              controllers
                application_controller.rb
                sessions_controller.rb
                top_controller.rb
              models
                user.rb
              views
                layouts
                  application.html.erb
                top
                  index.html.erb
            config
              initializers
                constants.rb
                local_setting.rb
                omniauth.rb
            db
              migrate
                create_users.rb
            README.rdoc
          scaffold_generator.rb
-----

◆gemspec作成
rake gemspec
-----
Generated: omniauth-scaffold.gemspec
omniauth-scaffold.gemspec is valid.
-----

◆Gemリビルド&コミット/プッシュ
rake build
git add . && git commit -m "update"
git push

◆ローカルGemインストール
[ ヘルプ ]
gem install -h
-----
  Local/Remote Options:
    -l, --local                      Restrict operations to the LOCAL domain
-----

[ インストール ]
gem install -l pkg/omniauth-scaffold-0.1.0.gem
-----
Successfully installed omniauth-scaffold-0.1.0
1 gem installed
-----

[ インストールリスト ]
gem list omniauth-scaffold
-----
*** LOCAL GEMS ***

omniauth-scaffold (0.1.0)
-----

◆RubyGems.orgアカウント作成
https://rubygems.org/users/new

◆RubyGems公開
rake release
-----
Committing omniauth-scaffold.gemspec
Pushing master to origin
Tagging v0.1.0
Pushing v0.1.0 to origin
Generated: omniauth-scaffold.gemspec
omniauth-scaffold.gemspec is valid.
  Successfully built RubyGem
  Name: omniauth-scaffold
  Version: 0.1.0
  File: omniauth-scaffold-0.1.0.gem
Executing "gem push ./pkg/omniauth-scaffold-0.1.0.gem":
gem push ./pkg/omniauth-scaffold-0.1.0.gem
Enter your RubyGems.org credentials.
Don't have an account yet? Create one at http://rubygems.org/sign_up
   Email:   **********@gmail.com
Password:   
Pushing gem to https://rubygems.org...
Signed in.
Pushing gem to https://rubygems.org...
Successfully registered gem: omniauth-scaffold (0.1.0)
-----

◆RubyGems.orgページ
https://rubygems.org/gems/omniauth-scaffold

◆作成Gemインストール
rails new sample01
cd sample01

vi Gemfile
-----
gem 'omniauth-scaffold'
gem 'omniauth-twitter'
-----
※omniauth-scaffoldにはOmniAuthモジュールを含まないためomniauth-twitterも同時インストール

bundle install
-----
Installing omniauth-scaffold (0.1.0) 
-----

rails g -h
-----
Omniauth:
  omniauth:scaffold
-----

rails g omniauth:scaffold
-----
      create  config/initializers/omniauth.rb
      create  config/initializers/local_setting.rb
      create  config/initializers/constants.rb
      insert  config/routes.rb
      insert  config/routes.rb
      insert  config/routes.rb
      create  db/migrate/20000101000000_create_users.rb
      create  app/models/user.rb
      create  app/controllers/sessions_controller.rb
    conflict  app/controllers/application_controller.rb
Overwrite /Users/*****/labo/sample02/app/controllers/application_controller.rb? (enter "h" for help) [Ynaqdh] a
       force  app/controllers/application_controller.rb
      create  app/controllers/top_controller.rb
    conflict  app/views/layouts/application.html.erb
       force  app/views/layouts/application.html.erb
      create  app/views/top/index.html.erb
      remove  public/index.html
    conflict  README.rdoc
       force  README.rdoc
-----

rake db:migrate
-----
==  CreateUsers: migrating ====================================================
-- create_table(:users)
   -> 0.0023s
==  CreateUsers: migrated (0.0024s) ===========================================
-----

rails s
-----
=> Booting WEBrick
=> Rails 3.2.3 application starting in development on http://0.0.0.0:3100
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-04-26 15:16:04] INFO  WEBrick 1.3.1
[2012-04-26 15:16:04] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin10.8.0]
[2012-04-26 15:16:04] INFO  WEBrick::HTTPServer#start: pid=4266 port=3100
-----

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

◆ローカルGemインストール/Railsアプリ組み込み
[ Gemインストール ]
cd ~/labo/omniauth-scaffold
gem install -l pkg/omniauth-scaffold-0.1.0.gem
-----
Successfully installed omniauth-scaffold-0.1.0
1 gem installed
-----

[ 作業ディレクトリ移動 ]
cd ~/labo

[ Railsアプリ作成 ]
rails new sample01

[ Gemfile編集 ]
vi Gemfile
-----
gem 'omniauth-scaffold'
gem 'omniauth-twitter'
-----

[ Gemインストール ]
bundle install

[ ヘルプ確認 ]
rails g -h
-----
Omniauth:
  omniauth:scaffold
-----

[ Omniauth Scaffold実行 ]
rails g omniauth:scaffold

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

◆Gemアンインストール
gem uninstall omniauth-scaffold
-----
Successfully uninstalled omniauth-scaffold-0.1.0
-----

◆omniauth:scaffold削除
rails destroy omniauth:scaffold

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

◆ローカルGemリビルド/再インストール
rake build

gem uninstall omniauth-scaffold
gem install -l pkg/omniauth-scaffold-0.1.0.gem
gem install -l pkg/omniauth-scaffold-0.1.1.gem
gem install -l pkg/omniauth-scaffold-0.1.2.gem
gem install -l pkg/omniauth-scaffold-0.1.3.gem

rails destroy omniauth:scaffold
rails g omniauth:scaffold

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

◆Gemアップデートフロー
git add . && git commit -m "update"

rake version:bump:patch
-----
Current version: 0.1.0
Updated version: 0.1.1
-----

rake release
-----
Pushing master to origin
Tagging v0.1.1
Pushing v0.1.1 to origin
Generated: omniauth-scaffold.gemspec
omniauth-scaffold.gemspec is valid.
  Successfully built RubyGem
  Name: omniauth-scaffold
  Version: 0.1.1
  File: omniauth-scaffold-0.1.1.gem
Executing "gem push ./pkg/omniauth-scaffold-0.1.1.gem":
gem push ./pkg/omniauth-scaffold-0.1.1.gem
Pushing gem to https://rubygems.org...
Successfully registered gem: omniauth-scaffold (0.1.1)
-----

https://rubygems.org/gems/omniauth-scaffold

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

◆トラブルシューティング
https://gist.github.com/2aa095171285a7b806a7

◆作業ディレクトリ移動
cd ~/meteor_labo

◆サンプルプロジェクト一覧
meteor create --list
-----
Available examples:
  leaderboard
  todos
  wordplay
-----

◆サンプルプロジェクト作成
[ Leaderboard ]
meteor create --example leaderboard
-----
leaderboard: created.

To run your new app:
   cd leaderboard
   meteor
-----

[ Todos ]
meteor create --example todos
-----
todos: created.

To run your new app:
   cd todos
   meteor
-----

[ Wordplay ]
meteor create --example wordplay
-----
wordplay: created.

To run your new app:
   cd wordplay
   meteor
-----

◆プロジェクト実行ヘルプ
meteor help run
-----
Usage: meteor run [options]

Searches upward from the current directory for the root directory of a
Meteor project, then runs that project in local development
mode. You can use the application by pointing your web browser at
localhost:3000. No internet connection is required.

Whenever you change any of the application's source files, the changes
are automatically detected and applied to the running application.

The application's database persists between runs. It's stored under
the .meteor directory in the root of the project.


Options:
  --port, -p    Port to listen on. NOTE: Also uses port N+1 and N+2.         [default: 3000]
  --production  Run in production mode. Minify and bundle CSS and JS files.  [boolean]
-----

◆Leaderboardプロジェクト実行
cd ~/meteor_labo/leaderboard
meteor -p 3000
-----
[[[[[ ~/meteor_labo/leaderboard ]]]]]

Running on: http://localhost:3000/
-----

http://localhost:3000/
-----
Leaderboard
-----

http://localhost:3001/
-----
Leaderboard
-----

http://localhost:3002/
-----
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
-----

◆Todosプロジェクト実行
cd ~/meteor_labo/todos
meteor -p 3003
-----
[[[[[ ~/meteor_labo/todos ]]]]]

Running on: http://localhost:3003/
-----

http://localhost:3003/cf17fc16-830d-40df-96e2-57ed59d2f7ce
-----
Todos
-----

http://localhost:3004/cf17fc16-830d-40df-96e2-57ed59d2f7ce
-----
Todos
-----

http://localhost:3005/
-----
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
-----

◆wordplayプロジェクト実行
cd ~/meteor_labo/wordplay
meteor -p 3006
-----
[[[[[ ~/meteor_labo/wordplay ]]]]]

Running on: http://localhost:3006/
-----

http://localhost:3006/
-----
Word play!
-----

http://localhost:3007/
-----
Word play!
-----

http://localhost:3008/
-----
You are trying to access MongoDB on the native driver port. For http diagnostic access, add 1000 to the port number
-----

◆デプロイ
[ Leaderboard ]
cd ~/meteor_labo/leaderboard
meteor deploy leaderboard-20120422.meteor.com
-----
Deploying to leaderboard-20120422.meteor.com.  Bundling ... uploading ... done.
Now serving at leaderboard-20120422.meteor.com
-----

[ Todos ]
cd ~/meteor_labo/todos
meteor deploy todos-20120422.meteor.com
-----
Deploying to todos-20120422.meteor.com.  Bundling ... uploading ... done.
Now serving at todos-20120422.meteor.com
-----

[ Wordplay ]
cd ~/meteor_labo/wordplay
meteor deploy wordplay-20120422.meteor.com
-----
Deploying to wordplay-20120422.meteor.com.  Bundling ... uploading ... done.
Now serving at wordplay-20120422.meteor.com
-----

◆アクセス
[ Leaderboard ]
http://leaderboard-20120422.meteor.com/

[ Todos ]
http://todos-20120422.meteor.com/

[ Wordplay ]
http://wordplay-20120422.meteor.com/

参考ページ:
 - [ http://www.meteor.com/examples/leaderboard ]
 - [ https://github.com/meteor/meteor ]

----------

◆インストール
curl install.meteor.com | sh
-----
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5238    0  5238    0     0   8010      0 --:--:-- --:--:-- --:--:-- 11850
Installing Meteor to /usr/local/meteor
... downloading
######################################################################## 100.0%

Meteor installed! To get started fast:

  $ meteor create ~/my_cool_app
  $ cd ~/my_cool_app
  $ meteor

Or see the docs at:

  docs.meteor.com
-----

◆Meteorバージョン確認
meteor --version
-----
Meteor version 0.3.3 (bec7f52312)
-----

◆Meteorヘルプ確認
meteor --help
-----
Usage: meteor [--version] [--help] <command> [<args>]

With no arguments, 'meteor' runs the project in the current
directory in local development mode. You can run it from the root
directory of the project or from any subdirectory.

Use 'meteor create <name>' to create a new Meteor project.

Commands:
   run        [default] Run this project in local development mode
   create     Create a new project
   update     Upgrade to the latest version of Meteor
   add        Add a package to this project
   remove     Remove a package from this project
   list       List available packages
   bundle     Pack this project up into a tarball
   mongo      Connect to the Mongo database for the specified site
   deploy     Deploy this project to Meteor
   logs       Show logs for specified site
   reset      Reset the project state. Erases the local database.

See 'meteor help <command>' for details on a command.
-----

◆作業ディレクトリ移動
cd ~/meteor_labo

◆プロジェクト作成
meteor create sample-20120422
-----
sample-20120422: created.

To run your new app:
   cd sample-20120422
   meteor
-----

◆プロジェクトディレクトリ移動
cd sample-20120422

◆作成ファイル確認
ls
-----
sample-20120422.css sample-20120422.html sample-20120422.js
-----

[ sample-20120422.css ]
-----
/* CSS declarations go here */
-----

[ sample-20120422.html ]
-----
<head>
  <title>sample-20120422</title>
</head>

<body>
  {{> hello}}
</body>

<template name="hello">
  <div class="hello">
    <h1>Hello World!</h1>
    {{greeting}}
    <input type="button" value="Click" />
  </div>
</template>
-----

[ sample-20120422.js ]
-----
if (Meteor.is_client) {
  Template.hello.greeting = function () {
    return "Welcome to sample-20120422.";
  };

  Template.hello.events = {
    'click input' : function () {
      // template data, if any, is available in 'this'
      if (typeof console !== 'undefined')
        console.log("You pressed the button");
    }
  };
}

if (Meteor.is_server) {
  Meteor.startup(function () {
    // code to run on server at startup
  });
}
-----

◆アプリ実行
meteor

◆ローカルアクセス
http://localhost:3000/

◆デプロイ
meteor deploy sample-20120422.meteor.com
-----
Deploying to sample-20120422.meteor.com.  Bundling ... uploading ... done.
Now serving at sample-20120422.meteor.com
-----

◆デプロイサイトアクセス
http://sample-20120422.meteor.com/

RVM更新
rvm get stable
-----
Installed RVM stable version:

rvm 1.12.4 () by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

RVM reloaded!
-----

◆Ruby1.9.3-p194リスト表示確認
rvm list known
-----
# MRI Rubies
[ruby-]1.9.3-p125
[ruby-]1.9.3[-p194]
[ruby-]1.9.3-head
-----

◆Ruby1.9.3-p194インストール
rvm install 1.9.3
-----
Fetching yaml-0.1.4.tar.gz to /Users/shu/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/shu/.rvm/src
Configuring yaml in /Users/shu/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/shu/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/shu/.rvm/usr
Installing Ruby from source to: /Users/shu/.rvm/rubies/ruby-1.9.3-p194, this may take a while depending on your cpu(s)...

ruby-1.9.3-p194 - #fetching 
ruby-1.9.3-p194 - #downloading ruby-1.9.3-p194, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9610k  100 9610k    0     0  1704k      0  0:00:05  0:00:05 --:--:-- 1781k
ruby-1.9.3-p194 - #extracting ruby-1.9.3-p194 to /Users/shu/.rvm/src/ruby-1.9.3-p194
ruby-1.9.3-p194 - #extracted to /Users/shu/.rvm/src/ruby-1.9.3-p194
ruby-1.9.3-p194 - #configuring 
ruby-1.9.3-p194 - #compiling 
ruby-1.9.3-p194 - #installing 
Retrieving rubygems-1.8.23
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  371k  100  371k    0     0   860k      0 --:--:-- --:--:-- --:--:-- 4882k
Extracting rubygems-1.8.23 ...
Removing old Rubygems files...
Installing rubygems-1.8.23 for ruby-1.9.3-p194 ...
Installation of rubygems completed successfully.
ruby-1.9.3-p194 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.3-p194 - #importing default gemsets (/Users/shu/.rvm/gemsets/)
Install of ruby-1.9.3-p194 - #complete 
-----

◆Ruby1.9.3-p194インストール確認
rvm list
-----
rvm rubies

   ruby-1.8.7-p352 [ i686 ]
   ruby-1.9.2-p290 [ x86_64 ]
=* ruby-1.9.3-p125 [ x86_64 ]
   ruby-1.9.3-p194 [ x86_64 ]
-----

◆使用Rubyデフォルト設定
rvm --default use 1.9.3
-----
Using /Users/shu/.rvm/gems/ruby-1.9.3-p194
-----

◆使用Ruby設定確認
rvm list
-----
rvm rubies

   ruby-1.8.7-p352 [ i686 ]
   ruby-1.9.2-p290 [ x86_64 ]
   ruby-1.9.3-p125 [ x86_64 ]
=* ruby-1.9.3-p194 [ x86_64 ]
-----

※Gemsetが新しくなるため、rails sをする前に再度bundle installを実行
※Herokuを使用する場合はHerokuクライアントも入れ直す「gem install heroku」

◆ruby -v
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.8.0]

◆rails -v
Rails 3.2.3

----------

◆作業ディレクトリ移動
cd ~/labo

◆nokogiriインストール(未インストールの場合のみ)
gem install nokogiri

◆cat ~/.railsrc
--skip-bundle
--skip-test-unit

◆Railsアプリ作成
rails _3.2.3_ new luti
cd luti

◆Gemfile編集
-----
# ----- Add ----- #
# For Heroku
group :production do
  gem 'pg'
  gem 'thin'
end

# Utility
gem 'kaminari'
gem 'active_decorator'
gem 'html5_validators'

# OmniAuth
gem 'omniauth-twitter'
# ----- / Add ----- #
-----

◆Gemインストール(Production環境用以外)
bundle install --without production

◆config/initializers/omniauth.rb(新規作成)
-----
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :developer unless Rails.env.production?
  provider :twitter, ENV['TWITTER_KEY'], ENV['TWITTER_SECRET']
end
-----

◆ローカル設定ファイル作成
config/initializers/local_setting.rb(新規作成)
-----
ENV['TWITTER_KEY'] = "YOUR_CONSUMER_KEY"
ENV['TWITTER_SECRET'] = "YOUR_CONSUMER_SECRET"
-----

◆config/routes.rb
-----
  # The priority is based upon order of creation:
  # first created -> highest priority.
  match "/auth/:provider/callback" => "sessions#callback"
  match "/auth/failure" => "sessions#failure"
  match "/logout" => "sessions#destroy", :as => :logout

 〜

  # root :to => 'welcome#index'
  root :to => 'top#index'

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  match ':controller(/:action(/:id(.:format)))'
-----

◆config/environments/development.rb
-----
  # Expands the lines which load the assets
#  config.assets.debug = true
  config.assets.debug = false
-----

◆Userモデル作成
rails g model user

◆マイグレーションファイル編集
db/migrate/〜_create_users.rb
-----
class CreateUsers < ActiveRecord::Migration
  def change
    create_table :users do |t|
      # ----- 追加 ----- #
      t.string :provider
      t.string :uid
      t.string :name
      t.string :screen_name
      t.string :image
      # ----- /追加 ----- #

      t.timestamps
    end
  end
end
-----

◆Userモデルファイル編集
app/models/user.rb
-----
# coding: utf-8
class User < ActiveRecord::Base
  # attr_accessible :title, :body

  private

  #---------------------------#
  # self.create_with_omniauth #
  #---------------------------#
  def self.create_with_omniauth( auth )
    user = User.new
    user[:provider] = auth["provider"]
    user[:uid] = auth["uid"]

    unless auth["info"].blank?
      user[:name] = auth["info"]["name"]
      user[:screen_name] = auth["info"]["nickname"]
      user[:image] = auth["info"]["image"]
    end

    user.save

    return user
  end

end
-----

◆Sessionsコントローラ作成
app/controllers/sessions_controller.rb(新規作成)
-----
# coding: utf-8
class SessionsController < ApplicationController

  #----------#
  # callback #
  #----------#
  def callback
    auth = request.env["omniauth.auth"]
    user = User.where( provider: auth["provider"], uid: auth["uid"] ).first || User.create_with_omniauth( auth )
    session[:user_id] = user.id

    redirect_to :root, notice: "ログインしました。"
  end

  #---------#
  # destroy #
  #---------#
  def destroy
    session[:user_id] = nil

    redirect_to :root, notice: "ログアウトしました。"
  end

  #---------#
  # failure #
  #---------#
  def failure
    render text: "<span style='color: red;'>Auth Failure</span>"
  end

end
-----

◆applicationコントローラ編集
app/controllers/application_controller.rb
-----
# coding: utf-8
class ApplicationController < ActionController::Base

  protect_from_forgery

  # セッション有効期限延長
  before_filter :reset_session_expires

  private

  #-----------------------#
  # reset_session_expires #
  #-----------------------#
  # セッション期限延長
  def reset_session_expires
    request.session_options[:expire_after] = 2.weeks
  end

  #--------------#
  # current_user #
  #--------------#
  def current_user
    @current_user ||= User.where( id: session[:user_id] ).first
  end

  helper_method :current_user

end
-----

◆コントローラ/ビュー作成
rails g controller top index

◆Topコントローラ編集
-----
# coding: utf-8
class TopController < ApplicationController

  #-------#
  # index #
  #-------#
  def index
  end

end
-----

◆public/index.htmlリネーム
「index.html」=>「_____index.html」

◆applicationレイアウト編集
app/views/layouts/application.html.erb
-----
<body>

<%# ----- 追加 ----- %>
<% if current_user %>
  <%# ログイン済み %>
  <%= current_user.name %> : <%= link_to "Logout" , logout_path %>
<% else %>
  <%# 未ログイン %>
  <%= link_to "Login", "/auth/#{DEFAULT_PROVIDER}" %>
<% end %>

<%# 通知/エラーメッセージ %>
<%= simple_format( flash[:notice], style: "color: green;" ) unless flash[:notice].blank? %>
<%= simple_format( flash[:alert], style: "color: red;" ) unless flash[:alert].blank? %>
<%# ----- /追加 ----- %>

<%= yield %>
-----

◆定数定義ファイル作成
config/initializers/constants.rb(新規作成)
-----
# coding: utf-8

# ---------- 環境別定義 ---------- #
if Rails.env.production?
  #----------------#
  # Production環境 #
  #----------------#
  DEFAULT_PROVIDER = "twitter"
else
  #--------------------#
  # Production環境以外 #
  #--------------------#
  DEFAULT_PROVIDER = "developer"
#  DEFAULT_PROVIDER = "twitter"
end
-----

◆マイグレーション実行
rake db:migrate

◆ローカルサーバ起動
rails s

◆ページアクセス
http://0.0.0.0:3000/

◆Gitリポジトリ作成
git init
-----
Initialized empty Git repository in /Users/shu/labo/luti/.git/
-----

◆アセットプリコンパイル
rake assets:precompile RAILS_ENV=production

◆Gitコミット
git add . && git commit -m "first commit"

◆Gitステータス確認
git status
-----
# On branch master
nothing to commit (working directory clean)
-----

◆Herokuアプリ作成
heroku create luti
-----
Creating luti... done, stack is bamboo-mri-1.9.2
http://luti.heroku.com/ | git@heroku.com:luti.git
Git remote heroku added
-----

◆Herokuリモートリポジトリ
git remote -v
-----
heroku git@heroku.com:luti.git (fetch)
heroku git@heroku.com:luti.git (push)
-----

◆Herokuプッシュ
git push heroku master

◆Herokuマイグレーション
heroku rake db:migrate

◆Twitterアプリ作成
https://dev.twitter.com/apps/new
-----
Name: *
[ LuTi ]

Description: *
[ Lightning Talk Support Tool. ]

WebSite: *
[ https://luti.heroku.com/ ]

Callback URL:
[ https://luti.heroku.com/ ]
-----
※必須マークが無いが「Callback URL:」も登録しないと動かない

◆Heroku環境変数設定
heroku config:add TWITTER_KEY=(Consumer key)
heroku config:add TWITTER_SECRET=(Consumer secret)

◆Heroku設定確認
heroku config list
-----
TWITTER_KEY         => (Consumer key)
TWITTER_SECRET   => (Consumer secret)
-----

◆Herokuオープン
heroku open

◆GitHubリポジトリ作成
https://github.com/repositories/new
-----
Project Name
[ luti ]

Description (optional)
[ Lightning Talk Support Tool. ]

Homepage URL (optional)
[ https://luti.heroku.com/ ]
-----

◆GitHubデプロイ
git remote add origin git@github.com:shu0115/luti.git
git push -u origin master

◆GitHubリポジトリページ
https://github.com/shu0115/luti

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

[更新フロー]

◆プリコンパイル
rake assets:precompile RAILS_ENV=production

◆ローカルリポジトリコミット
git add . && git commit -m "update"
-----
git add . && git commit
※コミットメッセージ入力 -> :wq(保存&終了)

◆デプロイ(Heroku/GitHub)
git push heroku master
git push origin master

◆Herokuマイグレーション
heroku rake db:migrate

◆Herokuオープン
heroku open

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

◆更新用コマンド
[ SHORT ]
git add . && git commit -m "update"
git push heroku master
git push origin master

----------

[ FULL ]
rake assets:precompile RAILS_ENV=production
git add . && git commit -m "update"
git push heroku master
git push origin master
heroku rake db:migrate
heroku open

----------

[ COMMIT ]
git add . && git commit

----------

[ Gist ]
https://gist.github.com/2226448

Recent Entries