Class: BitmovinPlayerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/bitmovin_player/bitmovin_player_generator.rb

Instance Method Summary collapse

Instance Method Details

#installObject



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
# File 'lib/generators/bitmovin_player/bitmovin_player_generator.rb', line 10

def install
  readme File.expand_path('.././README', __FILE__)
  @api_key = ask('Please enter your Bitmovin-Api-Key:')

  default_versions = fetch_player_versions

  puts "Available Player versions:"
  default_versions.each_with_index do |version, index|
    puts "#{index + 1}) [#{version["category"]}] #{version["version"]}"
  end
  default = default_versions.last

  player_index = ask("What player version do you want to install? (#{default_versions.length}):")
  player_index = default_versions.length if (player_index.blank?) 
  selected_version = default_versions[player_index.to_i - 1]

  puts "Installing Player `#{selected_version["version"]}`"

  @cdn_url = selected_version["cdnUrl"]
  @license_key = get_license_key
  @version = selected_version["version"]
  template "config.yml.erb", "config/bitmovin_player.yml"
  application "config.bitmovin_player = config_for(:bitmovin_player)"

  inject_into_file 'app/views/layouts/application.html.erb', :after => 'javascript_include_tag' do
    "<%= bitmovin_player_script %>"
  end

  puts "Installation successful!"
  readme File.expand_path('.././INSTRUCTIONS', __FILE__)
end