app_config_rails 0.0.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.
- data/.gitignore +8 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +99 -0
- data/MIT-LICENSE +20 -0
- data/README.md +17 -0
- data/Rakefile +27 -0
- data/app_config_rails.gemspec +28 -0
- data/lib/app_config_rails/railtie.rb +9 -0
- data/lib/app_config_rails/version.rb +3 -0
- data/lib/app_config_rails.rb +55 -0
- data/lib/tasks/app_config_rails_tasks.rake +4 -0
- metadata +111 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
# Declare your gem's dependencies in app_config_rails.gemspec.
|
4
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
5
|
+
# development dependencies will be added by default to the :development group.
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
# jquery-rails is used by the dummy application
|
9
|
+
gem "jquery-rails"
|
10
|
+
|
11
|
+
# Declare any dependencies that are still in development here instead of in
|
12
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
13
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
14
|
+
# your gem to rubygems.org.
|
15
|
+
|
16
|
+
# To use debugger
|
17
|
+
# gem 'debugger'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
app_config_rails (0.0.1)
|
5
|
+
app_config (~> 2.3.1)
|
6
|
+
rails (~> 3.2.13)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (3.2.14)
|
12
|
+
actionpack (= 3.2.14)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (3.2.14)
|
15
|
+
activemodel (= 3.2.14)
|
16
|
+
activesupport (= 3.2.14)
|
17
|
+
builder (~> 3.0.0)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
journey (~> 1.0.4)
|
20
|
+
rack (~> 1.4.5)
|
21
|
+
rack-cache (~> 1.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.2.1)
|
24
|
+
activemodel (3.2.14)
|
25
|
+
activesupport (= 3.2.14)
|
26
|
+
builder (~> 3.0.0)
|
27
|
+
activerecord (3.2.14)
|
28
|
+
activemodel (= 3.2.14)
|
29
|
+
activesupport (= 3.2.14)
|
30
|
+
arel (~> 3.0.2)
|
31
|
+
tzinfo (~> 0.3.29)
|
32
|
+
activeresource (3.2.14)
|
33
|
+
activemodel (= 3.2.14)
|
34
|
+
activesupport (= 3.2.14)
|
35
|
+
activesupport (3.2.14)
|
36
|
+
i18n (~> 0.6, >= 0.6.4)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
app_config (2.3.1)
|
39
|
+
arel (3.0.2)
|
40
|
+
builder (3.0.4)
|
41
|
+
erubis (2.7.0)
|
42
|
+
hike (1.2.3)
|
43
|
+
i18n (0.6.4)
|
44
|
+
journey (1.0.4)
|
45
|
+
jquery-rails (3.0.4)
|
46
|
+
railties (>= 3.0, < 5.0)
|
47
|
+
thor (>= 0.14, < 2.0)
|
48
|
+
json (1.8.0)
|
49
|
+
mail (2.5.4)
|
50
|
+
mime-types (~> 1.16)
|
51
|
+
treetop (~> 1.4.8)
|
52
|
+
mime-types (1.23)
|
53
|
+
multi_json (1.7.7)
|
54
|
+
polyglot (0.3.3)
|
55
|
+
rack (1.4.5)
|
56
|
+
rack-cache (1.2)
|
57
|
+
rack (>= 0.4)
|
58
|
+
rack-ssl (1.3.3)
|
59
|
+
rack
|
60
|
+
rack-test (0.6.2)
|
61
|
+
rack (>= 1.0)
|
62
|
+
rails (3.2.14)
|
63
|
+
actionmailer (= 3.2.14)
|
64
|
+
actionpack (= 3.2.14)
|
65
|
+
activerecord (= 3.2.14)
|
66
|
+
activeresource (= 3.2.14)
|
67
|
+
activesupport (= 3.2.14)
|
68
|
+
bundler (~> 1.0)
|
69
|
+
railties (= 3.2.14)
|
70
|
+
railties (3.2.14)
|
71
|
+
actionpack (= 3.2.14)
|
72
|
+
activesupport (= 3.2.14)
|
73
|
+
rack-ssl (~> 1.3.2)
|
74
|
+
rake (>= 0.8.7)
|
75
|
+
rdoc (~> 3.4)
|
76
|
+
thor (>= 0.14.6, < 2.0)
|
77
|
+
rake (10.1.0)
|
78
|
+
rdoc (3.12.2)
|
79
|
+
json (~> 1.4)
|
80
|
+
sprockets (2.2.2)
|
81
|
+
hike (~> 1.2)
|
82
|
+
multi_json (~> 1.0)
|
83
|
+
rack (~> 1.0)
|
84
|
+
tilt (~> 1.1, != 1.3.0)
|
85
|
+
sqlite3 (1.3.7)
|
86
|
+
thor (0.18.1)
|
87
|
+
tilt (1.4.1)
|
88
|
+
treetop (1.4.14)
|
89
|
+
polyglot
|
90
|
+
polyglot (>= 0.3.1)
|
91
|
+
tzinfo (0.3.37)
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
app_config_rails!
|
98
|
+
jquery-rails
|
99
|
+
sqlite3
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 Dale Campbell <oshuma@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# AppConfigRails
|
2
|
+
|
3
|
+
Rails plugin for the [AppConfig](https://github.com/Oshuma/app_config) library.
|
4
|
+
|
5
|
+
**Note**: Currently, only ActiveRecord is supported.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add the `app_config_rails` gem to your Rails `Gemfile`.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'app_config_rails'
|
13
|
+
```
|
14
|
+
|
15
|
+
And that should be all there is to it. This plugin was designed to detect the
|
16
|
+
current Rails environment's database settings and use those. See the [AppConfig](https://github.com/Oshuma/app_config)
|
17
|
+
documentation storage specific setup instructions.
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'AppConfigRails'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "app_config_rails/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "app_config_rails"
|
9
|
+
s.version = AppConfigRails::VERSION
|
10
|
+
|
11
|
+
s.authors = ["Dale Campbell"]
|
12
|
+
s.email = ["oshuma@gmail.com"]
|
13
|
+
s.homepage = "https://github.com/Oshuma/app_config_rails"
|
14
|
+
|
15
|
+
s.summary = "Rails plugin for the AppConfig gem."
|
16
|
+
s.description = "Rails plugin for the AppConfig gem."
|
17
|
+
|
18
|
+
s.license = 'MIT'
|
19
|
+
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
+
|
24
|
+
s.add_dependency "app_config", "~> 2.3.1"
|
25
|
+
s.add_dependency "rails", "~> 3.2.13"
|
26
|
+
|
27
|
+
s.add_development_dependency "sqlite3"
|
28
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'app_config'
|
2
|
+
require 'app_config_rails/railtie'
|
3
|
+
|
4
|
+
module AppConfigRails
|
5
|
+
|
6
|
+
def self.load_app_config!
|
7
|
+
case db_config[:adapter]
|
8
|
+
when 'mysql'
|
9
|
+
configure_mysql
|
10
|
+
when 'postgresql'
|
11
|
+
configure_postgres
|
12
|
+
when 'sqlite3'
|
13
|
+
configure_sqlite
|
14
|
+
else
|
15
|
+
raise RuntimeError, "AppConfigRails: Database adapter '#{db_config[:adapter]}' not supported; please create an issue if you would like it implemented."
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def self.db_config
|
22
|
+
@@__db_config ||= ActiveRecord::Base.connection_config
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: Finish this once AppConfig supports MySQL.
|
26
|
+
def self.configure_mysql
|
27
|
+
raise RuntimeError, 'AppConfigRails: MySQL support not yet implemented.'
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure_postgres
|
31
|
+
postgres = {
|
32
|
+
host: db_config[:host],
|
33
|
+
dbname: db_config[:database],
|
34
|
+
table: 'app_config'
|
35
|
+
}
|
36
|
+
|
37
|
+
postgres[:port] = db_config[:port] if db_config[:port]
|
38
|
+
|
39
|
+
postgres[:user] = db_config[:username] if db_config[:username]
|
40
|
+
postgres[:password] = db_config[:password] if db_config[:password]
|
41
|
+
|
42
|
+
# Catch PG::Error in case the app_config table (migration) hasn't been created.
|
43
|
+
begin
|
44
|
+
AppConfig.setup!(postgres: postgres)
|
45
|
+
rescue ::PG::Error => e
|
46
|
+
Rails.logger.warn "WARN: AppConfig table '#{postgres[:table]}' does not exist; migration has not been run."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# TODO: Finish this once AppConfig supports SQLite.
|
51
|
+
def self.configure_sqlite
|
52
|
+
raise RuntimeError, 'AppConfigRails: SQLite support not yet implemented.'
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: app_config_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dale Campbell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-07-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: app_config
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.3.1
|
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: 2.3.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.2.13
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.13
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sqlite3
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
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
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Rails plugin for the AppConfig gem.
|
63
|
+
email:
|
64
|
+
- oshuma@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- MIT-LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- app_config_rails.gemspec
|
76
|
+
- lib/app_config_rails.rb
|
77
|
+
- lib/app_config_rails/railtie.rb
|
78
|
+
- lib/app_config_rails/version.rb
|
79
|
+
- lib/tasks/app_config_rails_tasks.rake
|
80
|
+
homepage: https://github.com/Oshuma/app_config_rails
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
hash: -1561182594017206352
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
hash: -1561182594017206352
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.8.23
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: Rails plugin for the AppConfig gem.
|
111
|
+
test_files: []
|