Radio, Web and Free Software

Changeset 8c82fb69f188ac11b1eb2c70bf0f70ee71c378f1

Show
Ignore:
Timestamp:
07/27/10 21:23:22 (6 weeks ago)
Author:
Alban Peignier <alban@…>
Parents:
4d873e1c0c111a263ce1177d4c75ac80f32ef027
git-committer:
Alban Peignier <alban@tryphon.eu> / 2010-07-27T21:23:22Z+0200
Message:

Add Server#server_type supporting icecast2/shoutcast. Refs #19

Files:
7 modified

Legend:

Unmodified
Added
Removed
  • app/models/stream.rb

    r99b6862 r8c82fb6  
    88  validates_presence_of :name 
    99 
    10   attr_accessor :server, :password, :mount_point 
     10  attr_accessor :server, :server_type, :password, :mount_point 
    1111  acts_as_ip_port :port 
    12   validates_presence_of :server, :port, :mount_point, :password 
     12  validates_presence_of :server, :server_type, :port, :password 
     13  validates_presence_of :mount_point, :if => :icecast_server? 
     14  validates_inclusion_of :server_type, :in => [ :icecast2, :shoutcast ] 
    1315 
    14   validates_format_of :mount_point, :with => %r{^[^/]} 
     16  validates_format_of :mount_point, :with => %r{^[^/]}, :allow_blank => true 
    1517 
    1618  attr_accessor :format 
     
    2729    self.format ||= :vorbis 
    2830    self.quality ||= 4 
     31    self.server_type ||= :icecast2 
    2932    self.enabled = true if self.enabled.nil? 
    3033 
     
    5659  def path 
    5760    mount_point and mount_point.start_with?('/') ? mount_point : "/#{mount_point}" 
     61  end 
     62 
     63  def server_type=(server_type) 
     64    @server_type = server_type ? server_type.to_sym : nil 
     65  end 
     66 
     67  def icecast_server? 
     68    server_type == :icecast2 
    5869  end 
    5970 
  • app/views/streams/_form.erb

    r99b6862 r8c82fb6  
    55 
    66<h3><%= t(".server_attributes") %></h3> 
     7 
     8<p> 
     9  <%= form.label :server_type, Stream.human_attribute_name("server_type") %><br/> 
     10  <%= form.select :server_type, options_for_select([:icecast2, :shoutcast], @stream.server_type) %> 
     11</p> 
    712 
    813<p> 
  • app/views/streams/show.html.erb

    r99b6862 r8c82fb6  
    33<div class="stream description <%= @stream.presenter.status_class %>"> 
    44  <h3><%= t(".server_attributes") %></h3> 
     5 
     6  <p> 
     7    <%= Stream.human_attribute_name("server_type") %> : 
     8    <%= @stream.server_type %> 
     9  </p> 
     10 
    511  <p> 
    612    <%= Stream.human_attribute_name("server") %> : 
     
    1319  </p> 
    1420 
    15   <p> 
    16     <%= Stream.human_attribute_name("mount_point") %> : 
    17     <%= @stream.mount_point %> 
    18   </p> 
     21  <% if @stream.icecast_server? %> 
     22    <p> 
     23      <%= Stream.human_attribute_name("mount_point") %> : 
     24      <%= @stream.mount_point %> 
     25    </p> 
     26  <% end %> 
    1927 
    2028  <p> 
  • config/environment.rb

    r5b70fb7 r8c82fb6  
    22 
    33# Specifies gem version of Rails to use when vendor/rails is not present 
    4 RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION 
     4RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION 
    55 
    66# Bootstrap the Rails environment, frameworks, and default configuration 
     
    3535  # config.gem "aws-s3", :lib => "aws/s3" 
    3636 
    37   config.gem "inherited_resources", :version => "1.0.3" 
     37  config.gem "inherited_resources", :version => "1.0.6" 
    3838  config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org' 
    3939  config.gem 'delayed_job' 
  • config/locales/fr/stream.yml

    r99b6862 r8c82fb6  
    88        related_url: URL associée 
    99        server: Serveur 
     10        server_type: Type de serveur 
    1011        mount_point: Point de montage 
    1112        password: Mot de passe 
  • spec/models/stream_spec.rb

    r99b6862 r8c82fb6  
    2020  it { should validate_presence_of :server } 
    2121  it { should validate_presence_of :port } 
    22   it { should validate_presence_of :mount_point } 
    2322  it { should validate_presence_of :password } 
    2423 
     
    4544  end 
    4645 
    47   it "should use vorbis format for a new Stream" do 
    48     Stream.new.format.should == :vorbis 
    49   end 
    50  
    51   it "should use quality 4 for a new Stream" do 
    52     Stream.new.quality.should == 4 
    53   end 
    54  
    55   it "should enable a new Stream" do 
    56     Stream.new.should be_enabled 
     46  describe "for a new Stream" do 
     47 
     48    subject { Stream.new } 
     49 
     50    its(:format) { should == :vorbis } 
     51    its(:quality) { should == 4 } 
     52    it { should be_enabled } 
     53    its(:server_type) { should == :icecast2 } 
     54     
     55  end 
     56 
     57 
     58  describe "server_type" do 
     59 
     60    it { should validate_presence_of :server_type } 
     61     
     62    it "should support :icecast2 and :shoutcast" do 
     63      @stream.should allow_values_for :server_type, :icecast2, :shoutcast 
     64      @stream.should_not allow_values_for :server_type, :dummy 
     65    end 
     66 
     67    it "should be symbolized" do 
     68      @stream.server_type = "dummy" 
     69      @stream.server_type.should == :dummy 
     70    end 
     71 
     72  end 
     73 
     74  describe "mount_point" do 
     75 
     76    context "when server is an icecast server" do 
     77      before(:each) do 
     78        subject.stub :icecast_server? => true 
     79      end 
     80      it { should validate_presence_of :mount_point } 
     81    end 
     82 
     83    context "when server is not an icecast server" do 
     84      before(:each) do 
     85        subject.stub :icecast_server? => false 
     86      end 
     87      it { should_not validate_presence_of :mount_point } 
     88    end 
     89     
    5790  end 
    5891 
     
    6396    it "should support :vorbis, :mp3 and :aac" do 
    6497      @stream.should allow_values_for :format, :vorbis, :mp3, :aac 
    65       @stream.should_not allow_values_for :dummy 
     98      @stream.should_not allow_values_for :format, :dummy 
    6699    end 
    67100 
  • spec/views/streams/_form.erb_spec.rb

    rc3ae370 r8c82fb6  
    66    assigns[:stream] = @stream = Stream.new(:id => 1) 
    77 
    8     @form_builder = stub :text_field => '<input type="text"/>', :label => '<label/>', :collection_select => "<select/>", :check_box => '<input type="checkbox"/>' 
     8    @form_builder = stub :text_field => '<input type="text"/>', :label => '<label/>', :collection_select => "<select/>", :check_box => '<input type="checkbox"/>', :select => '<select/>' 
    99 
    1010    template.stub!(:format_radio_buttons)