Changeset 240


Ignore:
Timestamp:
Aug 28, 2009, 11:58:05 AM (11 years ago)
Author:
KOBAYASHI, Shinji
Message:

completed uri package

Location:
ruby/branches/0.5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/data_types/uri.rb

    r232 r240  
    66
    77module URI
    8   class Ehr < ::URI::Generic
     8  class EHR < ::URI::Generic
    99    COMPONENT = [
    1010      :scheme, :path, :fragment, :query
     
    2424    end
    2525  end
    26   @@schemes['EHR'] = Ehr
     26  @@schemes['EHR'] = EHR
    2727end
    2828
     
    3232      module Uri
    3333        class DvUri < OpenEHR::RM::DataTypes::Basic::DataValue
    34           attr_reader :value
    35 
    36           def initialize(args ={})
     34          def initialize(args = {})
    3735            self.value = args[:value]
    3836          end
    3937
     38          def value
     39            @value.to_s
     40          end
     41
    4042          def fragment_id
    41             @uri.fragment
     43            @value.fragment
    4244          end
    4345
    4446          def path
    45             @uri.path
     47            @value.path
    4648          end
    4749
    4850          def query
    49             @uri.query
     51            @value.query
    5052          end
    5153
    5254          def scheme
    53             @uri.scheme
     55            @value.scheme
    5456          end
    5557
     
    5759            raise ArgumentError, "value is empty" if value.nil?
    5860            parse(value)
    59             @value = value
    6061          end
    6162
     
    6364
    6465          def parse(value)
    65             @uri = ::URI.parse(value)
     66            @value = ::URI.parse(value)
    6667          end
    6768        end
     
    7475          def value=(value)
    7576            raise ArgumentError, "scheme must be ehr" if !(value =~ /^ehr/i)
    76             super(value)
     77            @value = parse(value)
    7778          end
    7879        end # of DV_EHR_URI
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/encapsulated/dv_parsable_spec.rb

    r238 r240  
    77    @dv_parsable = DvParsable.new(:value => 'test',
    88                                  :formalism => 'plain/text')
     9  end
     10
     11  it 'should be an instance of DvParsable' do
     12    @dv_parsable.should be_an_instance_of DvParsable
    913  end
    1014
     
    2428    lambda {@dv_parsable.formalism = nil}.should raise_error(ArgumentError)
    2529  end
     30
     31  it 'should raise ArgumentError formalism empty' do
     32    lambda {@dv_parsable.formalism = ''}.should raise_error(ArgumentError)
     33  end
    2634end
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/uri/dv_ehr_uri_spec.rb

    r233 r240  
    44describe DvEhrUri do
    55  before(:each) do
    6     @dv_ehr_uri = DvEhrUri.new(:value => 'ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00')
     6    @dv_ehr_uri = DvEhrUri.new(:value => 'ehr://test/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00')
     7  end
     8
     9  it 'should be an instance of EhrUri' do
     10    @dv_ehr_uri.should be_an_instance_of DvEhrUri
    711  end
    812
    913  it 's value should be valid' do
    1014    @dv_ehr_uri.value.should ==
    11       'ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00'
     15      'ehr://test/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00'
    1216  end
    1317
Note: See TracChangeset for help on using the changeset viewer.