rails-etcs 0.0.0 → 0.1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c931873937bb5e6d230bd181eba6382c34b2e430
4
- data.tar.gz: b8f016cfb9b88f5ff1d5a0b194295e660ebbbba4
2
+ SHA256:
3
+ metadata.gz: 4f5e1ab5d87f3089d00586c7c88630f8203e07f8149c88c6d1f3f70d42c13b6f
4
+ data.tar.gz: 0c1b6db67d1b14ff02b8167c7cb8f993b67e64d3064f8e00a35328a875062996
5
5
  SHA512:
6
- metadata.gz: 5921cdd680e47dfde236cc28629d9c94dafcb0d339fd3a44b95e68981667be2587f8674cece318f9422aff1f1931d45d659adadd390dec83b155ffa7039407dc
7
- data.tar.gz: cc59f4b4d58b4d9f0f82620286a20c8733b771f187264d0bb4263ba2b4c4264e675a0e65f2ab9acdb49f90d62a5b4a6b51dba58c1306ba456ffccdad8df1c08c
6
+ metadata.gz: a8e5a731e0e82c10ce5a77a42b570e3329fcdb0812307edaacbd98f5295867b1089e94bef37b6cdc394e188250422520227cf9914e98e74b62c126802b72e362
7
+ data.tar.gz: c0eec6f6a6da21a082830ec15a5eb36206cb4da9f5fc352f6d8e6e400a9af313b4c2729f93a18215261984ec2f85aa3c5901454a3373b483f4fa6d02a53914b9
data/.gitignore CHANGED
@@ -1,9 +1,15 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
9
+
10
+ # rspec failure tracking
11
+ /spec/examples.txt
12
+
13
+ # Bundler lockfiles
14
+ /Gemfile.lock
15
+ /gemfiles/*.lock
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,59 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/*.rb'
4
+ TargetRubyVersion: 2.3
5
+
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - 'spec/**/*_spec.rb'
10
+
11
+ Metrics/LineLength:
12
+ Exclude:
13
+ - 'spec/**/*_spec.rb'
14
+
15
+
16
+ Layout/AlignParameters:
17
+ EnforcedStyle: with_fixed_indentation
18
+
19
+ Layout/SpaceInsideHashLiteralBraces:
20
+ EnforcedStyle: no_space
21
+
22
+ Layout/SpaceInsideBlockBraces:
23
+ EnforcedStyle: space
24
+ EnforcedStyleForEmptyBraces: no_space
25
+ SpaceBeforeBlockParameters: false
26
+
27
+ Layout/CaseIndentation:
28
+ EnforcedStyle: end
29
+ SupportedStyles:
30
+ - case
31
+ - end
32
+ IndentOneStep: true
33
+
34
+
35
+ Naming/FileName:
36
+ Exclude:
37
+ - Appraisals
38
+ - Gemfile
39
+ - Rakefile
40
+ - rails-etcs.gemspec
41
+
42
+
43
+ Style/BracesAroundHashParameters:
44
+ EnforcedStyle: context_dependent
45
+
46
+ Style/RaiseArgs:
47
+ EnforcedStyle: compact
48
+
49
+ Style/Documentation:
50
+ Enabled: false
51
+
52
+ Style/SignalException:
53
+ EnforcedStyle: only_raise
54
+
55
+ Style/ClassAndModuleChildren:
56
+ Enabled: false
57
+
58
+ Style/TrivialAccessors:
59
+ AllowPredicates: true
data/.travis.yml CHANGED
@@ -1,6 +1,16 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.3.1
4
+ - 2.5.0
5
+ - 2.4.3
6
+ - 2.3.6
7
+ gemfiles:
8
+ - gemfiles/rails_4.2.gemfile
9
+ - gemfiles/rails_5.0.gemfile
10
+ - gemfiles/rails_5.1.gemfile
11
+ - gemfiles/rails_5.2.gemfile
12
+ - gemfiles/rails_head.gemfile
5
13
  before_install:
6
- - gem install bundler -v 1.13.3
14
+ - gem install bundler -v 1.16.1
15
+ script:
16
+ - bundle exec rspec
data/Appraisals ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ appraise 'rails-4.2' do
4
+ gem 'rails', '~> 4.2.0'
5
+ end
6
+
7
+ appraise 'rails-5.0' do
8
+ gem 'rails', '~> 5.0.0'
9
+ end
10
+
11
+ appraise 'rails-5.1' do
12
+ gem 'rails', '~> 5.1.0'
13
+ end
14
+
15
+ appraise 'rails-5.2' do
16
+ gem 'rails', '~> 5.2.0.rc'
17
+ end
18
+
19
+ appraise 'rails-head' do
20
+ gem 'rails', github: 'rails/rails'
21
+ end
data/Gemfile CHANGED
@@ -1,7 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
5
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
6
+
3
7
  # Specify your gem's dependencies in rails-etcs.gemspec
4
8
  gemspec
5
9
 
10
+ gem 'appraisal'
6
11
  gem 'rake'
7
12
  gem 'rspec', '~> 3.0'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jan Graichen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rails::ETCS
