Module: Bagel

Defined in:
lib/bagel.rb,
lib/bagel/video.rb,
lib/bagel/tennis.rb,
lib/bagel/graphic.rb,
lib/bagel/version.rb,
lib/bagel/timeframe.rb,
lib/bagel/graphic/stats/header.rb,
lib/bagel/graphic/stats/result.rb,
lib/bagel/graphic/stats/duration.rb,
lib/bagel/graphic/scoreboard/name.rb,
lib/bagel/graphic/scoreboard/sets.rb,
lib/bagel/graphic/scoreboard/games.rb,
lib/bagel/graphic/scoreboard/score.rb,
lib/bagel/graphic/scoreboard/points.rb,
lib/bagel/graphic/scoreboard/server.rb

Defined Under Namespace

Modules: Graphic, Tennis, Video Classes: Timeframe

Constant Summary collapse

TMP_DIR =
'tmp'
GRAPHIC_DIR =
'graphics'
TRIM_DIR =
'trims'
CLIP_DIR =
'clips'
VERSION =
"0.1.0"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.check_valuesObject



45
46
47
48
# File 'lib/bagel.rb', line 45

def self.check_values
  raise 'source_video does not exist' unless File.exist?(config.source_video.to_s)
  raise 'score_sheet does not exist' unless File.exist?(config.clip_data.to_s)
end

.configObject



34
35
36
# File 'lib/bagel.rb', line 34

def self.config
  @config ||= OpenStruct.new
end

.configure {|config| ... } ⇒ Object

Yields:



38
39
40
41
42
43
# File 'lib/bagel.rb', line 38

def self.configure
  yield(config)
  check_values
  set_default_values
  init_directories
end

.make_videoObject



71
72
73
74
75
# File 'lib/bagel.rb', line 71

def self.make_video
  data = Bagel.config.clip_data
  clips = ClipDataParser.new(data).parse_clips
  Video::Video.new(clips).save
end

.set_default_valuesObject



50
51
52
53
# File 'lib/bagel.rb', line 50

def self.set_default_values
  @config.show_scores = true if config.show_scores.nil?
  @config.show_second_serve_indicator = true if config.show_second_serve_indicator.nil?
end

Instance Method Details

#init_directoriesObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/bagel.rb', line 55

def init_directories
  @config.tmp_dir = File.join(TMP_DIR, @config.name)
  @config.graphic_dir = File.join(@config.tmp_dir, GRAPHIC_DIR)
  @config.trim_dir = File.join(@config.tmp_dir, TRIM_DIR)
  @config.clip_dir = File.join(@config.tmp_dir, CLIP_DIR)

  [
    @config.graphic_dir,
    @config.trim_dir,
    @config.clip_dir
  ].each do |path|
    FileUtils.rm_rf(path, secure: true)
    FileUtils.mkdir_p(path)
  end
end