Skip to content
Browse files

rename range to range_type

  • Loading branch information...
1 parent 4371634 commit 61713b44579e8b1d088ed482c9883f77fad79310 @smparkes smparkes committed Mar 8, 2010
View
2 app/helpers/application_helper.rb
@@ -164,7 +164,7 @@ def error_class object, method = nil
end
def descriptor_types
- pcs = @property_classes.select { |pc| pc.range == "descriptor_value" }.map( &:id )
+ pcs = @property_classes.select { |pc| pc.range_type == "descriptor_value" }.map( &:id )
@property_types.select { |pt| pcs.include? pt.property_class_id }
end
View
2 app/helpers/library_helper.rb
@@ -23,7 +23,7 @@ def tabs
end
def descriptor_types
- pcs = PropertyClass.find( :all, :conditions => "range = 'descriptor_value'" ).map(&:id)
+ pcs = PropertyClass.find( :all, :conditions => "range_type = 'descriptor_value'" ).map(&:id)
@property_types.select { |pt| pcs.include?(pt.property_class_id) }.sort { |a,b| b.priority <=> a.priority }
end
View
8 app/helpers/videos_helper.rb
@@ -116,15 +116,15 @@ def assets_json
private
def render_partial_by_class class_name, title
- range = PropertyClass.find_by_name( class_name ).range
- render :partial => "show_properties_#{range}",
+ range_type = PropertyClass.find_by_name( class_name ).range_type
+ render :partial => "show_properties_#{range_type}",
:locals => { :property_class => class_name,
:title => title }
end
def render_partial_edit_by_class class_name
- range = PropertyClass.find_by_name( class_name ).range
- render :partial => "edit_properties_#{range}",
+ range_type = PropertyClass.find_by_name( class_name ).range_type
+ render :partial => "edit_properties_#{range_type}",
:locals => { :property_class => class_name }
end
View
30 app/models/property_class.rb
@@ -30,18 +30,18 @@ class PropertyClass < ActiveRecord::Base
validates_presence_of :name
validates_inclusion_of :multivalued, :optional, :in => [ true, false ]
- validates_inclusion_of :range, :in => ( RANGE_MAP.keys +
- RANGE_MAP.keys.map( &:to_sym ) )
+ validates_inclusion_of :range_type, :in => ( RANGE_MAP.keys +
+ RANGE_MAP.keys.map( &:to_sym ) )
before_save { |pc|
- Symbol === pc.range and pc.range = pc.range.to_s
+ Symbol === pc.range_type and pc.range_type = pc.range_type.to_s
true
}
class NoRangeClass < StandardError; end
def self.simple
- find :all, :conditions => "range in ( 'string', 'date' )"
+ find :all, :conditions => "range_type in ( 'string', 'date' )"
end
def tableize
@@ -50,13 +50,13 @@ def tableize
end
def field
- lambdas = RANGE_MAP[range.to_s]
+ lambdas = RANGE_MAP[range_type.to_s]
lambdas and lambdas[:field]
end
def values type, options = nil
- lambdas = RANGE_MAP[range.to_s]
- raise NoRangeClass.new( range ) if not lambdas
+ lambdas = RANGE_MAP[range_type.to_s]
+ raise NoRangeClass.new( range_type ) if not lambdas
if lambdas[:values]
lambdas[:values].call( type, options )
else
@@ -65,26 +65,26 @@ def values type, options = nil
end
def validate_value property
- lambdas = RANGE_MAP[range.to_s]
- raise NoRangeClass.new( range ) if not lambdas
+ lambdas = RANGE_MAP[range_type.to_s]
+ raise NoRangeClass.new( range_type ) if not lambdas
lambdas[:validate] ? lambdas[:validate].call( property ) : true
end
def translate_value property
- lambdas = RANGE_MAP[range.to_s]
- raise NoRangeClass.new( range ) if not lambdas
+ lambdas = RANGE_MAP[range_type.to_s]
+ raise NoRangeClass.new( range_type ) if not lambdas
lambdas[:translate] ? lambdas[:translate].call( property ) : true
end
def retrieve_value property
- lambdas = RANGE_MAP[range.to_s]
- raise NoRangeClass.new( range ) if not lambdas
+ lambdas = RANGE_MAP[range_type.to_s]
+ raise NoRangeClass.new( range_type ) if not lambdas
lambdas[:retrieve].call( property )
end
def retrieve_priority property
- lambdas = RANGE_MAP[range.to_s]
- raise NoRangeClass.new( range ) if not lambdas
+ lambdas = RANGE_MAP[range_type.to_s]
+ raise NoRangeClass.new( range_type ) if not lambdas
( l = lambdas[:priority] ) ? l.call( property ) : 0
end
View
4 app/models/property_type.rb
@@ -40,14 +40,14 @@ def self.descriptor_types
:select => "pts.*",
:joins => "pts, property_classes pcs",
:conditions => "property_class_id = pcs.id and " +
- "range = 'descriptor_value'"
+ "range_type = 'descriptor_value'"
end
def descriptor_values
# This is allowed because it's called from the destructor
# Could make the destructor more explicit (and the dvs not dependent)
# but the extra safety doesn't seem a big deal now?
- if property_class.range == "descriptor_value"
+ if property_class.range_type == "descriptor_value"
property_class.values self
else
# raise NotDescriptorType.new( property_class_id ) unless
View
4 app/models/video.rb
@@ -145,12 +145,12 @@ def update_tags string
end
def descriptors
- ids = PropertyClass.find_all_by_range "descriptor_value"
+ ids = PropertyClass.find_all_by_range_type "descriptor_value"
(properties.find_all_by_property_class_id ids).freeze
end
def descriptors= descriptors
- ids = PropertyClass.find_all_by_range "descriptor_value"
+ ids = PropertyClass.find_all_by_range_type "descriptor_value"
(properties.find_all_by_property_class_id ids).each {|p| p.destroy}
descriptors.each { |d| properties << d }
end
View
2 db/migrate/20081003200654_create_property_classes.rb
@@ -4,7 +4,7 @@ def self.up
t.string :name, :null => false
t.boolean :multivalued, :null => false
t.boolean :optional, :null => false
- t.string :range, :null => false
+ t.string :range_type, :null => false
t.timestamps
end
end
View
22 lib/ovdlt/import/map.rb
@@ -116,33 +116,33 @@ def import file
when Hash
if header.size == 1
key = header.keys.first
- range = header.values.first
+ range_type = header.values.first
if key =~ /^[a-z]/
- case range
+ case range_type
when String
- set video, key, Object.const_get(range).map(value)
+ set video, key, Object.const_get(range_type).map(value)
when Hash
- if range.has_key? value
- set video, key, range[value]
+ if range_type.has_key? value
+ set video, key, range_type[value]
else
raise "can't map #{value} for #{key}"
end
when Proc;
- set video, key, range.call( value )
+ set video, key, range_type.call( value )
else
- raise "cannot map range #{range.class} #{range}"
+ raise "cannot map range_type #{range_type.class} #{range_type}"
end
elsif key =~ /^[A-Z]/
value.split(/[\s;]+/).each do |v|
- case range
+ case range_type
when String;
when Hash;
- if range.has_key? v
- v = range[v]
+ if range_type.has_key? v
+ v = range_type[v]
else
raise "can't map #{v} for #{key}"
end
- else raise "bad range: #{range} (for #{key})"
+ else raise "bad range_type: #{range_type} (for #{key})"
end
video.properties << (p = Property.build( key, v ))
end
View
2 lib/tasks/populate.rake
@@ -36,7 +36,7 @@ namespace :db do
years = (1850..2008).to_a
- collections = Collection.find_all_by_user_id 10
+ collections = Collection.find_all_by_user_id 3
# generate videos
View
84 public/javascripts/jquery-ui-1.7.2/tests/visual/all.css
@@ -1,84 +0,0 @@
-
-body { font-size: 62.5%; margin: 0; padding: 20px; background: #191919; }
-ul.plugins {
- margin: 0;
- padding: 0;
-}
-ul.plugins li.plugin {
- margin: 0 12px 12px 0;
- list-style-type: none;
- width: 220px;
- height: 220px;
- float: left;
- color: white;
- border: 1px solid gray;
- text-align: center;
- font-weight: bold;
-}
-li.plugin {
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
-}
-
-#draggable, #resizable, #selectable, #sortable {
- margin: 10px;
- width: 190px; height: 180px;
- text-align: center;
- background: #FF9C08; color: white; font-weight: bold;
- -moz-border-radius: 2px; -webkit-border-radius: 2px; border-radius: 2px;
-}
-#accordion {
- background: none;
- text-align: left;
-}
-#accordion, #datepicker, #dialog, #progressbar, #slider {
- margin: 10px;
-}
-#datepicker {
- margin-left: -40px;
-}
-#tabs {
- margin: 0 10px;
-}
-#selectable div {
- width: 45px; height: 45px; float: left; margin: 6px 8px;
- border: 1px solid white;
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
-}
-#selectable .ui-selecting {
- background: gray;
-}
-#selectable .ui-selected {
- background: black;
-}
-#sortable div {
- width: 45px; height: 45px; float: left; margin: 6px 8px;
- border: 1px solid white;
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
-}
-#sortable .ui-sortable-helper {
- background: black;
-}
-#tabs {
- text-align: left;
-}
-
-.draggable {
- margin: 10px;
- width: 32px;
- height: 30px;
- float: left;
- background: #FF9C08;
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
-}
-#droppable {
- margin: 10px;
- width: 190px;
- height: 130px;
- float: left;
- border: 1px solid #FF9C08;
- overflow: hidden;
- -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;
-}
-#droppable .draggable {
- margin: 7px;
-}
View
30 spec/controllers/library_controller_spec.rb
@@ -177,25 +177,25 @@ def post_bad_update params = nil
PropertyClass.find_by_id(@pc_id).should be_nil
end
- it "should should validate pc range" do
+ it "should should validate pc range_type" do
- [ "rights_detail", "string" ].each do |range|
+ [ "rights_detail", "string" ].each do |range_type|
- @pc["range"] = range
+ @pc["range_type"] = range_type
post :update, @params
response.should redirect_to(library_path)
- PropertyClass.find(@pc_id).range.should == range
+ PropertyClass.find(@pc_id).range_type.should == range_type
end
- @pc["range"] = "xyzzy"
+ @pc["range_type"] = "xyzzy"
post :update, @params
assigns[:property_classes][@pc_id].errors.should_not be_nil
- PropertyClass.find(@pc_id).range.should == "string"
+ PropertyClass.find(@pc_id).range_type.should == "string"
end
end
@@ -574,47 +574,47 @@ def post_bad_update params = nil
1 => { "name" => "Date Types",
"multivalued" => true,
"optional" => true,
- "range" => "date" },
+ "range_type" => "date" },
2 => { "name" => "Roles",
"multivalued" => true,
"optional" => true,
- "range" => "string" },
+ "range_type" => "string" },
4 => { "name" => "Optional Multivalued Descriptor",
"multivalued"=>true,
"optional"=>true,
- "range"=>"descriptor_value" },
+ "range_type"=>"descriptor_value" },
5 => { "name"=>"Digital Files",
"multivalued"=>true,
"optional"=>true,
- "range"=>"string" },
+ "range_type"=>"string" },
6 => {"name"=>"Rights Statements",
"multivalued"=>false,
"optional"=>false,
- "range"=>"rights_detail"},
+ "range_type"=>"rights_detail"},
7 => {"name"=>"Mandatory Multivalued Descriptor",
"multivalued"=>true,
"optional"=>false,
- "range"=>"descriptor_value"},
+ "range_type"=>"descriptor_value"},
8 => {"name"=>"Optional Singular Descriptor",
"multivalued"=>false,
"optional"=>true,
- "range"=>"descriptor_value"},
+ "range_type"=>"descriptor_value"},
9 => {"name"=>"Mandatory Singular Descriptor",
"multivalued"=>false,
"optional"=>false,
- "range"=>"descriptor_value"},
+ "range_type"=>"descriptor_value"},
10 => {"name"=>"Format Types",
"multivalued"=>true,
"optional"=>true,
- "range"=>"string"}
+ "range_type"=>"string"}
},
View
20 spec/fixtures/property_classes.yml
@@ -1,69 +1,69 @@
date:
id: 1
name: Date Types
- range: date
+ range_type: date
optional: true
multivalued: true
role:
id: 2
name: Roles
- range: string
+ range_type: string
optional: true
multivalued: true
# collection:
# id: 3
# name: Collections
-# range: string
+# range_type: string
# optional: true
# multivalued: true
4:
id: 4
name: Optional Multivalued Descriptor
- range: descriptor_value
+ range_type: descriptor_value
optional: true
multivalued: true
digital_file:
id: 5
name: Digital Files
- range: string
+ range_type: string
optional: true
multivalued: true
rights_statements:
id: 6
name: Rights Statements
- range: rights_detail
+ range_type: rights_detail
optional: false
multivalued: false
7:
id: 7
name: Mandatory Multivalued Descriptor
- range: descriptor_value
+ range_type: descriptor_value
optional: false
multivalued: true
8:
id: 8
name: Optional Singular Descriptor
- range: descriptor_value
+ range_type: descriptor_value
optional: true
multivalued: false
9:
id: 9
name: Mandatory Singular Descriptor
- range: descriptor_value
+ range_type: descriptor_value
optional: false
multivalued: false
10:
id: 10
name: Format Types
- range: string
+ range_type: string
optional: true
multivalued: true
View
2 spec/helpers/application_helper_spec.rb
@@ -77,7 +77,7 @@
assigns[:descriptor_values] = @descriptor_values = DescriptorValue.find( :all )
- dt = @property_types.find { |pt| pt.property_class.range == "descriptor_value" }
+ dt = @property_types.find { |pt| pt.property_class.range_type == "descriptor_value" }
@descriptor_values << ( dv = DescriptorValue.new( :property_type_id => dt.id ) )
View
8 spec/helpers/library_helper_spec.rb
@@ -24,18 +24,18 @@
it "should return all the current descriptor types" do
assigns[:property_types] = @property_types =
- PropertyType.find( :all ).select { |pt| pt.property_class.range == "descriptor_value" }
+ PropertyType.find( :all ).select { |pt| pt.property_class.range_type == "descriptor_value" }
@property_types << ( pt = PropertyType.new( :property_class =>
PropertyClass.find( :first,
:conditions =>
- "range = 'descriptor_value'"
+ "range_type = 'descriptor_value'"
)
) )
sort_ar( helper.descriptor_types ).
should == sort_ar( [ pt ] +( PropertyType.find( :all ).
- select { |pt| pt.property_class.range ==
+ select { |pt| pt.property_class.range_type ==
"descriptor_value" } ) )
end
@@ -45,7 +45,7 @@
it "should return a descriptor class type" do
dcs = PropertyClass.find :all,
- :conditions => "range = 'descriptor_value'"
+ :conditions => "range_type = 'descriptor_value'"
dcs.include?( helper.default_descriptor_class ).should be_true
end
View
16 spec/models/property_class_spec.rb
@@ -7,7 +7,7 @@
:name => "some property name",
:multivalued => true,
:optional => false,
- :range => "string",
+ :range_type => "string",
}
end
@@ -33,8 +33,8 @@
should raise_error( ActiveRecord::RecordInvalid )
end
- it "should require a resonable range" do
- @valid_attributes[:range] = "nothing_good"
+ it "should require a resonable range_type" do
+ @valid_attributes[:range_type] = "nothing_good"
lambda { PropertyClass.create!(@valid_attributes) }.
should raise_error( ActiveRecord::RecordInvalid )
end
@@ -71,15 +71,15 @@
describe "#validate_value" do
it "should validate a good date" do
- @valid_attributes[:range] = "date"
+ @valid_attributes[:range_type] = "date"
property_class = PropertyClass.create!(@valid_attributes)
property = mock "property"
property.stub!(:value).and_return("12/25/2005")
property_class.validate_value( property ).should be_true
end
it "should not validate a bad date" do
- @valid_attributes[:range] = "date"
+ @valid_attributes[:range_type] = "date"
property_class = PropertyClass.create!(@valid_attributes)
property = mock "property"
property.stub!(:value).and_return("12/52/2005")
@@ -94,7 +94,7 @@
describe "#translate_value" do
it "should return a date for a date" do
- @valid_attributes[:range] = "date"
+ @valid_attributes[:range_type] = "date"
property_class = PropertyClass.create!(@valid_attributes)
property = mock "property"
property.should_receive(:value).and_return("12/25/2005")
@@ -107,7 +107,7 @@
describe "#retrieve_value" do
it "should return a string for a string" do
- @valid_attributes[:range] = "string"
+ @valid_attributes[:range_type] = "string"
property_class = PropertyClass.create!(@valid_attributes)
property = mock "property"
property.stub!(:string_value).and_return("a result")
@@ -116,7 +116,7 @@
end
it "should return a date for a date" do
- @valid_attributes[:range] = "date"
+ @valid_attributes[:range_type] = "date"
property_class = PropertyClass.create!(@valid_attributes)
property = mock "property"
property.stub!(:date_value).and_return(Date.parse("12/25/2005"))
View
4 spec/models/video_spec.rb
@@ -152,7 +152,7 @@
pc = PropertyClass.create! :name => "myclass",
:multivalued => false,
:optional => false,
- :range => :string
+ :range_type => :string
pt = PropertyType.create! :property_class_id => pc.id,
:name => "mytype"
@@ -170,7 +170,7 @@
pc = PropertyClass.create! :name => "myclass",
:multivalued => false,
:optional => false,
- :range => :string
+ :range_type => :string
pt = PropertyType.create! :property_class_id => pc.id,
:name => "mytype"

0 comments on commit 61713b4

Please sign in to comment.
Something went wrong with that request. Please try again.