Class: SSRS::DataSource

Inherits:
Object
  • Object
show all
Defined in:
lib/ssrs/datasource.rb

Constant Summary collapse

BASE_PATH =
'DataSources'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#databaseObject

Returns the value of attribute database.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def database
  @database
end

#datasource_idObject

Returns the value of attribute datasource_id.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def datasource_id
  @datasource_id
end

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def host
  @host
end

#instanceObject

Returns the value of attribute instance.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def instance
  @instance
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def name
  @name
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def password
  @password
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/ssrs/datasource.rb', line 4

def username
  @username
end

Instance Method Details

#connection_stringObject



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_specObject



11
12
13
# File 'lib/ssrs/datasource.rb', line 11

def host_spec
  "#{self.host}#{self.instance.nil? ? '' : '\\'}#{self.instance}"
end

#symbolic_nameObject



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