sou's blog

落ち着いた華やかさがあり、上品に明るく陽気なさまを表す。

UMLの勉強

UMLモデリングレッスン 21の基本パターンでわかる要求モデルの作り方

UMLモデリングレッスン 21の基本パターンでわかる要求モデルの作り方

設計においてUML覚えておくと便利だなぁと最近思い出して、
色々調べてたけどやっぱり実践しながらじゃないと覚えないと思っていたところ
実際の事例を元に学べそうな良書にたどり着いた。

今日は休日なので一気に読み込んでみよう。

Mac Book Airよきかな

やりました。
MacBookAirゲット。

1年前くらいの発売時完全に欲しかったのを我慢したかいがありました。
というのもスペック後一歩。というところでした。

MacBookAirの場合は使用用途が外出したときとか
どの部屋でもできるとかそういったこれまで時間がとれなかったところを
埋める役割として期待していたので、メインという考えはまったくありませんでした。

あと、金銭的な問題で上記のような目的のマシンに10万円以上は到底払えないと考えていました。

なので、1年前のスペックでは最下位モデルが今一歩足りなかった。
(拡張すれば確かにクリアできたかもしれないけど、金銭的にアウト)

今回これらの今一歩感が完全に払拭されました。
ばっちり最下位モデルを購入して合間に使ってます。

いやぁ楽しい。

まず、Lionにもっとも適したマシンだなぁとつくづく思う。
OSとの一体感がユーザエクスペリエンス非常に高いです。

itunesiPhotoは自宅のiMacと共有で見るとかしてストレージ圧迫しなければ得に入れるものがないから、逆に仮想OS入れたりして無駄遣いしています。

とりあえず、言えるのはいいってこと。

Windows環境でのRedmine構築手順

ここの記事を参考にさせて頂き、バージョンを指定しながら構築する手順

構築する環境

Ruby

Rails

  • rails2.3.11

Redmine

  • redmine1.2.0

DB

  • sqlite3

RubyGems

Rubyのインストール

ここから1.8.7系をダウンロードし、インストールする。
(途中で、環境変数にパスを通すか、拡張子を紐付けるかといったチェックボックスが出てくるのでどちらもチェックしておく)
コマンドプロンプトで正しくインストールされていることを確認。

$ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

$gem -v
1.5.2

Railsのインストール

$gem install rails -v 2.3.11
Fetching: rake-0.9.2.gem (100%)
Fetching: activesupport-2.3.11.gem (100%)
Fetching: activerecord-2.3.11.gem (100%)
Fetching: rack-1.1.2.gem (100%)
Fetching: actionpack-2.3.11.gem (100%)
Fetching: actionmailer-2.3.11.gem (100%)
Fetching: activeresource-2.3.11.gem (100%)
Fetching: rails-2.3.11.gem (100%)
Successfully installed rake-0.9.2
Successfully installed activesupport-2.3.11
Successfully installed activerecord-2.3.11
Successfully installed rack-1.1.2
Successfully installed actionpack-2.3.11
Successfully installed actionmailer-2.3.11
Successfully installed activeresource-2.3.11
Successfully installed rails-2.3.11
8 gems installed
Installing ri documentation for rake-0.9.2...
Installing ri documentation for activesupport-2.3.11...
Installing ri documentation for activerecord-2.3.11...
Installing ri documentation for rack-1.1.2...
Installing ri documentation for actionpack-2.3.11...
Installing ri documentation for actionmailer-2.3.11...
Installing ri documentation for activeresource-2.3.11...
Installing ri documentation for rails-2.3.11...
Installing RDoc documentation for rake-0.9.2...
Installing RDoc documentation for activesupport-2.3.11...
Installing RDoc documentation for activerecord-2.3.11...
Installing RDoc documentation for rack-1.1.2...
Installing RDoc documentation for actionpack-2.3.11...
Installing RDoc documentation for actionmailer-2.3.11...
Installing RDoc documentation for activeresource-2.3.11...
Installing RDoc documentation for rails-2.3.11...

$rails -v
Rails 2.3.11

rakeのダウングレード

$gem uninstall rake
Remove executables:
        rake

in addition to the gem? [Yn]  y
Removing rake

