boof / categorizable

Simply categorize (tag) your ActiveRecord models.

This URL has Read+Write access

categorizable / install.rb
100644 34 lines (25 sloc) 0.778 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require 'fileutils'
 
module Install
 
  TIME = Time.now
  ROOT = File.dirname __FILE__
  rails_root = File.join ROOT, %w[ .. .. .. ]
  RAILS_ROOT = File.expand_path rails_root
 
  def copy(basename, target)
    source = File.join ROOT, 'install', basename
    target = File.join RAILS_ROOT, target
 
    begin
      FileUtils.mkdir_p target unless File.directory? target
      FileUtils.cp source, target, :verbose => true
    rescue
      STDERR.puts $!
      STDERR.puts "=> failed!"
    end
  end
  module_function :copy
 
end
 
STDERR.puts 'Categorizable:'
STDERR.puts
 
Install.copy 'category.rb', %w[app models categorizable]
Install.copy 'categorization.rb', %w[app models categorizable]
 
STDERR.puts
STDERR.puts 'Run script/generate categorization to create the migration.'