Class: SSRS::DataSource
- Inherits:
-
Object
- Object
- SSRS::DataSource
- Defined in:
- lib/ssrs/datasource.rb
Constant Summary collapse
- BASE_PATH =
'DataSources'
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#datasource_id ⇒ Object
Returns the value of attribute datasource_id.
-
#host ⇒ Object
Returns the value of attribute host.
-
#instance ⇒ Object
Returns the value of attribute instance.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #connection_string ⇒ Object
- #host_spec ⇒ Object
-
#initialize(name) ⇒ DataSource
constructor
A new instance of DataSource.
- #symbolic_name ⇒ Object
- #write(file) ⇒ Object
Constructor Details
#initialize(name) ⇒ DataSource
Returns a new instance of DataSource.
6 7 8 9 |
# File 'lib/ssrs/datasource.rb', line 6 def initialize(name) self.name = name self.datasource_id = SSRS::UUID.create.to_s end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def database @database end |
#datasource_id ⇒ Object
Returns the value of attribute datasource_id.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def datasource_id @datasource_id end |
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def host @host end |
#instance ⇒ Object
Returns the value of attribute instance.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def instance @instance end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/ssrs/datasource.rb', line 4 def username @username end |
Instance Method Details
#connection_string ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ssrs/datasource.rb', line 19 def connection_string auth_details = unless ( self.username || self.password ) 'Integrated Security=SSPI' else "User Id=#{self.username};Password=#{self.password}" end "Data Source=#{self.host_spec};Initial Catalog=#{self.database};#{auth_details};" end |
#host_spec ⇒ Object
11 12 13 |
# File 'lib/ssrs/datasource.rb', line 11 def host_spec "#{self.host}#{self.instance.nil? ? '' : '\\'}#{self.instance}" end |
#symbolic_name ⇒ Object
15 16 17 |
# File 'lib/ssrs/datasource.rb', line 15 def symbolic_name "#{DataSource::BASE_PATH}/#{self.name}" end |
#write(file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ssrs/datasource.rb', line 28 def write(file) file.write "<RptDataSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n <Name>\#{self.name}</Name>\n <ConnectionProperties>\n<Extension>SQL</Extension>\n<ConnectString>\#{connection_string}</ConnectString>\n </ConnectionProperties>\n <DataSourceID>\#{self.datasource_id}</DataSourceID>\n</RptDataSource>\n" end |