Generator API が使いにくい問題の解決策として、クラスベースの実装方法を考える。 なお、クラスベースでの利用は Generator の当初の設計思想に含まれているが、現状ではいろいろ足りていない。
注意: 下記コードは、実装の提案のためのものであり、実際に動作するものではない。
| $ git remote set-url origin [email protected]:foo/bar.git |
| // Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
| // jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
| // author: Pawel Kozlowski | |
| var myApp = angular.module('myApp', []); | |
| //service style, probably the simplest one | |
| myApp.service('helloWorldFromService', function() { | |
| this.sayHello = function() { | |
| return "Hello, World!" |
| Result: Avg. 89 seconds | |
| $ ruby test.rb | |
| user system total real | |
| 81.500000 0.320000 81.820000 ( 81.891870) | |
| $ ruby test.rb | |
| user system total real | |
| 93.640000 0.540000 94.180000 ( 95.164552) | |
| $ ruby test.rb | |
| user system total real |
| class FooController < ApplicationController | |
| def export | |
| csv_data = CSV.generate do |csv| | |
| # (CSV データを作る処理) | |
| end | |
| # exported という名前で cookie を作成 | |
| cookies[:exported] = { value: 'yes', expires: 1.minutes.from_now } | |
| send_data csv_data, disposition: 'attachment', |
| $:.unshift File.expand_path(File.dirname(__FILE__) + '/lib') # << 必ず先頭に追加 | |
| # Load DSL and Setup Up Stages | |
| require 'capistrano/setup' | |
| # Includes default deployment tasks | |
| require 'capistrano/deploy' | |
| # : | |
| # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
| Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } |
| require 'railsless-deploy' | |
| Dir.chdir 'output' | |
| set :application, 'hoge.com' | |
| set :repository, '.' | |
| set :user, 'username' | |
| set :use_sudo, false |
svn status | grep "^\!" | awk '{print $2}' | xargs svn delete
svn status | grep "^\?" | awk '{print $2}' | xargs svn add