fittings 0.2.0 → 0.2.1

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: 3d284c9153aca2da7768369111eece8dba1689fa
4
- data.tar.gz: 32ceeb38ef5c2ddc8c2878f4c49ea3383de0118d
3
+ metadata.gz: 439b5a8be43662c47cd5addf374576c13630cfad
4
+ data.tar.gz: 94ace6db002ecde0f67d447ce682ef01d638a8e8
5
5
  SHA512:
6
- metadata.gz: a20d5db9cdc38c55707b843860eae271c47d211ff1220a2c043e8780965c3e3c3dc35de1c358614aaf587b3caddb541e2f8eba130994f0326c87bda4838911a9
7
- data.tar.gz: e2a67f2e123d73f37ecacb303d9a451bca42fef4c7325cbb8c7233c0dbe35532e589943fdac110d88f394bd9c04e86a3c961891dd8782508756f4a941240a47b
6
+ metadata.gz: a8f492235d7a68d4fd2a648b7d788546eabb478b3b4048a15237fa08fe59b9c2df9dbcc904b052257e36345b6f2e95b5d4846107c1e514801ea828d8c31be7a0
7
+ data.tar.gz: d571940258d9359e2c1fa68f6aaccade7ad1563c32244c4f73458ba4428387a8b9852dba31789226e6728f9e846a2d74ac91385b13c0e22fdd6d76790034c842
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ coverage
2
+ html
3
+ pkg
4
+ .idea
5
+ .rvmrc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.1
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.7
4
+ - 2.3.4
5
+ - 2.4.1
6
+ - ruby-head
7
+ before_install:
8
+ - gem install bundler
@@ -0,0 +1,6 @@
1
+ # Code of Conduct
2
+
3
+ We are committed to keeping our community open and inclusive.
4
+
5
+ **Our Code of Conduct can be found here**:
6
+ http://opensource.stitchfix.com/code-of-conduct.html
data/Gemfile.lock CHANGED
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fittings (0.2.0)
4
+ fittings (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.3)
10
10
  rake (12.1.0)
11
+ rdoc (5.1.0)
11
12
  rspec (3.6.0)
12
13
  rspec-core (~> 3.6.0)
13
14
  rspec-expectations (~> 3.6.0)
@@ -28,6 +29,7 @@ PLATFORMS
28
29
  DEPENDENCIES
29
30
  fittings!
30
31
  rake
32
+ rdoc
31
33
  rspec
32
34
 
33
35
  BUNDLED WITH
data/README.rdoc CHANGED
@@ -1,4 +1,23 @@
1
- = Application Settings Manager
1
+ = fittings
2
+
3
+ This is a fork of ModCloth's mc-settings gem which has gone unmaintained and has deprection warnings. This modernizes that and will be maintained.
4
+
5
+ == Install
6
+
7
+ Add to your +Gemfile+:
8
+
9
+ gem "fittings"
10
+
11
+ For Rails, create +config/settings/default.yml+ as well as +config/settings/environments/{development,testing,production}.yml+.
12
+
13
+ Then, in +config/environment.rb+, before the call to +initialize!+:
14
+
15
+ Setting.load(path: "#{Rails.root}/config/settings",
16
+ files: ["default.yml", "environments/#{Rails.env}.yml"])
17
+
18
+ === Why is it +Setting+?
19
+
20
+ This is a fork of the mc-settings gem that is intended to be backwards-compatible.
2
21
 
3
22
  == Summary
4
23
 
data/Rakefile CHANGED
@@ -1,14 +1,23 @@
1
- require 'bundler/gem_tasks'
2
- require 'rubygems/package_task'
3
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubygems/package_task"
4
+ require "rdoc/task"
4
5
 
5
- $: << File.join(File.dirname(__FILE__),'lib')
6
+ $: << File.join(File.dirname(__FILE__),"lib")
6
7
 
7
8
  include Rake::DSL
8
9
 
9
- gemspec = eval(File.read('fittings.gemspec'))
10
+ gemspec = eval(File.read("fittings.gemspec"))
11
+
10
12
  Gem::PackageTask.new(gemspec) {}
13
+
11
14
  RSpec::Core::RakeTask.new(:spec)
12
15
  Bundler::GemHelper.install_tasks
13
16
 
17
+ RDoc::Task.new do |rdoc|
18
+ rdoc.main = "README.rdoc"
19
+ rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
20
+ end
21
+
22
+
14
23
  task :default => :spec