1
+ # Rails::Etcs
2
2
 
3
3
  A collection of patches and alternatives for Rails core classes.
4
4
 
@@ -8,5 +8,46 @@ If you cannot install the gem alone you should better not use it.
8
8
 
9
9
  ## Usage
10
10
 
11
- TODO: Write usage instructions here
11
+ ### Rails::Etcs::Application
12
12
 
13
+ `Rails::Etcs::Application` can be used instead of `Rails::Application` when creating your own applications:
14
+
15
+ ```ruby
16
+ # my-app/config/application.rb
17
+
18
+ module MyApp
19
+ class Application < ::Rails::Etcs::Application
20
+ self.ident = 'my-app'
21
+ end
22
+ end
23
+ ```
24
+
25
+ `Rails::Etcs::Application` is tuned in several ways:
26
+
27
+ #### Application Paths
28
+
29
+ Most paths have been adjusted to allow moving static files such as `config/application.rb`, `config/routes.rb`, `config/environment.rb`, `config/initializers`, `config/environments`, `config/locales` to `app/`. You can therefore move all application code into the application directory. `config/boot.rb` could be moved manually.
30
+
31
+ This way it is possible to have an application where `config/` really only contains (end-user) configuration files.
32
+
33
+ #### XDG Base Directory Specification
34
+
35
+ The application will further respect the XDG Base Directory Specification for looking up configuration files and temp directories.
36
+
37
+ You can customize the application name via `self.ident = 'my-app'`. Configuration file by search e.g. in:
38
+
39
+ * `~/.config/my-app`
40
+ * `/etc/xdg/my-app`
41
+ * `/etc/my-app`
42
+ * `config`
43
+
44
+ `#config_for` has been patched to search for the first existing configuration file in any existing configuration directory.
45
+
46
+ The same lookup is applied for `database.yml`, `secrets.yml`, and additional
47
+ initializers and environments files.
48
+
49
+ ## License
50
+
51
+ Rails::Etcs (c) 2018 Jan Graichen
52
+
53
+ It is free software, and may be redistributed under the terms of The MIT License (MIT).
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "rails/etcs"
4
+ require 'bundler/setup'
5
+ require 'rails/etcs'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "rails/etcs"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
- IRB.start
14
+ require 'irb'
15
+ IRB.start(__FILE__)
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rails", "~> 4.2.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rails", "~> 5.0.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rails", "~> 5.1.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rails", "~> 5.2.0.rc"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rake"
7
+ gem "rspec", "~> 3.0"
8
+ gem "rails", git: "https://github.com/rails/rails"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xdg'
4
+
5
+ class Rails::Etcs::Application
6
+ class Configuration < ::Rails::Application::Configuration
7
+ attr_reader :ident
8
+
9
+ def initialize(root, ident)
10
+ super root
11
+
12
+ @ident = ident
13
+ end
14
+
15
+ # rubocop:disable AbcSize
16
+ # rubocop:disable MethodLength
17
+ def paths
18
+ @paths ||= begin
19
+ paths = super
20
+
21
+ paths.add 'lib', eager_load: true
22
+ paths.add 'tmp', with: xdg_cache.flatten
23
+ paths.add 'config', with: xdg_config.flatten
24
+
25
+ paths.add 'config/environment',
26
+ with: %w[app/environment.rb config/environment.rb]
27
+
28
+ paths.add 'config/initializers',
29
+ with: %w[app/initializers],
30
+ glob: '**/*.rb'
31
+
32
+ paths.add 'config/locales',
33
+ with: %w[app/locales config/locales],
34
+ glob: '*.{rb,yml}'
35
+
36
+ paths.add 'config/routes.rb',
37
+ with: %w[app/routes.rb config/routes.rb]
38
+
39
+ paths.add 'config/environments',
40
+ with: %w[app/environments],
41
+ glob: "#{Rails.env}.rb"
42
+
43
+ paths.add 'config/database',
44
+ with: paths['config'].each.map {|d| File.join(d, 'database.yml') }
45
+
46
+ paths.add 'config/secrets',
47
+ with: paths['config'],
48
+ glob: 'secrets.yml{,.enc}'
49
+
50
+ paths['config'].to_ary.reverse.each do |dir|
51
+ paths['config/initializers'] << File.join(dir, 'initializers')
52
+ paths['config/environments'] << File.join(dir, 'environments')
53
+ end
54
+
55
+ paths
56
+ end
57
+ end
58
+ # rubocop:enable all
59
+
60
+ private
61
+
62
+ def xdg_config
63
+ [XDG['CONFIG'].with_subdirectory(ident), 'config'].flatten
64
+ end
65
+
66
+ def xdg_cache
67
+ [XDG['CACHE'].with_subdirectory(ident).to_ary.reverse, 'tmp'].flatten
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rails::Etcs
4
+ class Application < ::Rails::Application
5
+ require 'rails/etcs/application/configuration'
6
+
7
+ def config
8
+ @config ||= begin
9
+ root = self.class.find_root self.class.called_from
10
+
11
+ Application::Configuration.new root, self.class.ident
12
+ end
13
+ end
14
+
15
+ # rubocop:disable AbcSize
16
+ # rubocop:disable MethodLength
17
+ def config_for(name, env: Rails.env)
18
+ files = paths['config']
19
+ .expanded
20
+ .map {|d| Pathname.new(d).join("#{name}.yml") }
21
+
22
+ yaml = files.find(&:exist?)
23
+
24
+ unless yaml
25
+ raise "Could not load configuration. No such file - #{files.join(', ')}"
26
+ end
27
+
28
+ require 'erb'
29
+
30
+ data = YAML.safe_load(ERB.new(yaml.read).result) || {}
31
+ data.fetch(env, {})
32
+ rescue Psych::SyntaxError => e
33
+ raise <<~ERR
34
+ YAML syntax error occurred while parsing #{yaml}.
35
+ Please note that YAML must be consistently indented using spaces.
36
+ Tabs are not allowed.
37
+ Error: #{e.message}
38
+ ERR
39
+ end
40
+ # rubocop:enable all
41
+
42
+ class << self
43
+ attr_writer :ident
44
+
45
+ def ident
46
+ @ident ||= begin
47
+ name.underscore.gsub(/[^A-z]+/, '-').gsub(/-application$/, '')
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rails
2
- module ETCS
4
+ module Etcs
3
5
  module VERSION
