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
35
36
37
38
39
40
41
42
43
|
# File 'lib/podrb/commands/init/runner.rb', line 9
def call
return build_failure_response(details: :home_not_found) if home_dir.nil?
return build_failure_response(details: :already_initialized) if Dir.exist?(podrb_config_dir)
FileUtils.mkdir_p(podrb_config_dir)
db = Infrastructure::Storage::SQL.new(db: podrb_db_dir)
db.execute " create table podcasts (\n id integer primary key,\n name text not null,\n description text,\n feed text not null unique,\n website text\n );\n SQL\n db.execute <<-SQL\n create table episodes (\n id integer primary key,\n title text not null,\n release_date text,\n duration text,\n link text not null,\n archived_at text,\n external_id string unique,\n podcast_id integer not null,\n foreign key(podcast_id) references podcasts(id)\n );\n SQL\n\n build_success_response(details: :successfully_initialized)\nrescue SystemCallError, Infrastructure::Storage::Exceptions::CantStartConnection\n build_failure_response(details: :cannot_create_initial_config)\nend\n"
|