racym 0.0.3

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: 015c4b746f3afed79a884ee073162807fefef5e7
4
+ data.tar.gz: 8689e16140ca000072994c81ab91f48600f567f6
5
+ SHA512:
6
+ metadata.gz: bff780f9aa2ed6e4b0fe823e86c8428f0f0e6cea6c1875e581b4502c3161040db46bd321e9cf05fff84032af4950e34b2a270e1ab1189856a5e5c291473ff336
7
+ data.tar.gz: 19720870effa911b6cfc7f3a928f480a7ebf6a687a8ab254ee8c30e63e91ae730ccc569fb595a6c0b5eb0840cec8ee33cb78f2ad70c6d8902dbff4982ecbeb40
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.4
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in racym.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 UserTesting.com
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,35 @@
1
+ [![Build Status](https://travis-ci.org/usertesting/racym.png)](https://travis-ci.org/usertesting/racym)
2
+
3
+ [![Code Climate](https://codeclimate.com/github/usertesting/racym.png)](https://codeclimate.com/github/usertesting/racym)
4
+
5
+ # Racym
6
+
7
+ Rails Application Configuration for Yield Main (RACYM)
8
+
9
+ Racym is used as a shortcut to rails configuration.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'racym'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install racym
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/lib/racym.rb ADDED
@@ -0,0 +1,50 @@
1
+ require "racym/version"
2
+
3
+ def racym(*args)
4
+ value = args.map(&:to_s).join('.').split('.').inject(Rails.application.config) { |r, m| r = r.send(m); r }
5
+
6
+ if value.is_a?(Proc)
7
+ value.call
8
+ else
9
+ value
10
+ end
11
+ end
12
+
13
+ def racym_set(*args)
14
+ Rails.application.config.racym_cache ||= {}
15
+
16
+ after = args.pop
17
+ before = racym(*args)
18
+ token = args.map(&:to_s).join('.').split('.').join('.')
19
+
20
+ if Rails.application.config.racym_cache[token]
21
+ before = Rails.application.config.racym_cache[token].first
22
+ end
23
+
24
+ config_methods = token.split('.')
25
+
26
+ config_methods.inject([config_methods.last, Rails.application.config]) do |last_and_rails_config, current_method|
27
+ last, rails_config = last_and_rails_config
28
+
29
+ rails_config = if last == current_method
30
+ rails_config.send("#{current_method}=", after)
31
+ else
32
+ rails_config = rails_config.send(current_method)
33
+ end
34
+
35
+ [last, rails_config]
36
+ end
37
+
38
+ Rails.application.config.racym_cache[token] = [before, after]
39
+ end
40
+
41
+ def racym_undo!
42
+ return unless Rails.application.config.racym_cache.is_a? Hash
43
+
44
+ Rails.application.config.racym_cache.each do |key, changes|
45
+ config_methods = key.split('.')
46
+ racym_set(key, changes.first)
47
+ end
48
+
49
+ Rails.application.config.racym_cache = nil
50
+ end
@@ -0,0 +1,3 @@
1
+ module Racym
2
+ VERSION = "0.0.3"
3
+ end
data/racym.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'racym/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "racym"
8
+ spec.version = Racym::VERSION
9
+ spec.authors = ["David Raffauf"]
10
+ spec.email = ["david@usertesting.com"]
11
+ spec.description = %q{Rails Application Configuration for Yield Main}
12
+ spec.summary = %q{Used as a shortcut to rails configuration.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_dependency "railties", ">= 3.2.13","< 5.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,5 @@
1
+ require_relative '../../lib/racym'
2
+
3
+ describe "racym" do
4
+ pending
5
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: racym
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - David Raffauf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.13
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.13
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.3'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: Rails Application Configuration for Yield Main
76
+ email:
77
+ - david@usertesting.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".ruby-version"
84
+ - ".travis.yml"
85
+ - Gemfile
86
+ - LICENSE.txt
87
+ - README.md
88
+ - Rakefile
89
+ - lib/racym.rb
90
+ - lib/racym/version.rb
91
+ - racym.gemspec
92
+ - spec/lib/racym_spec.rb
93
+ homepage: ''
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.8
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Used as a shortcut to rails configuration.
117
+ test_files:
118
+ - spec/lib/racym_spec.rb
119
+ has_rdoc: