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
44
45
46
47
48
|
# 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)"
if (File.exists?('app/views/layouts/application.html.haml'))
inject_into_file 'app/views/layouts/application.html.haml', :before => '%body' do
"= bitmovin_player_script\n"
end
puts "Injected a script tag into your HAML Layout. Please make sure it is indented correctly."
end
if (File.exists?('app/views/layouts/application.html.erb'))
inject_into_file 'app/views/layouts/application.html.erb', :before => '</head>' do
"<%= bitmovin_player_script %>\n"
end
end
puts "Installation successful!"
readme File.expand_path('.././INSTRUCTIONS', __FILE__)
end
|