2013/07/20
done homework of Kyoto.rb
kyotorb/2013-07-18_TDDBC at master · pinzolo/kyotorb
ステップ5は出力だけの話なのでステップ4まででいーや。(投げやり)
英語がかなり微妙、そして RSpec の describe や context の扱いも慣れていないのでブレまくり。
2013/07/17
椅子代わりにバランスボールを導入してみた
近場のオフィス用品中古店を見て回り、45kでアーロンチェアが売っていたり、16kのオカムラのFeegoもいいなと思っていた。
しかしまあ思いつきで、バランスボールによる体幹トレーニングができるなら、それでいいかなと。安いし。
ヨドバシで1kちょいなんで、失敗しても諦めつくし。高い椅子はそれから買えばいいし。
というわけで、バランスボールを椅子代わりに我が家に導入しました。
子供が出来たら安全面を考える必要があるかもしれないけど、しばらく試してみます。
願わくば、体にいい傾向が出ますように。
java -jar にて実行可能な jar ファイルを作成するための pom.xml 設定
classpathPrefix でクラスパスを通すディレクトリを指定できるのはかなり便利だと思う。
2013/07/08
github のリポジトリを remote add して push したらエラーが出た
git push したらこんなエラーが出た。
% git push origin master
To git@github.com:pinzolo/repo.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:pinzolo/repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
いつも下記の手順で github と連携していたから、特に困ったことはなかった。
- github にリポジトリを作成する
- ローカルに clone する
- 開発する
しかし今回は
- ローカルで
git initする - github リポジトリを作成
- ローカルに対して
git add origin git@github.com:pinzolo/repo.git - 冒頭のエラー
というわけだ。
github でリポジトリを作成した時に README.md を作成したから、そっちの情報がなかったわけね。
というわけで、一旦 git pull してから git push したらエラーは出なくなった。なるほど
2013/07/04
startup_redmine_plugin_development.sh
自動で行なってくれる作業は
- 専用ディレクトリの作成
- 最新のRedmineを取得
- Redmineをローカルにデプロイ
- database.ymlを作成
- gemのインストール
- トークンの作成
- マイグレーションの実行
- デフォルトデータのロード(デフォルトは日本語)
- プラグインの雛形を生成
- gitにて初回コミット
2013/06/22
Redmine プラグインのテストが実行できるまで
環境はこちら。
- Ruby 2.0.0-p195(use rbenv)
- Redmine 2.3.1
- Mac OS X 10.8.4
まずは、公式を参考に実行。
% bundle exec rake test:engines:all
rake aborted!
Don't know how to build task 'test:engines:all'
...
タスクが存在していないみたいなので、テストに関連しそうなタスクの一覧を確認。
% bundle exec rake -T | grep test
rake ci # Run the Continous Integration tests for Redmine
rake extract_fixtures # Create YAML test fixtures from data in an existing database.
rake redmine:email:test[login] # Send a test email to the user with the provided login name
rake redmine:plugins:test # Runs the plugins tests.
rake redmine:plugins:test:functionals # Run tests for {:functionals=>"db:test:prepare"}
rake redmine:plugins:test:integration # Run tests for {:integration=>"db:test:prepare"}
rake redmine:plugins:test:units # Run tests for {:units=>"db:test:prepare"}
rake test # Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)
rake test:coverage # Measures test coverage
rake test:rdm_routing # Run tests for rdm_routing / Run the routing tests
rake test:recent # Run tests for {:recent=>"test:prepare"} / Test recent changes
rake test:scm # Run unit and functional scm tests
rake test:scm:functionals # Run tests for {:functionals=>"db:test:prepare"} / Run the scm functional tests
rake test:scm:setup:all # Creates all test repositories
rake test:scm:setup:bazaar # Creates a test bazaar repository
rake test:scm:setup:create_dir # Creates directory for test repositories
rake test:scm:setup:cvs # Creates a test cvs repository
rake test:scm:setup:darcs # Creates a test darcs repository
rake test:scm:setup:filesystem # Creates a test filesystem repository
rake test:scm:setup:git # Creates a test git repository
rake test:scm:setup:mercurial # Creates a test mercurial repository
rake test:scm:setup:subversion # Creates a test subversion repository
rake test:scm:units # Run tests for {:units=>"db:test:prepare"} / Run the scm unit tests
rake test:scm:update # Updates installed test repositories
rake test:single # Run tests for {:single=>"test:prepare"}
rake test:ui # Run tests for {:ui=>"db:test:prepare"} / Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)
rake test:uncommitted # Run tests for {:uncommitted=>"test:prepare"} / Test changes since last checkin (only Subversion and Git)
どうやら、rake redmine:plugins:test{functionals,integration,units}あたりでテストが出来そう。
% bundle exec rake redmine:plugins:test
rake aborted!
undefined method `[]' for nil:NilClass
…
Tasks: TOP => db:test:load => db:test:purge
RAILS_ENV=test を忘れていた。
% bundle exec rake redmine:plugins:test RAILS_ENV=test
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
rake aborted!
database configuration does not specify adapter
…
Tasks: TOP => redmine:plugins:test:units => db:test:prepare => db:abort_if_pending_migrations => environment
テスト用のデータベースの設定がしてない。 config/database.yml を編集して・・・
# config/databse.yml
development:
adapter: sqlite3
database: db/redmine.db
# ここから追加
test:
adapter: sqlite3
database: db/redmine_test.db
再度実行。
% bundle exec rake redmine:plugins:test RAILS_ENV=test
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
You have 221 pending migrations:
1 Setup
2 IssueMove
3 IssueAddNote
4 ExportPdf
…
Run `rake db:migrate` to update your database then try again.
マイグレーションができていないのね。
% bundle exec rake db:migrate RAILS_ENV=test
== Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
-> 0.0039s
-- create_table("auth_sources", {:force=>true})
-> 0.0011s
-- create_table("custom_fields", {:force=>true})
-> 0.0008s
-- create_table("custom_fields_projects", {:id=>false, :force=>true})
-> 0.0004s
-- create_table("custom_fields_trackers", {:id=>false, :force=>true})
-> 0.0413s
-- create_table("custom_values", {:force=>true})
-> 0.0011s
-- create_table("documents", {:force=>true})
-> 0.0008s
-- add_index("documents", ["project_id"], {:name=>"documents_project_id"})
-> 0.0003s
-- create_table("enumerations", {:force=>true})
-> 0.0005s
-- create_table("issue_categories", {:force=>true})
-> 0.0005s
-- add_index("issue_categories", ["project_id"], {:name=>"issue_categories_project_id"})
-> 0.0002s
-- create_table("issue_histories", {:force=>true})
-> 0.0007s
-- add_index("issue_histories", ["issue_id"], {:name=>"issue_histories_issue_id"})
-> 0.0002s
-- create_table("issue_statuses", {:force=>true})
-> 0.0006s
-- create_table("issues", {:force=>true})
-> 0.0011s
-- add_index("issues", ["project_id"], {:name=>"issues_project_id"})
-> 0.0002s
-- create_table("members", {:force=>true})
-> 0.0006s
-- create_table("news", {:force=>true})
-> 0.0007s
-- add_index("news", ["project_id"], {:name=>"news_project_id"})
-> 0.0002s
-- create_table("permissions", {:force=>true})
-> 0.0007s
-- create_table("permissions_roles", {:id=>false, :force=>true})
-> 0.0004s
-- add_index("permissions_roles", ["role_id"], {:name=>"permissions_roles_role_id"})
-> 0.0002s
-- create_table("projects", {:force=>true})
-> 0.0008s
-- create_table("roles", {:force=>true})
-> 0.0004s
-- create_table("tokens", {:force=>true})
-> 0.0006s
-- create_table("trackers", {:force=>true})
-> 0.0005s
-- create_table("users", {:force=>true})
-> 0.0009s
-- create_table("versions", {:force=>true})
-> 0.0007s
-- add_index("versions", ["project_id"], {:name=>"versions_project_id"})
-> 0.0002s
-- create_table("workflows", {:force=>true})
-> 0.0006s
== Setup: migrated (0.1067s) =================================================
…
== RemoveIssuesDefaultFkValues: migrating ====================================
-- change_column_default(:issues, :tracker_id, nil)
-> 0.0257s
-- change_column_default(:issues, :project_id, nil)
-> 0.0737s
-- change_column_default(:issues, :status_id, nil)
-> 0.0252s
-- change_column_default(:issues, :assigned_to_id, nil)
-> 0.0236s
-- change_column_default(:issues, :priority_id, nil)
-> 0.0245s
-- change_column_default(:issues, :author_id, nil)
-> 0.0251s
== RemoveIssuesDefaultFkValues: migrated (0.1981s) ===========================
% bundle exec rake redmine:load_default_data RAILS_ENV=test
Select language: ar, az, bg, bs, ca, cs, da, de, el, en, en-GB, es, et, eu, fa, fi, fr, gl, he, hr, hu, id, it, ja, ko, lt, lv, mk, mn, nl, no, pl, pt, pt-BR, ro, ru, sk, sl, sq, sr, sr-YU, sv, th, tr, uk, vi, zh, zh-TW [en] ja
====================================
Default configuration data loaded.
もう一度実行。
% bundle exec rake redmine:plugins:test RAILS_ENV=test
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
/Users/pinzolo/.rbenv/versions/2.0.0-p195/bin/ruby -I"lib:test" -I"/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "plugins/*/test/unit/**/*_test.rb"
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/lib/SVG/Graph/Graph.rb:3: warning: class variable access from toplevel
Run options:
# Running tests:
Finished tests in 0.067877s, 132.5928 tests/s, 132.5928 assertions/s.
9 tests, 9 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
/Users/pinzolo/.rbenv/versions/2.0.0-p195/bin/ruby -I"lib:test" -I"/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "plugins/*/test/functional/**/*_test.rb"
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/lib/SVG/Graph/Graph.rb:3: warning: class variable access from toplevel
Run options:
# Running tests:
Finished tests in 0.062297s, 16.0521 tests/s, 16.0521 assertions/s.
1 tests, 1 assertions, 0 failures, 0 errors, 0 skips
ruby -v: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
/Users/pinzolo/.rbenv/versions/2.0.0-p195/bin/ruby -I"lib:test" -I"/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "plugins/*/test/integration/**/*_test.rb"
成功したみたいなので、失敗させてみる。
# sample_model_test.rb
require File.expand_path('../../test_helper', __FILE__)
class SampleModelTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
#assert true
assert false
end
end
% bundle exec rake redmine:plugins:test:units RAILS_ENV=test
berk redmine:plugins:test:units RAILS_ENV=test
(in /Users/pinzolo/projects/sample_plugin/redmine-2.3.1)
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
/Users/pinzolo/.rbenv/versions/2.0.0-p195/bin/ruby -I"lib:test" -I"/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "plugins/*/test/unit/**/*_test.rb"
*** Mocha deprecation warning: Change `require 'mocha'` to `require 'mocha/setup'`.
/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/lib/SVG/Graph/Graph.rb:3: warning: class variable access from toplevel
Run options:
# Running tests:
[1/9] SampleModelTest#test_truth = 0.00 s
1) Failure:
test_truth(SampleModelTest) [/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/plugins/sample_plugin/test/unit/sample_model_test.rb:8]:
Failed assertion, no message given.
Finished tests in 0.069086s, 130.2724 tests/s, 130.2724 assertions/s.
9 tests, 9 assertions, 1 failures, 0 errors, 0 skips
ruby -v: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
rake aborted!
Command failed with status (1): [ruby -I"lib:test" -I"/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib" "/Users/pinzolo/projects/sample_plugin/redmine-2.3.1/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/rake_test_loader.rb" "plugins/*/test/unit/**/*_test.rb" ]
…
Tasks: TOP => redmine:plugins:test:units
予定通り失敗した。
あとはテストを書いて実行していけばよさそうだ
Ruby2.0.0をインストール
Ruby 2.0 がリリースされてしばらくしたのでそろそろ入れることにした。
% rbenv install 2.0.0-p195
Downloading ruby-2.0.0-p195.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
Installing ruby-2.0.0-p195...
BUILD FAILED
Inspect or clean up the working tree at /var/folders/1j/hw72brh57jv94vdl9567fr140000gn/T/ruby-build.20130621233411.34289
Results logged to /var/folders/1j/hw72brh57jv94vdl9567fr140000gn/T/ruby-build.20130621233411.34289.log
Last 10 log lines:
make[2]: *** [readline.o] Error 1
make[1]: *** [ext/readline/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling ../.././ext/psych/yaml/reader.c
compiling ../.././ext/psych/yaml/scanner.c
compiling ../.././ext/psych/yaml/writer.c
installing default psych libraries
linking shared-object psych.bundle
ld: warning: directory not found for option '-L/Users/pinzolo/.rbenv/versions/2.0.0-p195/lib'
make: *** [build-ext] Error 2
なんか失敗した。
こちらを参考に再度挑戦。
readline は入っていたので openssl を入れて、`RUBY_CONFIGURE_OPTS`を指定してインストール。
% brew update
% brew install openssl
% brew link openssl --force
% brew install curl-ca-bundle
% brew list curl-ca-bundle
/usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt
% cp /usr/local/Cellar/curl-ca-bundle/1.87/share/ca-bundle.crt /usr/local/etc/openssl/cert.pem
% RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline` --enable-shared" rbenv install 2.0.0-p195
Downloading ruby-2.0.0-p195.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz
Installing ruby-2.0.0-p195...
Installed ruby-2.0.0-p195 to /Users/pinzolo/.rbenv/versions/2.0.0-p195
いけたみたいなので確認。
% ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.4.0]
bundler は入れておかないと。
% gem install bundler
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
1 gem installed
バッチリ!お疲れ様でした。
2013/06/20
Redmine から Google Apps のメールを送信する
一人しか使ってないプライベートの Redmine ですが、メール設定しておくのを忘れていたので、メール設定を行った。
GMail の設定は過去に行ったが Google Apps の設定は初めてなのでメモ。
ちなみに環境は Redmine 2.3.1 on Ruby 1.9.3。
とはいっても、Google Apps のメールとはいってもほぼ GMail と同じ。
$REDMINE_HOME/config/configuration.ymlに下記の設定をするだけ。
変更したのは domain を Google Apps で使用しているドメインに設定した。それだけ。
production:
email_delivery:
delivery_method: :smtp
smtp_settings:
enable_starttls_auto: true
address: "smtp.gmail.com"
port: 587
domain: "mkt-sys.jp"
authentication: :login
user_name: "hogefuga@mkt-sys.jp"
password: "foobarbaz"
2013/06/08
さくらVPSのRedmineを2.0.0から2.3.1にアップデート
やったことはtail -f pinzo.log: Redmine を 1.4.1 から 2.0.0 にアップデートしたの焼き直し。
あと、「Plugin assetsディレクトリに書き込み可能」にビックリマークが出ていたので、解消しておいた。
$REDMINE_HOME/public/plugin_assetsディレクトリを作成して、www-dataにchownしただけ。
2013/06/06
Kyoto.rbに行ってきた
登録はしたものの、引越しとかなんとかで一度も行っていなかったKyoto.rbに初参加してきた。
とはいえ、途中から参加のため自己紹介して軽く発言した程度。
ていうかスーツが俺だけ!?っていうのが驚いた。
引越しとか関西での仕事探しとかですっかりプライベートでの開発熱が下がっていたけど、久しぶりに技術者の集いに参加できたおかげで少しテンションが上がった。
やっぱりモノ作らんといかんよな。
次回の Kyoto.rb は6/20。また参加します。