foca / integrity

Don't mind this, go to http://github.com/integrity/integrity

integrity / bin / integrity
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 1 #!/usr/bin/env ruby
2 require "rubygems"
3 require "thor"
599e7d96 » sr 2008-11-14 installer: require integrit... 4
5 require File.dirname(__FILE__) + "/../lib/integrity"
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 6
7 class WithIntegrity < Thor
8 include FileUtils
9
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 10 desc "install [PATH]",
11 "Copy template files to PATH. Next, go there and edit them."
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 12 def install(path)
13 @root = File.expand_path(path)
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 14
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 15 create_dir_structure
16 copy_template_files
17 edit_template_files
3ff2b6ea » sr 2008-11-14 fix the installer 18 create_db(root / 'config.yml')
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 19 after_setup_message
20 end
3ff2b6ea » sr 2008-11-14 fix the installer 21
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 22 desc "create_db [CONFIG]",
a5102dd0 » foca 2008-11-20 Change the description of `... 23 "Checks the `database_uri` in CONFIG and creates and bootstraps a database for integrity"
3ff2b6ea » sr 2008-11-14 fix the installer 24 def create_db(config)
9badf31c » foca 2008-11-20 Allow Integrity.new an opti... 25 Integrity.new(config)
2bd38c9b » foca 2008-11-14 Nicer database migration 26 DataMapper.auto_migrate!
3ff2b6ea » sr 2008-11-14 fix the installer 27 end
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 28
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 29 private
30 attr_reader :root
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 31
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 32 def create_dir_structure
33 mkdir_p root
34 mkdir_p root / "builds"
35 mkdir_p root / "log"
36 end
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 37
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 38 def copy_template_files
39 cp Integrity.root / "config" / "config.sample.ru", root / "config.ru"
40 cp Integrity.root / "config" / "config.sample.yml", root / "config.yml"
41 cp Integrity.root / "config" / "thin.sample.yml", root / "thin.yml"
42 end
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 43
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 44 def edit_template_files
3ff2b6ea » sr 2008-11-14 fix the installer 45 edit_integrity_configuration
46 edit_thin_configuration
47 end
48
49 def edit_integrity_configuration
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 50 config = File.read(root / "config.yml")
51 config.gsub!(%r(sqlite3:///var/integrity.db), "sqlite3://#{root}/integrity.db")
52 config.gsub!(%r(/path/to/scm/exports), "#{root}/builds")
7b409ab6 » sr 2008-11-21 update the installer to set... 53 config.gsub!(%r(/var/log), "#{root}/log")
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 54 File.open(root / "config.yml", "w") {|f| f.puts config }
55 end
3ff2b6ea » sr 2008-11-14 fix the installer 56
57 def edit_thin_configuration
58 config = File.read(root / 'thin.yml')
59 config.gsub!(%r(/apps/integrity), root)
60 File.open(root / 'thin.yml', 'w') { |f| f.puts config }
61 end
5a84bd67 » wilson 2008-11-20 Edit Thor descriptions so t... 62
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 63 def after_setup_message
64 puts
65 puts %Q(Awesome! Integrity was installed successfully!)
66 puts
67 puts %Q(If you want to enable notifiers, install the gems and then require them)
68 puts %Q(in #{root}/config.ru)
69 puts
70 puts %Q(For example:)
71 puts
72 puts %Q( sudo gem install -s http://gems.github.com foca-integrity-email)
73 puts
74 puts %Q(And then in #{root}/config.ru add:)
75 puts
76 puts %Q( require "notifier/email")
ac7ff963 » sr 2008-11-17 tell the user to tweak the ... 77 puts
78 puts %Q(Don't forget to tweak #{root / "config.yml"} to your needs.)
aa5893c8 » foca 2008-11-13 Add a Thor-based installer 79 end
80 end
81
3ff2b6ea » sr 2008-11-14 fix the installer 82 WithIntegrity.start