Module: Gdshowsdb
- Included in:
- ImportShows
- Defined in:
- lib/gdshowsdb.rb,
lib/gdshowsdb/diff.rb,
lib/gdshowsdb/version.rb,
lib/gdshowsdb/set_diff.rb,
lib/gdshowsdb/show_diff.rb,
lib/gdshowsdb/song_diff.rb,
lib/gdshowsdb/song_ref_diff.rb,
lib/gdshowsdb/set_yaml_parser.rb,
lib/gdshowsdb/set_db_extractor.rb,
lib/gdshowsdb/show_yaml_parser.rb,
lib/gdshowsdb/song_yaml_parser.rb,
lib/gdshowsdb/show_db_extractor.rb,
lib/gdshowsdb/song_db_extractor.rb,
lib/gdshowsdb/song_ref_yaml_parser.rb,
lib/gdshowsdb/song_ref_db_extractror.rb
Defined Under Namespace
Classes: Diff, SetDBExtractor, SetDiff, SetYAMLParser, ShowDBExtractor, ShowDiff, ShowYAMLParser, SongDBExtractor, SongDiff, SongRefDBExtractor, SongRefDiff, SongRefYAMLParser, SongYAMLParser
Constant Summary
collapse
- VERSION =
"3.0.0"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.init(params = { adapter: 'sqlite3', database: 'gdshowsdb.db' }) ⇒ Object
20
21
22
|
# File 'lib/gdshowsdb.rb', line 20
def self.init(params = { adapter: 'sqlite3', database: 'gdshowsdb.db' })
@@connection = ActiveRecord::Base.establish_connection(params)
end
|
.load(level = nil) ⇒ Object
24
25
26
27
28
|
# File 'lib/gdshowsdb.rb', line 24
def self.load(level = nil)
schema_migration = ActiveRecord::Base.connection.schema_migration
migration_context = ActiveRecord::MigrationContext.new(File.dirname(__FILE__) + '/gdshowsdb/db/migrations', schema_migration)
ActiveRecord::Migrator.new(:up, migration_context.migrations, schema_migration, level).migrate
end
|
.load_yaml(file_name) ⇒ Object
34
35
36
|
# File 'lib/gdshowsdb.rb', line 34
def self.load_yaml(file_name)
YAML.load_file(yaml_file_location(file_name))
end
|
.load_yaml_for_year(year) ⇒ Object
38
39
40
|
# File 'lib/gdshowsdb.rb', line 38
def self.load_yaml_for_year(year)
load_yaml("#{year}.yaml")
end
|
.write_yaml(file_name, data) ⇒ Object
42
43
44
45
46
|
# File 'lib/gdshowsdb.rb', line 42
def self.write_yaml(file_name, data)
File.open(yaml_file_location(file_name), "w") do |file|
file.write data.to_yaml
end
end
|
.yaml_file_location(file_name) ⇒ Object
30
31
32
|
# File 'lib/gdshowsdb.rb', line 30
def self.yaml_file_location(file_name)
Gem.loaded_specs['gdshowsdb'].full_gem_path + "/data/gdshowsdb/#{file_name}"
end
|
Instance Method Details
#generate_uuid ⇒ Object
16
17
18
|
# File 'lib/gdshowsdb.rb', line 16
def generate_uuid
SecureRandom.uuid
end
|