You have requested to uninstall the gem:
        rake-0.9.2
rails-2.3.11 depends on [rake (>= 0.8.3)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  y
Successfully uninstalled rake-0.9.2

$gem install rake -v 0.8.7
Fetching: rake-0.8.7.gem (100%)
Successfully installed rake-0.8.7
1 gem installed
Installing ri documentation for rake-0.8.7...
Installing RDoc documentation for rake-0.8.7...

DevKitのインストール

ここから
DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe をRubyのディレクトリにdevkitとかのディレクトリ作ってそこにでも展開しておく。
環境変数に(例)C:\Ruby\devkit\binのPATHを通しておく。

RedClothのインストール

$gem install RedCloth
Fetching: RedCloth-4.2.7-x86-mingw32.gem (100%)
Successfully installed RedCloth-4.2.7-x86-mingw32
1 gem installed
Installing ri documentation for RedCloth-4.2.7-x86-mingw32...
Installing RDoc documentation for RedCloth-4.2.7-x86-mingw32...

sqlite3-rubyのインストール

$gem install sqlite3-ruby
Fetching: sqlite3-1.3.3-x86-mingw32.gem (100%)

=============================================================================

  You've installed the binary version of sqlite3.
  It was built using SQLite3 version 3.7.3.
  It's recommended to use the exact same version to avoid potential issues.

  At the time of building this gem, the necessary DLL files where available
  in the following download:

  http://www.sqlite.org/sqlitedll-3_7_3.zip

  You can put the sqlite3.dll available in this package in your Ruby bin
  directory, for example C:\Ruby\bin

=============================================================================

Fetching: sqlite3-ruby-1.3.3.gem (100%)

#######################################################

Hello! The sqlite3-ruby gem has changed it's name to just sqlite3.  Rather than
installing `sqlite3-ruby`, you should install `sqlite3`.  Please update your
dependencies accordingly.

Thanks from the Ruby sqlite3 team!

<3 <3 <3 <3

#######################################################

Successfully installed sqlite3-1.3.3-x86-mingw32
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.3-x86-mingw32...

No definition for libversion

Enclosing class/module 'mSqlite3' for class Statement not known
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.3-x86-mingw32...

No definition for libversion

Enclosing class/module 'mSqlite3' for class Statement not known
Installing RDoc documentation for sqlite3-ruby-1.3.3...

mongrel_serviceのインストール

$gem install mongrel_service
Fetching: gem_plugin-0.2.3.gem (100%)
Fetching: cgi_multipart_eof_fix-2.5.0.gem (100%)
Fetching: mongrel-1.1.5-x86-mingw32.gem (100%)
Fetching: mongrel_service-0.4.0.gem (100%)
Successfully installed gem_plugin-0.2.3
Successfully installed cgi_multipart_eof_fix-2.5.0
Successfully installed mongrel-1.1.5-x86-mingw32
Successfully installed mongrel_service-0.4.0
4 gems installed
Installing ri documentation for gem_plugin-0.2.3...
Installing ri documentation for cgi_multipart_eof_fix-2.5.0...
Installing ri documentation for mongrel-1.1.5-x86-mingw32...
Installing ri documentation for mongrel_service-0.4.0...
Installing RDoc documentation for gem_plugin-0.2.3...
Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0...
Installing RDoc documentation for mongrel-1.1.5-x86-mingw32...
Installing RDoc documentation for mongrel_service-0.4.0...

i18nのインストール

$gem install i18n -v 0.4.2
Fetching: i18n-0.4.2.gem (100%)
Successfully installed i18n-0.4.2
1 gem installed
Installing ri documentation for i18n-0.4.2...
Installing RDoc documentation for i18n-0.4.2...

sqlite3のダウンロードと配置

  1. ここから「sqlite-shell-win32-x86-3070701.zip」と「sqlite-dll-win32-x86-3070701.zip」をダウンロード
  2. 解凍してできた「sqlite3.exe」、「sqlite3.dll」、「sqlite3.def」をC:\Windowsディレクトリ配下(PATHが通っているところ)に配置する。

Redmineのダウンロードと配置と設定

  1. ここから「redmine-1.2.0.zip」をダウンロード
  2. 解凍してできた「redmine-1.2.0」ディレクトリを「redmine」にリネーム
  3. 「C:\redmine\config\database.yml.example」を「database.yml」にリネーム
  4. database.ymlのproductionの以下の項目を修正する
production:
  adapter: sqlite3
  database: db/redmine.db

秘密鍵の生成

$cd C:\redmine
$rake config/initializers/session_store.rb
(in C:/redmine)

DBの移行

$cd C:\redmine
$rake db:migrate RAILS_ENV=production

サービスの登録

$mongrel_rails service::install -N "Redmine" -c C:\Redmine -p 80 -e production
** Copying native mongrel_service executable...
Redmine service created.
  1. サービスの一覧から「Redmine」を選択しプロパティを編集する
    • スタートアップの種類
      • 手動→自動
  2. サービスを開始する

エラーが出る場合の回避方法

adminでログインできない場合
vendor/rails/actionpack/lib/action_controller/request.rb 449行目を以下に修正

session.destroy if session and session.respond_to?(:destroy)

You are being redirected.から進まない
ここを参考にC:\redmine\config\initializers\mongrel.rbを作成

完成

あとは、ここを参考に初期設定して完成。

watirでjavascriptの実行結果として返されるhtmlを取得する

最近、html解析作業にもっぱら心を奪われています。
特にwatirとhpricotは使いやすくていいなと思ってます。

指定したurlのhtmlを取得する。(javascriptでも可)

#! ruby

require 'rubygems'
require 'watir'

class Foo

  attr_reader:html

  def initialize(url)
    browser = Watir::Browser.new
    browser.go(url)
    browser.wait # ブラウザの読込が終わるまで待つ
    @html = browser.html
  end

end

f = Foo.new(ここにurl)
f.html

iphoneから投稿なので、間違ってるかも。

gitコマンドまとめ

gitを覚えるのに二つのサイトを見ればいい。わかりやすかった。

ピックアップ(引用)

リポジトリの作成およびメンテナンスに利用するコマンド:

コマンド 説明
git init リポジトリを作成する
git clone 既存のリポジトリの複製を作る
git fsck リポジトリの正当性チェックを行う
git gc リポジトリ内の不要なオブジェクトを削除し、最適化を行う

作業ツリーやブランチを操作・管理するコマンド:

コマンド 説明
git status 変更が加えられたファイルを表示する
git diff ファイルに加えられた変更点をdiff形式で表示する
git add コミットするファイルを指定する
git commit 変更点をコミットする
git log コミットログを閲覧する
git reset 直前のコミットを取り消す
git revert 作業ツリーを指定したコミット時点の状態にまで戻す
git branch ブランチ情報の表示およびブランチの作成
git checkout ブランチの切り替え
git show-branch ブランチの作成/変更/マージ履歴を表示
git merge ローカルブランチのマージを行う
git tag コミットにタグを付ける
git stash 現在の作業ツリーの状態を一時的に保管する
git rebase ブランチの派生元(上流)を変更する

ほかのリポジトリとの連携を行うコマンド:

コマンド 説明
git pull ほかのリポジトリの変更点をローカルリポジトリにマージする
git push 公開リポジトリに自分のリポジトリの内容を送信する

オンラインIDEのCloud9がすごくいい

Rubyを使い始めて、Webアプリケーションを作りたいと思い、Ruby onRailsというフレームワークがあることを知り使ってみると実際作りたいものはこんな大きなフレームワークにも載せる必要は無いなと感じる。
そして、sinatraというもっと軽量なフレームワークにたどり着き、開発を始めるとオンラインでソース管理してどんな環境でもいじれるようになりたいと思ってgithubに手を出した。
すると、ソースがオンラインなら開発環境もオンラインにできればと思うようになったところでChromeのウェブストアが日本語化されオープンしたのをきっかけにオンラインIDEについて調べてみた。
そうして辿り着いたのがCloud9というIDE。

前置きが長くなったけど、ようはいつでもどこでもブラウザがあれば開発できる環境が整った。

githubアカウントがあれば、インスタントログインでSSHの公開鍵を登録すればgithubのリポジトリにIDE上のコンソールからpushすることまでできる。

ただ、herokuへのpushは出来るともっといいなぁなんて思ってる。