localmotive 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in localmotive.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 The FrontSide
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,57 @@
1
+ # Localmotive: a Rails Engine for local development
2
+
3
+ Very often, we want to override the settings for our application which are contained in source control with our own
4
+ local values. This could be to use our own AWS key, SMTP server, or database url. It is also useful to run a tweaked
5
+ version of your production or staging environment that is mostly faithful to the original but has some extras to make it
6
+ friendlier for local development (like not using a CDN)
7
+
8
+ For these reasons and more, localmotive lets you maintain your own custom per-environment configurations that lie
9
+ outside your main source control without giving up orderliness.
10
+
11
+
12
+ ## Installation
13
+
14
+ Add this to your rails application's development group:
15
+
16
+ group :development do
17
+ gem 'localmotive'
18
+ end
19
+
20
+ ## Usage
21
+
22
+ To get started, run the install command
23
+
24
+ rails generate localmotive
25
+
26
+ This will generate your local config files
27
+
28
+ create .local/config/application.rb
29
+ create .local/config/environments/development.rb
30
+ create .local/config/environments/production.rb
31
+ create .local/config/environments/test.rb
32
+ append .gitignore
33
+
34
+
35
+ This will create a mirror of your rails environment configuration files in the `.local` directory and add it to your
36
+ .gitignore. That way, each developer can locally configure their application to their heart's content without worrying
37
+ about
38
+
39
+ 1. clobbering anybody else's configuration
40
+ 1. accidentally checking in sensitive configuration information to source control
41
+
42
+ The load rules of your local environment shadow those of vanilla rails. So, if you are running in the development
43
+ environment, localmotive will load
44
+
45
+ 1. `.local/config/application.rb`
46
+ 1. `.local/config/environments/development.rb`
47
+
48
+ local configuration files are loaded only after all stock configuration has been run, but before application
49
+ initialization. That way, you can be sure that your settings will take precedence.
50
+
51
+ ## Credits
52
+
53
+ Localmotive was developed at [The FrontSide][1] in order to avoid development papercuts
54
+
55
+ [1]: http://thefrontside.net
56
+
57
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ class LocalmotiveGenerator < ::Rails::Generators::Base
2
+ source_root File.expand_path '../templates', __FILE__
3
+
4
+ def create_local_directory
5
+ template "application.rb.tt", ".local/config/application.rb"
6
+ Dir[Rails.root.join('config/environments/*.rb')].map {|f| File.basename(f, '.rb')}.each do |env|
7
+ @env = env
8
+ template "environment.rb.tt", ".local/config/environments/#{env}.rb"
9
+ end
10
+ end
11
+
12
+ def add_local_directory_to_gitignore
13
+ append_to_file '.gitignore' do
14
+ '/.local'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ <%= Rails.application.class.parent_name %>::Application.configure do |config|
2
+ # put stuff in here that should apply to all environments when running locally
3
+ end
@@ -0,0 +1,3 @@
1
+ <%= Rails.application.class.parent_name %>::Application.configure do |config|
2
+ # these settings will only apply in the <%= @env %> environment when running locally
3
+ end
@@ -0,0 +1,19 @@
1
+ require "localmotive/version"
2
+
3
+ module Localmotive
4
+ class Railtie < ::Rails::Railtie
5
+
6
+ def maybe_load(app, filename)
7
+ path = app.root.join('.local/config', filename)
8
+ if path.exist?
9
+ load path
10
+ end
11
+ end
12
+
13
+ config.before_initialize do |app|
14
+ maybe_load app, "application.rb"
15
+ maybe_load app, "environments/#{Rails.env}.rb"
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Localmotive
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'localmotive/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "localmotive"
8
+ gem.version = Localmotive::VERSION
9
+ gem.authors = ["Charles Lowell"]
10
+ gem.email = ["cowboyd@thefrontside.net"]
11
+ gem.description = %q{a rails engine for local development}
12
+ gem.summary = %q{keep a private set of per-environment configurations for just your machine}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'railties', '~> 3.0'
21
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: localmotive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Charles Lowell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ description: a rails engine for local development
31
+ email:
32
+ - cowboyd@thefrontside.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - lib/generators/localmotive_generator.rb
43
+ - lib/generators/templates/application.rb.tt
44
+ - lib/generators/templates/environment.rb.tt
45
+ - lib/localmotive.rb
46
+ - lib/localmotive/version.rb
47
+ - localmotive.gemspec
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 1.8.24
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: keep a private set of per-environment configurations for just your machine
72
+ test_files: []