mp3_player 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,12 @@ require 'mp3_player/version'
3
3
  require 'mp3_player/view_helper'
4
4
  require 'mp3_player/layout_helper'
5
5
  require 'mp3_player/engine'
6
+ require 'mp3_player/configuration'
6
7
  # includes the view and layout helpers to ActionView::Base
7
8
  ActionView::Base.send(:include, Mp3Player::ViewHelper)
8
9
  ActionView::Base.send(:include, Mp3Player::LayoutHelper)
9
10
 
11
+ module Mp3Player
12
+ mattr_accessor :default_options
13
+ @@default_options = nil
14
+ end
@@ -0,0 +1,10 @@
1
+ module Mp3Player
2
+ class Configuration
3
+ def self.load_options
4
+ config_file_path = Rails.root.join('config', 'mp3_player.yml')
5
+ if File.exists? config_file_path
6
+ Mp3Player.default_options = YAML::load(File.open(config_file_path))
7
+ end
8
+ end
9
+ end
10
+ end
@@ -2,5 +2,16 @@ module Mp3Player
2
2
  # Required for assets to be discoverable in the asset pipeline
3
3
  # @private
4
4
  class Engine < ::Rails::Engine
5
+ initializer 'mp3_player.assets_precompile', group: :all do |app|
6
+ app.config.assets.precompile += [
7
+ 'audio-player.js',
8
+ 'audio-player-noswfobject.js',
9
+ 'player.swf'
10
+ ]
11
+ end
12
+
13
+ initializer 'mp3_player.load_options' do
14
+ Configuration.load_options
15
+ end
5
16
  end
6
17
  end
@@ -1,18 +1,12 @@
1
1
  module Mp3Player
2
2
  module LayoutHelper
3
- if Rails.env.production?
4
- load_config_options
5
- else
6
- @@default_options = nil
7
- end
8
-
9
3
  def mp3_player_headers options = {}
10
4
  ViewHelper.reset_player_count
11
5
 
12
6
  # Don't reload configuration options in production env
13
- load_config_options if !Rails.env.production?
7
+ Configuration.load_options if !Rails.env.production?
14
8
 
15
- options.reverse_merge! @@default_options if @@default_options
9
+ options.reverse_merge! Mp3Player.default_options if Mp3Player.default_options
16
10
  options.reverse_merge!({ width: 290 })
17
11
 
18
12
  audio_player_path = if options[:with_swfobject] == false
@@ -24,18 +18,8 @@ module Mp3Player
24
18
  javascript_include_tag(audio_player_path) +
25
19
  %Q[
26
20
  <script type="text/javascript">
27
- AudioPlayer.setup("#{asset_path('player.swf')}/", #{options.to_json} );
21
+ AudioPlayer.setup("#{asset_path('player.swf')}", #{options.to_json} );
28
22
  </script>].html_safe
29
23
  end
30
-
31
- private
32
- def load_config_options
33
- config_file_path = Rails.root.join('config', 'mp3_player.yml')
34
- @@default_options = if File.exists? config_file_path
35
- YAML::load(File.open(config_file_path))
36
- else
37
- nil
38
- end
39
- end
40
24
  end
41
25
  end
@@ -1,3 +1,3 @@
1
1
  module Mp3Player
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mp3_player
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gavin Morrice
@@ -60,6 +60,7 @@ files:
60
60
  - lib/generators/mp3_player/templates/mp3_player.yml
61
61
  - lib/generators/mp3_player/yml_generator.rb
62
62
  - lib/mp3_player.rb
63
+ - lib/mp3_player/configuration.rb
63
64
  - lib/mp3_player/engine.rb
64
65
  - lib/mp3_player/layout_helper.rb
65
66
  - lib/mp3_player/version.rb