Skip to content

Commit e29462f

Browse files
rashidspmikeproeng37
authored andcommitted
Introduces static project config manager (#176)
1 parent f111aa5 commit e29462f

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Copyright 2019, Optimizely and contributors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
module Optimizely
19+
class ProjectConfigManager
20+
# Interface for fetching ProjectConfig instance.
21+
22+
def config; end
23+
end
24+
end
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Copyright 2019, Optimizely and contributors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
require_relative 'project_config_manager'
20+
module Optimizely
21+
class StaticProjectConfigManager < ProjectConfigManager
22+
# Implementation of ProjectConfigManager interface.
23+
attr_reader :config
24+
25+
def initialize(config)
26+
# config - Instance of ProjectConfig
27+
@config = config
28+
end
29+
end
30+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
#
4+
# Copyright 2019, Optimizely and contributors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
require 'spec_helper'
19+
require 'optimizely/config_manager/static_project_config_manager'
20+
describe Optimizely::StaticProjectConfigManager do
21+
describe '#config' do
22+
it 'should return project config instance' do
23+
expect_project_config = Optimizely::ProjectConfig.new(OptimizelySpec::VALID_CONFIG_BODY_JSON, nil, nil)
24+
project_config_manager = Optimizely::StaticProjectConfigManager.new(expect_project_config)
25+
expect(project_config_manager.config).to eq(expect_project_config)
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)