data/bin/rake ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rspec' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require "pathname"
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
data/fittings.gemspec CHANGED
@@ -1,13 +1,7 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
1
  Gem::Specification.new do |s|
7
2
  s.name = "fittings"
8
- s.version = "0.2.0"
3
+ s.version = "0.2.1"
9
4
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
5
  s.authors = ["Edwin Cruz", "Colin Shield"]
12
6
  s.date = %q{2011-09-06}
13
7
  s.description = %q{implement custom keys independently of environment}
@@ -16,35 +10,18 @@ Gem::Specification.new do |s|
16
10
  "LICENSE.txt",
17
11
  "README.rdoc"
18
12
  ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/mc-settings.rb",
28
- "lib/setting.rb",
29
- "fittings.gemspec",
30
- "spec/fixtures/joes-colors.yml",
31
- "spec/fixtures/sample.yml",
32
- "spec/fixtures/shipping.yml",
33
- "spec/mc_settings_spec.rb",
34
- "spec/spec_helper.rb",
35
- "spec/support/settings_helper.rb"
36
- ]
37
13
  s.homepage = %q{http://github.com/stitchfix/fittings}
38
14
  s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
15
  s.summary = %q{Manage settings per environment}
41
- s.test_files = [
42
- "spec/mc_settings_spec.rb",
43
- "spec/spec_helper.rb",
44
- "spec/support/settings_helper.rb"
45
- ]
16
+ s.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ s.bindir = "exe"
20
+ s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
46
22
 
47
23
  s.add_development_dependency "rspec"
48
24
  s.add_development_dependency "rake"
25
+ s.add_development_dependency "rdoc"
49
26
  end
50
27
 
data/lib/fittings.rb ADDED
@@ -0,0 +1 @@
1
+ require_relative "mc-settings"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fittings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edwin Cruz
8
8
  - Colin Shield
9
9
  autorequire:
10
- bindir: bin
10
+ bindir: exe
11
11
  cert_chain: []
12
12
  date: 2011-09-06 00:00:00.000000000 Z
13
13
  dependencies:
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rdoc
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  description: implement custom keys independently of environment
43
57
  email: eng@stitchfix.com
44
58
  executables: []
@@ -47,22 +61,21 @@ extra_rdoc_files:
47
61
  - LICENSE.txt
48
62
  - README.rdoc
49
63
  files:
50
- - ".document"
64
+ - ".gitignore"
65
+ - ".ruby-version"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
51
68
  - Gemfile
52
69
  - Gemfile.lock
53
70
  - LICENSE.txt
54
71
  - README.rdoc
55
72
  - Rakefile
56
- - VERSION
73
+ - bin/rake
74
+ - bin/rspec
57
75
  - fittings.gemspec
76
+ - lib/fittings.rb
58
77
  - lib/mc-settings.rb
59
78
  - lib/setting.rb
60
- - spec/fixtures/joes-colors.yml
61
- - spec/fixtures/sample.yml
62
- - spec/fixtures/shipping.yml
63
- - spec/mc_settings_spec.rb
64
- - spec/spec_helper.rb
65
- - spec/support/settings_helper.rb
66
79
  homepage: http://github.com/stitchfix/fittings
67
80
  licenses:
68
81
  - MIT
@@ -87,7 +100,4 @@ rubygems_version: 2.6.13
87
100
  signing_key:
88
101
  specification_version: 4
89
102
  summary: Manage settings per environment
90
- test_files:
91
- - spec/mc_settings_spec.rb
92
- - spec/spec_helper.rb
93
- - spec/support/settings_helper.rb
103
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6
@@ -1,9 +0,0 @@
1
- color:
2
- pants:
3
- favorite:
4
- :orange
5
- shorts:
6
- favorite:
7
- :white
8
- default:
9
- :stripes
@@ -1,35 +0,0 @@
1
- tax:
2
- default: 0.0
3
- california: 7.5
4
- states:
5
- default:
6
- - 'CA'
7
- - 'WA'
8
- - 'NY'
9
- ship_to:
10
- - 'CA'
11
- - 'NY'
12
- boolean_true:
13
- default: 4
14
- boolean_false:
15
- default: false
16
- negated: true
17
- color:
18
- default:
19
- :grey
20
- pants:
21
- default:
22
- :purple
23
- favorite:
24
- :red
25
- school:
26
- :blue
27
- shorts:
28
- default:
29
- :plaid
30
- favorite:
31
- :yellow
32
- school:
33
- :black
34
-
35
-
@@ -1,36 +0,0 @@
1
- shipping_config:
2
- default: <%= 'Defaulted' %>
3
- domestic:
4
- service: MyService
5
- countries:
6
- - "US"
7
- non_shippable_regions:
8
- - "US-AS"
9
- - "US-GU"
10
- - "US-MP"
11
- - "US-PR"
12
- - "US-UM"
13
- - "US-VI"
14
- - "US-AF"
15
- - "US-AA"
16
- - "US-AC"
17
- - "US-AE"
18
- - "US-AM"
19
- - "US-AP"
20
- - "US-FM"
21
- - "US-PW"
22
- - "US-MH"
23
- international:
24
- service: Foo
25
- countries:
26
- - "GU"
27
- - "VI"
28
- - "AS"
29
- - "MP"
30
- - "UM"
31
- - "FR"
32
- - "GR"
33
- - "RU"
34
- shipping_carrier: Bar
35
- number: <%= 5%>
36
- stringified: <%= nil || "stringified"%>
@@ -1,160 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- describe Setting do
3
- subject { Setting }
4
-
5
- context "Test with stubs" do
6
- before :each do
7
- stub_setting_files
8
- subject.reload(
9
- :path => "config/settings",
10
- :files => ["default.yml", "environments/test.yml"],
11
- :local => true)
12
- end
13
-
14
- it 'should return test specific values' do
15
- expect(subject.available_settings['one']).to eq("test")
16
- expect(subject.one).to eq("test")
17
- expect(subject['one']).to eq("test")
18
- end
19
-
20
- it "should handle custom values overriding everything else" do
21
- expect(subject.seven).to eq("seven from custom")
22
- end
23
-
24
- it "handles multiple values" do
25
- expect(subject[:six]).to eq({"default"=>"default value", "extra"=>"recursively overriden", "deep_level"=>{"value"=>"even deeper level"}})
26
- expect(subject.available_settings['six']['default']).to eq("default value")
27
- expect(subject.seven).to eq("seven from custom")
28
- end
29
-
30
- it "handles default key" do
31
- expect(subject.default_setting).to eq(1)
32
- expect(subject['seven']['default']).to eq("seven from custom")
33
- end
34
-
35
- it "should handle empty strings" do
36
- expect(subject.empty).to eq("")
37
- end
38
-
39
- it "should responds to ? mark" do
40
- expect(subject.autologin?).to eq(true)
41
- end
42
-
43
- it "should returns false correctly" do
44
- expect(subject.flag_false).to be(false)
45
- end
46
-
47
- it "should merge keys recursivelly" do
48
- expect(subject.six(:extra)).to eq("recursively overriden")
49
- expect(subject.six(:deep_level, :value)).to eq("even deeper level")
50
- end
51
-
52
- it "should create keys if it does not exist" do
53
- expect(subject.test_specific).to eq("exist")
54
- end
55
-
56
- context "working with arrays" do
57
- it "should replace the whole array instead of appending new values" do
58
- expect(subject.nested_array).to eq(['first', 'four', 'five'])
59
- end
60
- end
61
- end
62
-
63
- context "When running with threads" do
64
- it "should keep its values" do
65
- 3.times do |time|
66
- Thread.new {
67
- subject.available_settings.shoud_not be_empty
68
- }
69
- end
70
- end
71
- end
72
-
73
- context "Test from file" do
74
- before :each do
75
- subject.reload(
76
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
77
- :files => ['sample.yml']
78
- )
79
- end
80
-
81
- it 'should support [] syntax' do
82
- expect(subject['tax']['default']).to eq(0.0)
83
- expect(subject['tax']).to eq({ 'default' => 0.0, 'california' => 7.5 })
84
- end
85
-
86
- it 'should support method invocation syntax' do
87
- expect(subject.tax).to eq(0.0)
88
-
89
- expect(subject.tax(:default)).to eq(subject.tax)
90
- expect(subject.tax('default')).to eq(subject.tax)
91
- expect(subject.tax(:california)).to eq(7.5)
92
-
93
- expect(subject.states).to eq(['CA', 'WA', 'NY'])
94
- expect(subject.states(:default)).to eq(subject.states)
95
- expect(subject.states(:ship_to)).to eq(['CA', 'NY'])
96
- end
97
-
98
- it 'should correctly process Boolean values' do
99
- expect(subject.boolean_true?).to be(true)
100
- expect(subject.boolean_true).to eq(4)
101
- expect(subject.boolean_false?).to be(false)
102
- expect(subject.boolean_false?(:default)).to be(false)
103
- expect(subject.boolean_false?(:negated)).to be(true)
104
- end
105
- end
106
-
107
- context "Test recursive overrides and nested hashes" do
108
- before :each do
109
- subject.reload(
110
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
111
- :files => ['sample.yml', 'joes-colors.yml']
112
- )
113
- end
114
-
115
- it 'should override colors with Joes and support nested hashes' do
116
- expect(subject.color).to eq(:grey) # default
117
- expect(subject.color(:pants)).to eq(:purple) # default
118
-
119
- expect(subject.color(:pants, :school)).to eq(:blue) # in sample
120
- expect(subject.color(:pants, :favorite)).to eq(:orange) # joes override
121
-
122
- expect(subject.color(:shorts, :school)).to eq(:black) # in sample
123
- expect(subject.color(:shorts, :favorite)).to eq(:white) # joe's override
124
-
125
- expect(subject.color(:shorts)).to eq(:stripes) # joe's override of default
126
- end
127
-
128
- end
129
- context "Complex nested configs" do
130
- before :each do
131
- subject.reload(
132
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
133
- :files => ['shipping.yml']
134
- )
135
- end
136
- it "should build correct tree with arrays and default values " do
137
- expect(subject.shipping_config).to eq("Defaulted")
138
- expect(subject.shipping_config(:domestic, :non_shippable_regions).first).to eq("US-AS")
139
- expect(subject.shipping_config(:international, :service)).to eq('Foo')
140
- expect(subject.shipping_config(:international, :countries).size).to be > 0
141
- expect(subject.shipping_config(:international, :shipping_carrier)).to eq('Bar')
142
- #backward compatibility:
143
- expect(subject.shipping_config(:domestic)['non_shippable_regions'].size).to be > 0
144
- end
145
- end
146
-
147
- context "Ruby code inside yml file" do
148
- before :each do
149
- subject.reload(
150
- :path => File.join(File.dirname(__FILE__)) + '/fixtures',
151
- :files => ['shipping.yml']
152
- )
153
- end
154
- it "should interpret ruby code and put correct values" do
155
- expect(subject.shipping_config).to eq("Defaulted")
156
- subject.number == 5
157
- subject.stringified == "stringified"
158
- end
159
- end
160
- end
data/spec/spec_helper.rb DELETED
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'mc-settings'
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
@@ -1,59 +0,0 @@
1
- def stub_setting_files
2
- defaults = <<-CONTENT
3
- one: default
4
- two:
5
- three: 3
6
- four: "4"
7
- five: "default string"
8
- default_setting: 1
9
- six:
10
- default: "default value"
11
- extra: "extra"
12
- deep_level:
13
- value: "even deeper level"
14
- seven:
15
- default: "seven"
16
- empty:
17
- default:
18
- autologin:
19
- format: int
20
- default: 7
21
- flag_false:
22
- default: false
23
- nested_array:
24
- - first
25
- - second
26
- - third
27
- CONTENT
28
- test = <<-CONTENT
29
- one: test
30
- two:
31
- three: 5
32
- four: "6"
33
- five: "test string"
34
- six:
35
- extra: "recursively overriden"
36
- test_specific: "exist"
37
- nested_array:
38
- - first
39
- - four
40
- - five
41
- CONTENT
42
-
43
- empty = <<-CONTENT
44
- CONTENT
45
-
46
- custom = <<-CONTENT
47
- seven:
48
- default: "seven from custom"
49
- CONTENT
50
-
51
- allow(File).to receive(:exists?).and_return(true)
52
- allow(File).to receive(:exists?).with("config/settings/environments/development.yml").and_return(false)
53
- allow(IO).to receive(:read).with("config/settings/default.yml").and_return(defaults)
54
- allow(IO).to receive(:read).with("config/settings/environments/test.yml").and_return(test)
55
- allow(IO).to receive(:read).with("config/settings/local/custom.yml").and_return(custom)
56
- allow(IO).to receive(:read).with("config/settings/local/empty.yml").and_return(empty)
57
-
58
- allow(Dir).to receive(:glob).and_return(["config/settings/local/empty.yml", "config/settings/local/custom.yml"])
59
- end