4
6
  MAJOR = 0
5
- MINOR = 0
7
+ MINOR = 1
6
8
  PATCH = 0
7
- STAGE = nil
9
+ STAGE = :beta1
8
10
 
9
11
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.').freeze
10
12
 
data/lib/rails/etcs.rb CHANGED
@@ -1,7 +1,10 @@
1
- require "rails/etcs/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails'
4
+ require 'rails/etcs/version'
2
5
 
3
6
  module Rails
4
- module ETCS
5
- # Your code goes here...
7
+ module Etcs
8
+ require 'rails/etcs/application'
6
9
  end
7
10
  end
data/rails-etcs.gemspec CHANGED
@@ -1,25 +1,30 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'rails/etcs/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = 'rails-etcs'
8
- spec.version = Rails::ETCS::VERSION
9
+ spec.version = Rails::Etcs::VERSION
9
10
  spec.authors = ['Jan Graichen']
10
11
  spec.email = ['jgraichen@altimos.de']
11
12
 
12
- spec.summary = %q{Collection of patches and alternatives for Rails core classes}
13
- spec.description = %q{Collection of patches and alternatives for Rails core classes}
13
+ spec.summary = 'Collection of patches and alternatives for Rails core classes'
14
+ spec.description = 'Collection of patches and alternatives for Rails core classes'
14
15
  spec.homepage = 'https://github.com/jgraichen/rails-etcs'
15
- spec.license = 'LGPLv3'
16
+ spec.license = 'MIT'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
22
24
  spec.require_paths = ['lib']
23
25
 
26
+ spec.add_dependency 'xdg', '~> 2.2.3'
27
+ spec.add_dependency 'railties', '>= 4.2.0'
28
+
24
29
  spec.add_development_dependency 'bundler', '~> 1.13'
25
30
  end
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-etcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xdg
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.2.0
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: bundler
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -33,18 +61,29 @@ extra_rdoc_files: []
33
61
  files:
34
62
  - ".gitignore"
35
63
  - ".rspec"
64
+ - ".rubocop.yml"
36
65
  - ".travis.yml"
66
+ - Appraisals
37
67
  - Gemfile
68
+ - LICENSE
38
69
  - README.md
39
70
  - Rakefile
40
71
  - bin/console
41
72
  - bin/setup
73
+ - gemfiles/.bundle/config
74
+ - gemfiles/rails_4.2.gemfile
75
+ - gemfiles/rails_5.0.gemfile
76
+ - gemfiles/rails_5.1.gemfile
77
+ - gemfiles/rails_5.2.gemfile
78
+ - gemfiles/rails_head.gemfile
42
79
  - lib/rails/etcs.rb
80
+ - lib/rails/etcs/application.rb
81
+ - lib/rails/etcs/application/configuration.rb
43
82
  - lib/rails/etcs/version.rb
44
83
  - rails-etcs.gemspec
45
84
  homepage: https://github.com/jgraichen/rails-etcs
46
85
  licenses:
47
- - LGPLv3
86
+ - MIT
48
87
  metadata: {}
49
88
  post_install_message:
50
89
  rdoc_options: []
@@ -57,12 +96,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
96
  version: '0'
58
97
  required_rubygems_version: !ruby/object:Gem::Requirement
59
98
  requirements:
60
- - - ">="
99
+ - - ">"
61
100
  - !ruby/object:Gem::Version
62
- version: '0'
101
+ version: 1.3.1
63
102
  requirements: []
64
103
  rubyforge_project:
65
- rubygems_version: 2.6.7
104
+ rubygems_version: 2.7.3
66
105
  signing_key:
67
106
  specification_version: 4
68
107
  summary: Collection of patches and alternatives for Rails core classes