super_stack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f47a8fbf6c7a9a3c1a3c2be8a7d41a9e3d49909
4
+ data.tar.gz: 15a5385e65bb378577021bdb576b6bf22978fe71
5
+ SHA512:
6
+ metadata.gz: 9223673ee43028e4911e861047c01f22e56e448f2bc0dfc31998821e5958001771f5a3f5ccdcd824570b88a13549500307fff59fb226c9af8ef28c1343611747
7
+ data.tar.gz: a6ed81f4d44069b47b85e597bfb014667611e788d04739643f248c6905112bc6a179ae1db25ff0771ebecd5ff23c726ace93631aa66e9d2205e2471d892241c3
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .idea
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in super_stack.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Laurent B.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # SuperStack
2
+ [![Build Status](https://travis-ci.org/lbriais/super_stack.svg)](https://travis-ci.org/lbriais/super_stack)
3
+ [![Gem Version](https://badge.fury.io/rb/super_stack.svg)](http://badge.fury.io/rb/super_stack)
4
+
5
+ The purpose of this gem is to provide a simple way to manage the merge of different
6
+ hashes (layers).
7
+ It offers different merge policies.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'super_stack'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install super_stack
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( http://github.com/<my-github-username>/super_stack/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ module SuperStack
2
+ class Layer < Hash
3
+
4
+ include LayerWrapper
5
+
6
+ end
7
+ end
@@ -0,0 +1,56 @@
1
+ require 'yaml'
2
+
3
+ module SuperStack
4
+ module LayerWrapper
5
+
6
+ include Comparable
7
+
8
+ DEFAULT_LAYER_NAME = 'Unknown layer'
9
+
10
+ attr_reader :file_name, :priority
11
+
12
+ def priority=(priority)
13
+ raise 'invalid priority' unless priority.is_a? Numeric
14
+ @priority = priority
15
+ end
16
+
17
+ def name=(name)
18
+ @name = name.to_s
19
+ end
20
+
21
+ def name
22
+ @name || DEFAULT_LAYER_NAME
23
+ end
24
+
25
+ def load(file_name, type = :yaml)
26
+ raise 'Invalid file' unless File.readable? file_name
27
+ load_from_yaml file_name if type == :yaml
28
+ end
29
+
30
+ def has_file?
31
+ !@file_name.nil?
32
+ end
33
+
34
+ def <=>(other)
35
+ # For priorities, the smallest the higher
36
+ self.priority <=> other.priority
37
+ end
38
+
39
+ def inspect
40
+ "name: #{name}, priority: #{priority}, #{super}"
41
+ end
42
+
43
+ private
44
+
45
+ def load_from_yaml(file_name)
46
+ begin
47
+ self.replace Hash[YAML::load(File.open(file_name)).map { |k, v| [k.to_sym, v] }]
48
+
49
+ rescue NoMethodError
50
+ # Empty file...
51
+ end
52
+ @file_name = file_name
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,57 @@
1
+ module SuperStack
2
+ class Manager
3
+
4
+ DEFAULT_INTERVAL = 10
5
+
6
+ attr_reader :layers, :merge_policy
7
+
8
+ def [](filter=nil)
9
+ raise 'Manager not ready (no merge policy specified)' unless ready?
10
+ layers = to_a
11
+ return [] if layers.empty?
12
+ return layers[0] if layers.count == 1
13
+ first_layer = layers.shift
14
+ res = layers.inject(first_layer) do |stack, layer|
15
+ merge_policy.merge stack, layer
16
+ end
17
+ if filter.nil?
18
+ res
19
+ else
20
+ res[filter]
21
+ end
22
+ end
23
+
24
+ def initialize
25
+ @layers = {}
26
+ end
27
+
28
+ def to_a
29
+ layers.values.sort
30
+ end
31
+
32
+ def add_layer(layer)
33
+ raise 'Layer should have a name' unless layer.respond_to? :name
34
+ raise 'Layer already existing' if layers.keys.include? layer.name
35
+ layer.priority = get_unused_priority if layer.priority.nil?
36
+ layers[layer.name] = layer
37
+ end
38
+
39
+ def merge_policy=(policy)
40
+ raise "Invalid merge policy #{policy}" unless SuperStack::MergePolicies.list.include? policy
41
+ @merge_policy = policy
42
+ end
43
+
44
+ def ready?
45
+ !@merge_policy.nil?
46
+ end
47
+
48
+ private
49
+
50
+ def get_unused_priority
51
+ ordered = self.to_a
52
+ return DEFAULT_INTERVAL if ordered.empty?
53
+ ordered.last.priority + DEFAULT_INTERVAL
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ require 'deep_merge/core'
2
+
3
+ module SuperStack
4
+ module MergePolicies
5
+ module FullMergePolicy
6
+
7
+ module DeepMergeWrapper
8
+ def deep_merge!(source)
9
+ DeepMerge::deep_merge!(source, self, {})
10
+ end
11
+ end
12
+
13
+ def self.merge(h1, h2)
14
+ deep_cloned_source = Marshal::load(Marshal.dump(h1))
15
+ deep_cloned_source.extend DeepMergeWrapper
16
+ deep_cloned_source.deep_merge! h2
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module SuperStack
2
+ module MergePolicies
3
+ module OverridePolicy
4
+
5
+ def self.merge(h1, h2)
6
+ h2
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module SuperStack
2
+ module MergePolicies
3
+ module StandardMergePolicy
4
+
5
+ def self.merge(h1, h2)
6
+ h1.merge h2
7
+ end
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'super_stack/merge_policies/override_policy'
2
+ require 'super_stack/merge_policies/standard_merge_policy'
3
+ require 'super_stack/merge_policies/full_merge_policy'
4
+
5
+
6
+ module SuperStack
7
+ module MergePolicies
8
+
9
+ def self.list
10
+ constants.map(&:to_s).grep(/Policy$/).map{|policy_name| const_get policy_name}
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module SuperStack
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,9 @@
1
+ require 'super_stack/version'
2
+ require 'super_stack/merge_policies'
3
+ require 'super_stack/layer_wrapper'
4
+ require 'super_stack/layer'
5
+ require 'super_stack/manager'
6
+
7
+ module SuperStack
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe SuperStack::Layer do
4
+
5
+ subject {SuperStack::Layer.new}
6
+
7
+ it 'has a name' do
8
+ expect(subject.respond_to? :name).to be_truthy
9
+ expect(subject.respond_to? :name=).to be_truthy
10
+ end
11
+
12
+ it 'has a default name' do
13
+ expect(subject.name == subject.class.const_get('DEFAULT_LAYER_NAME')).to be_truthy
14
+ end
15
+
16
+ it 'should allow to change the name' do
17
+ subject.name = 'foo'
18
+ expect(subject.name == 'foo').to be_truthy
19
+ end
20
+
21
+ it 'should have a priority' do
22
+ expect(subject.respond_to? :priority).to be_truthy
23
+ expect(subject.respond_to? :priority=).to be_truthy
24
+ end
25
+
26
+ it 'should be comparable by priority' do
27
+ other = SuperStack::Layer.new
28
+ subject.priority = 1
29
+ other.priority = 2
30
+ expect( subject < other).to be_truthy
31
+ end
32
+
33
+ context 'when loaded from a YAML file' do
34
+
35
+ def file_from_type(file_type)
36
+ File.expand_path("../../test/layer_content_type_#{file_type}.yml", __FILE__)
37
+ end
38
+
39
+ %w(empty standard containing_an_array well_formatted).each do |file_type|
40
+ it "should allow #{file_type} content type" do
41
+ expect {
42
+ subject.load file_from_type file_type
43
+ }.not_to raise_error
44
+ expect( subject.has_file?).to be_truthy
45
+ end
46
+ end
47
+
48
+
49
+ end
50
+
51
+
52
+
53
+
54
+
55
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe SuperStack::Manager do
4
+ subject {SuperStack::Manager.new}
5
+
6
+
7
+ it 'should contain layers' do
8
+ expect( subject.respond_to? :layers).to be_truthy
9
+ end
10
+
11
+ it 'should present layers ordered by priority' do
12
+ l1 = SuperStack::Layer.new
13
+ l1.priority = 1
14
+ l1.name = :pipo
15
+ l2 = SuperStack::Layer.new
16
+ l2.priority = 2
17
+ l2.name = :bimbo
18
+
19
+ subject.add_layer l2
20
+ subject.add_layer l1
21
+
22
+ expect(subject.to_a[0] == l1).to be_truthy
23
+ expect(subject.to_a[1] == l2).to be_truthy
24
+ end
25
+
26
+ it 'should have a policy' do
27
+ expect( subject.respond_to? :merge_policy).to be_truthy
28
+ end
29
+
30
+ it 'should not be ready unless a merge policy is set' do
31
+ expect( subject.ready?).to be_falsey
32
+ subject.merge_policy = SuperStack::MergePolicies.list[0]
33
+ expect( subject.ready?).to be_truthy
34
+ end
35
+
36
+ it 'should not accept stupid policies' do
37
+ expect {subject.merge_policy = :foo}.to raise_error
38
+ end
39
+
40
+ context 'when ready' do
41
+
42
+ def file_from_layer(layer_number)
43
+ File.expand_path("../../test/stacked_layer_#{layer_number}.yml", __FILE__)
44
+ end
45
+
46
+ (1..4).each do |layer_number|
47
+ let("layer#{layer_number}".to_sym) {
48
+ file_name = file_from_layer layer_number
49
+ layer = SuperStack::Layer.new
50
+ layer.load file_name
51
+ layer.name = "layer#{layer_number}"
52
+ layer
53
+ }
54
+ end
55
+
56
+ SuperStack::MergePolicies.list.each do |policy|
57
+ it "should provide a merged view of the layers according to the merge policy: #{policy}" do
58
+ subject.add_layer layer1
59
+ subject.add_layer layer2
60
+ subject.add_layer layer3
61
+ subject.add_layer layer4
62
+ subject.merge_policy = policy
63
+ expect(subject[].is_a? Hash).to be_truthy
64
+ expect(subject[:layer] == 'four').to be_truthy
65
+ end
66
+ end
67
+
68
+
69
+
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe SuperStack::MergePolicies do
4
+
5
+ subject {SuperStack::MergePolicies}
6
+
7
+ def file_from_layer(layer_number)
8
+ File.expand_path("../../test/stacked_layer_#{layer_number}.yml", __FILE__)
9
+ end
10
+
11
+ (1..4).each do |layer_number|
12
+ let("layer#{layer_number}".to_sym) {
13
+ file_name = file_from_layer layer_number
14
+ Hash[YAML::load(File.open(file_name)).map { |k, v| [k.to_sym, v] }]
15
+ }
16
+ end
17
+
18
+
19
+ it 'should have merge policies' do
20
+ policies = subject.list
21
+ expect( policies.is_a? Array).to be_truthy
22
+ expect( policies.count == 3).to be_truthy
23
+ end
24
+
25
+ context 'when dealing with override policy' do
26
+
27
+ subject {SuperStack::MergePolicies::OverridePolicy}
28
+
29
+ it 'should retain only the second hash' do
30
+ merged_hashs = subject.merge(layer1, layer2)
31
+ expect( merged_hashs == layer2).to be_truthy
32
+ expect( merged_hashs[:layer] == 'two').to be_truthy
33
+ end
34
+
35
+ end
36
+
37
+ context 'when dealing with standard merge policy' do
38
+
39
+ subject {SuperStack::MergePolicies::StandardMergePolicy}
40
+
41
+ it 'should be merged at first level' do
42
+ merged_hashs = subject.merge(layer1, layer2)
43
+ expect( merged_hashs[:layer] == 'two').to be_truthy
44
+ expect( merged_hashs[:from_layer_1]['stupid-data'] == 'stupid in one').to be_truthy
45
+ expect( merged_hashs[:from_layer_2]['stupid-data'] == 'stupid in two').to be_truthy
46
+ expect( merged_hashs[:'to-be-merged'] == layer2[:'to-be-merged']).to be_truthy
47
+ end
48
+
49
+ end
50
+
51
+ context 'when dealing with full merge policy' do
52
+
53
+ subject {SuperStack::MergePolicies::FullMergePolicy}
54
+
55
+ it 'should be merged at all levels' do
56
+ merged_hashs = subject.merge(layer1, layer2)
57
+ expect( merged_hashs[:layer] == 'two').to be_truthy
58
+ expect( merged_hashs[:from_layer_1]['stupid-data'] == 'stupid in one').to be_truthy
59
+ expect( merged_hashs[:from_layer_2]['stupid-data'] == 'stupid in two').to be_truthy
60
+ expect( merged_hashs[:'to-be-merged'] == layer2[:'to-be-merged']).to be_falsey
61
+
62
+ expect( merged_hashs[:'to-be-merged']['name'] == 'from layer 2').to be_truthy
63
+ expect( merged_hashs[:'to-be-merged']['my-array'].count == layer1[:'to-be-merged']['my-array'].count + layer2[:'to-be-merged']['my-array'].count).to be_truthy
64
+ # The hashes have 2 keys in common, and bring a new one each, leading to 4.
65
+ expect( merged_hashs[:'to-be-merged']['my-hash'].keys.count == 4).to be_truthy
66
+
67
+ end
68
+
69
+ end
70
+
71
+ end
@@ -0,0 +1,92 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ # The `.rspec` file also contains a few flags that are not defaults but that
14
+ # users commonly want.
15
+ #
16
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+
18
+ require 'super_stack'
19
+
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+ # The settings below are suggested to provide a good initial experience
45
+ # with RSpec, but feel free to customize to your heart's content.
46
+ =begin
47
+ # These two settings work together to allow you to limit a spec run
48
+ # to individual examples or groups you care about by tagging them with
49
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
50
+ # get run.
51
+ config.filter_run :focus
52
+ config.run_all_when_everything_filtered = true
53
+
54
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
58
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
59
+ config.disable_monkey_patching!
60
+
61
+ # This setting enables warnings. It's recommended, but in some cases may
62
+ # be too noisy due to issues in dependencies.
63
+ config.warnings = true
64
+
65
+ # Many RSpec users commonly either run the entire suite or an individual
66
+ # file, and it's useful to allow more verbose output when running an
67
+ # individual spec file.
68
+ if config.files_to_run.one?
69
+ # Use the documentation formatter for detailed output,
70
+ # unless a formatter has already been configured
71
+ # (e.g. via a command-line flag).
72
+ config.default_formatter = 'doc'
73
+ end
74
+
75
+ # Print the 10 slowest examples and example groups at the
76
+ # end of the spec run, to help surface which specs are running
77
+ # particularly slow.
78
+ config.profile_examples = 10
79
+
80
+ # Run specs in random order to surface order dependencies. If you find an
81
+ # order dependency and want to debug it, you can fix the order by providing
82
+ # the seed, which is printed after each run.
83
+ # --seed 1234
84
+ config.order = :random
85
+
86
+ # Seed global randomization in this process using the `--seed` CLI option.
87
+ # Setting this allows you to use `--seed` to deterministically reproduce
88
+ # test failures related to randomization by passing the same `--seed` value
89
+ # as the one that triggered the failure.
90
+ Kernel.srand config.seed
91
+ =end
92
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'super_stack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'super_stack'
8
+ spec.version = SuperStack::VERSION
9
+ spec.authors = ['Laurent B.']
10
+ spec.email = ['lbnetid+gh@gmail.com']
11
+ spec.summary = %q{Provides a way to manage ordered layers.}
12
+ spec.description = %q{Provides a way to manage ordered layers.}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_development_dependency 'pry'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+
26
+ spec.add_dependency 'deep_merge'
27
+
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ - One
2
+ - two
3
+ - three
File without changes
@@ -0,0 +1,9 @@
1
+ stupid-stuff: oh yeah
2
+
3
+ an-array:
4
+ - item 1
5
+ - item 2
6
+ - a-hash:
7
+ pipo: bimbo
8
+ bozo: the clown
9
+
@@ -0,0 +1,9 @@
1
+ ---
2
+ an-array:
3
+ - "item 1"
4
+ - "item 2"
5
+ -
6
+ a-hash: ~
7
+ bozo: "the clown"
8
+ pipo: bimbo
9
+ stupid-stuff: "oh yeah"
@@ -0,0 +1,19 @@
1
+ layer: one
2
+
3
+ from_layer_1:
4
+ stupid-data: stupid in one
5
+
6
+ to-be-merged:
7
+ name: from layer 1
8
+ my-prop: property one
9
+ my-array:
10
+ - item 1 from array 1
11
+ - item 2 from array 1
12
+ my-hash:
13
+ common-property: from one
14
+ speficif_1: Specific from one
15
+ a-sub-array:
16
+ - another item 1 from sub array 1
17
+ - another item 2 from sub array 1
18
+ - another item 3 from sub array 1
19
+
@@ -0,0 +1,19 @@
1
+ layer: two
2
+
3
+ from_layer_2:
4
+ stupid-data: stupid in two
5
+
6
+ to-be-merged:
7
+ name: from layer 2
8
+ my-prop: property two
9
+ my-array:
10
+ - item 1 from array 2
11
+ - item 2 from array 2
12
+ my-hash:
13
+ common-property: from two
14
+ speficif_2: Specific from two
15
+ a-sub-array:
16
+ - another item 1 from sub array 2
17
+ - another item 2 from sub array 2
18
+ - another item 3 from sub array 2
19
+
@@ -0,0 +1,19 @@
1
+ layer: three
2
+
3
+ from_layer_3:
4
+ stupid-data: stupid in three
5
+
6
+ to-be-merged:
7
+ name: from layer 3
8
+ my-prop: property three
9
+ my-array:
10
+ - item 1 from array 3
11
+ - item 2 from array 3
12
+ my-hash:
13
+ common-property: from three
14
+ speficif_3: Specific from three
15
+ a-sub-array:
16
+ - another item 1 from sub array 3
17
+ - another item 3 from sub array 3
18
+ - another item 3 from sub array 3
19
+
@@ -0,0 +1,19 @@
1
+ layer: four
2
+
3
+ from_layer_4:
4
+ stupid-data: stupid in four
5
+
6
+ to-be-merged:
7
+ name: from layer 4
8
+ my-prop: property four
9
+ my-array:
10
+ - item 1 from array 4
11
+ - item 2 from array 4
12
+ my-hash:
13
+ common-property: from four
14
+ speficif_4: Specific from four
15
+ a-sub-array:
16
+ - another item 1 from sub array 4
17
+ - another item 2 from sub array 4
18
+ - another item 3 from sub array 4
19
+
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: super_stack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Laurent B.
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: deep_merge
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Provides a way to manage ordered layers.
84
+ email:
85
+ - lbnetid+gh@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/super_stack.rb
98
+ - lib/super_stack/layer.rb
99
+ - lib/super_stack/layer_wrapper.rb
100
+ - lib/super_stack/manager.rb
101
+ - lib/super_stack/merge_policies.rb
102
+ - lib/super_stack/merge_policies/full_merge_policy.rb
103
+ - lib/super_stack/merge_policies/override_policy.rb
104
+ - lib/super_stack/merge_policies/standard_merge_policy.rb
105
+ - lib/super_stack/version.rb
106
+ - spec/layer_spec.rb
107
+ - spec/manager_spec.rb
108
+ - spec/merge_policies_spec.rb
109
+ - spec/spec_helper.rb
110
+ - super_stack.gemspec
111
+ - test/layer_content_type_containing_an_array.yml
112
+ - test/layer_content_type_empty.yml
113
+ - test/layer_content_type_standard.yml
114
+ - test/layer_content_type_well_formatted.yml
115
+ - test/stacked_layer_1.yml
116
+ - test/stacked_layer_2.yml
117
+ - test/stacked_layer_3.yml
118
+ - test/stacked_layer_4.yml
119
+ homepage: ''
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.0.0
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Provides a way to manage ordered layers.
143
+ test_files:
144
+ - spec/layer_spec.rb
145
+ - spec/manager_spec.rb
146
+ - spec/merge_policies_spec.rb
147
+ - spec/spec_helper.rb
148
+ - test/layer_content_type_containing_an_array.yml
149
+ - test/layer_content_type_empty.yml
150
+ - test/layer_content_type_standard.yml
151
+ - test/layer_content_type_well_formatted.yml
152
+ - test/stacked_layer_1.yml
153
+ - test/stacked_layer_2.yml
154
+ - test/stacked_layer_3.yml
155
+ - test/stacked_layer_4.yml