Class: Tractive::Main
- Inherits:
-
Object
- Object
- Tractive::Main
- Defined in:
- lib/tractive/main.rb
Instance Method Summary collapse
- #create_attachment_exporter_script ⇒ Object
- #export_attachments ⇒ Object
- #info ⇒ Object
-
#initialize(opts) ⇒ Main
constructor
A new instance of Main.
- #migrate ⇒ Object
- #migrate_wikis ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(opts) ⇒ Main
Returns a new instance of Main.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tractive/main.rb', line 5 def initialize(opts) (opts) @opts = opts @cfg = YAML.load_file(@opts[:config]) Tractive::Utilities.setup_logger(output_stream: @opts[:logfile] || $stderr, verbose: @opts[:verbose]) verify_config!(@cfg, @opts) @cfg["github"] ||= {} @cfg["github"]["token"] = @opts["git-token"] if @opts["git-token"] GithubApi::GraphQlClient.add_constants(@cfg["github"]["token"]) unless @opts[:info] @db = Tractive::Utilities.setup_db!(@opts["trac-database-path"] || @cfg["trac"]["database"]) rescue Sequel::DatabaseConnectionError, Sequel::AdapterNotFound, URI::InvalidURIError, Sequel::DatabaseError => e $logger.error e. exit 1 rescue StandardError => e warn_and_exit(e., 1) end |
Instance Method Details
#create_attachment_exporter_script ⇒ Object
58 59 60 |
# File 'lib/tractive/main.rb', line 58 def Tractive::AttachmentExporter.new(@cfg, @db).generate_script end |
#export_attachments ⇒ Object
54 55 56 |
# File 'lib/tractive/main.rb', line 54 def Tractive::AttachmentExporter.new(@cfg, @db).export end |
#info ⇒ Object
50 51 52 |
# File 'lib/tractive/main.rb', line 50 def info Tractive::Info.new.print end |
#migrate ⇒ Object
42 43 44 |
# File 'lib/tractive/main.rb', line 42 def migrate Migrator::Engine.new(opts: @opts, cfg: @cfg, db: @db).migrate end |
#migrate_wikis ⇒ Object
46 47 48 |
# File 'lib/tractive/main.rb', line 46 def migrate_wikis Migrator::Wikis::MigrateFromDb.new(opts: @opts, cfg: @cfg).migrate_wikis end |
#run ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tractive/main.rb', line 28 def run if @opts[:info] info elsif @opts[:attachmentexporter] elsif @opts[:exportattachments] elsif @opts[:generaterevmap] generate_revmap_file else migrate end end |