wolas_channel 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cae176f6087ce6fd8f9c2a75b545231e94738c72
4
- data.tar.gz: 8c6195c0ad5ec9af9ea849f529967c3b2ab38f70
3
+ metadata.gz: 9ad159ec4acd5e1fa0f357a2160848dc651525f8
4
+ data.tar.gz: 268d8324e8ede3207fcda9a549e764238aa63bd4
5
5
  SHA512:
6
- metadata.gz: 302805f4fbb7bad2a197400ce659d7a501debaf6443ed887cb6f30c8a6cba58060f9e34a7b45c366853eec2dcc0e527185001dc5fd04c0b3ae88c1afff254a2c
7
- data.tar.gz: 0ad7b705d138ffe972b683ed85563fa0b614c5f7738e3c1230f53d4b7b316d04d204c6f0863bde6810f4251f5c910421e4e400d9663c9e4441bb5efd173828fc
6
+ metadata.gz: dc09ceb2f397fbf6b758a50b349b410a70d9d99a355c4d2a5f77d58f5eaa2fea9adad49af055404947d35e720db01876b535f2073b782be1d89db03680687790
7
+ data.tar.gz: c5f3c9d7d7ba8b95c0672b6f9dfaa3b8a8bfcb94ecc2de51886f6d8ec0b3449b063e5eaa9e2245aa118c5e9c2e10aed502ea9f84096b729545a8ac687b80173b
data/lib/connection.rb CHANGED
@@ -1,12 +1,15 @@
1
1
  require 'mysql2'
2
2
  # Establish connection to mysql2
3
3
  class Connection
4
- def open(database, host, username, password)
4
+ def open
5
+ # Read the database credentials from local file
6
+ creds = YAML.load_file(File.expand_path('~/.wolas/credentials.yml'))
7
+
5
8
  @connection = Mysql2::Client.new(
6
- :database => database,
7
- :host => host,
8
- :username => username,
9
- :password => password,
9
+ :database => creds['channel_service']['database'],
10
+ :host => creds['channel_service']['host'],
11
+ :username => creds['channel_service']['username'],
12
+ :password => creds['channel_service']['password'],
10
13
  :connect_timeout => 20
11
14
  )
12
15
  end
@@ -1,3 +1,3 @@
1
1
  class WolasChannel
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/wolas_channel.rb CHANGED
@@ -18,19 +18,15 @@ end
18
18
  # This class handles mapping the channel items from and to the database
19
19
  class WolasChannel
20
20
  # Initialize a tenant_id when the channel service is instantiated
21
- def initialize(tenant_id, database, host, username, password)
21
+ def initialize(tenant_id)
22
22
  @tenant_id = tenant_id
23
- @database = database
24
- @host = host
25
- @user = username
26
- @pw = password
27
23
  end
28
24
 
29
25
  # This method allows a tenant to add a channel to their tenancy
30
26
  def add_channel(type = 'Not Specified')
31
27
  begin
32
28
  # Connect to the database
33
- connect = Connection.new.open(@database, @host, @user, @pw)
29
+ connect = Connection.new.open
34
30
 
35
31
  insert = "INSERT INTO `channel`.`channels` (`tenant_id`, `type`) VALUES (?, ?)"
36
32
  # This method performs the insert. Mysql2 does not return an object on a successful
@@ -52,7 +48,7 @@ class WolasChannel
52
48
  begin
53
49
  # Connect to the database. Instance variable used to pass the connection to
54
50
  # private methods
55
- @connect = Connection.new.open(@database, @host, @user, @pw)
51
+ @connect = Connection.new.open
56
52
  # Determine if the tenant is able to view this entity based off the
57
53
  # channel and return the type of the entity
58
54
  check = tenant_entity(entity_id)
@@ -73,7 +69,7 @@ class WolasChannel
73
69
  begin
74
70
  # Connect to the database. Instance variable used to pass connection to
75
71
  # private methods
76
- @connect = Connection.new.open(@database, @host, @user, @pw)
72
+ @connect = Connection.new.open
77
73
  # Determine if this channel is valid for the tenant and returns its type
78
74
  type = tenant_channel(channel_id)
79
75
  return nil if type == nil
@@ -108,7 +104,7 @@ class WolasChannel
108
104
  begin
109
105
  # Connect to the database. Instance variable used to pass connection to
110
106
  # private methods
111
- @connect = Connection.new.open(@database, @host, @user, @pw)
107
+ @connect = Connection.new.open
112
108
  # Determine if this channel is valid for the tenant and returns its type
113
109
  type = tenant_channel(channel_id)
114
110
  return nil if type == nil
@@ -146,7 +142,7 @@ class WolasChannel
146
142
  begin
147
143
  # Connect to the database. Instance variable used to pass the connection to
148
144
  # private methods
149
- @connect = Connection.new.open(@database, @host, @user, @pw)
145
+ @connect = Connection.new.open
150
146
  # Determine if the tenant is able to view this entity based off the
151
147
  # channel and return the type of the entity
152
148
  type = tenant_channel(channel_id)
@@ -221,7 +217,7 @@ class WolasChannel
221
217
  begin
222
218
  # Connect to the database. Instance variable used to pass connection to
223
219
  # private methods
224
- @connect = Connection.new.open(@database, @host, @user, @pw)
220
+ @connect = Connection.new.open
225
221
  # Determine if the tenant has access to all channels requested
226
222
  channel_ids.each do |channel_id|
227
223
  tenant_channel(channel_id)
@@ -287,7 +283,7 @@ class WolasChannel
287
283
  begin
288
284
  # Connect to the database. Instance variable used to pass connection to
289
285
  # private methods
290
- @connect = Connection.new.open(@database, @host, @user, @pw)
286
+ @connect = Connection.new.open
291
287
  # Determine if the tenant has access to the entity requested
292
288
  check = tenant_entity(entity_id)
293
289
 
@@ -338,7 +334,7 @@ class WolasChannel
338
334
  begin
339
335
  # Connect to the database. Instance variable used to pass connection to
340
336
  # private methods
341
- @connect = Connection.new.open(@database, @host, @user, @pw)
337
+ @connect = Connection.new.open
342
338
  # Determine if the tenant has access to the entity requested
343
339
  tenant_entity(entity_id)
344
340
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolas_channel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - WOLAS
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2015-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,8 +99,6 @@ files:
99
99
  - lib/connection.rb
100
100
  - lib/wolas_channel.rb
101
101
  - lib/wolas_channel/version.rb
102
- - wolas_channel-0.1.4.gem
103
- - wolas_channel-0.1.5.gem
104
102
  - wolas_channel.gemspec
105
103
  homepage: https://bitbucket.org/wolas-revolution/srvc-channel
106
104
  licenses: []
Binary file
Binary file