singlettings 0.0.2

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.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +73 -0
  6. data/Rakefile +15 -0
  7. data/lib/singlettings.rb +5 -0
  8. data/lib/singlettings/base.rb +108 -0
  9. data/lib/singlettings/exceptions.rb +5 -0
  10. data/lib/singlettings/rails.rb +56 -0
  11. data/lib/singlettings/version.rb +3 -0
  12. data/myapp/.gitignore +16 -0
  13. data/myapp/Gemfile +47 -0
  14. data/myapp/README.rdoc +28 -0
  15. data/myapp/Rakefile +6 -0
  16. data/myapp/app/assets/images/.keep +0 -0
  17. data/myapp/app/assets/javascripts/application.js +16 -0
  18. data/myapp/app/assets/stylesheets/application.css +13 -0
  19. data/myapp/app/controllers/application_controller.rb +5 -0
  20. data/myapp/app/controllers/concerns/.keep +0 -0
  21. data/myapp/app/helpers/application_helper.rb +2 -0
  22. data/myapp/app/mailers/.keep +0 -0
  23. data/myapp/app/models/.keep +0 -0
  24. data/myapp/app/models/concerns/.keep +0 -0
  25. data/myapp/app/views/layouts/application.html.erb +14 -0
  26. data/myapp/bin/bundle +3 -0
  27. data/myapp/bin/rails +4 -0
  28. data/myapp/bin/rake +4 -0
  29. data/myapp/config.ru +4 -0
  30. data/myapp/config/application.rb +28 -0
  31. data/myapp/config/boot.rb +4 -0
  32. data/myapp/config/database.yml +25 -0
  33. data/myapp/config/environment.rb +5 -0
  34. data/myapp/config/environments/development.rb +29 -0
  35. data/myapp/config/environments/production.rb +80 -0
  36. data/myapp/config/environments/test.rb +36 -0
  37. data/myapp/config/initializers/backtrace_silencers.rb +7 -0
  38. data/myapp/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/myapp/config/initializers/inflections.rb +16 -0
  40. data/myapp/config/initializers/mime_types.rb +5 -0
  41. data/myapp/config/initializers/secret_token.rb +12 -0
  42. data/myapp/config/initializers/session_store.rb +3 -0
  43. data/myapp/config/initializers/wrap_parameters.rb +14 -0
  44. data/myapp/config/locales/en.yml +23 -0
  45. data/myapp/config/routes.rb +56 -0
  46. data/myapp/config/singletting.yml +25 -0
  47. data/myapp/config/singlettings/setting.yml +25 -0
  48. data/myapp/config/yetting.yml +25 -0
  49. data/myapp/db/seeds.rb +7 -0
  50. data/myapp/lib/assets/.keep +0 -0
  51. data/myapp/lib/tasks/.keep +0 -0
  52. data/myapp/log/.keep +0 -0
  53. data/myapp/public/404.html +58 -0
  54. data/myapp/public/422.html +58 -0
  55. data/myapp/public/500.html +57 -0
  56. data/myapp/public/favicon.ico +0 -0
  57. data/myapp/public/robots.txt +5 -0
  58. data/myapp/vendor/assets/javascripts/.keep +0 -0
  59. data/myapp/vendor/assets/stylesheets/.keep +0 -0
  60. data/singlettings.gemspec +24 -0
  61. data/spec/sample.yml +39 -0
  62. data/spec/singletting_spec.rb +79 -0
  63. data/spec/spec_helper.rb +11 -0
  64. metadata +151 -0
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
data/myapp/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
data/myapp/log/.keep ADDED
File without changes
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
File without changes
File without changes
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'singlettings/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "singlettings"
8
+ spec.version = Singlettings::VERSION
9
+ spec.authors = ["Jingkai He"]
10
+ spec.email = ["jaxihe@gmail.com"]
11
+ spec.description = %q{A simple YML to singleton class solution for ruby programming language.}
12
+ spec.summary = %q{A simple YML to singleton class solution for ruby programming language.}
13
+ spec.homepage = "https://github.com/mycolorway/singlettings"
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_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/spec/sample.yml ADDED
@@ -0,0 +1,39 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MYSQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
+ development:
12
+ adapter: mysql2
13
+ encoding: utf8
14
+ database: minutes_development
15
+ pool: 5
16
+ username: root
17
+ password:
18
+ socket: /tmp/mysql.sock
19
+
20
+ # Warning: The database defined as "test" will be erased and
21
+ # re-generated from your development database when you run "rake".
22
+ # Do not set this db to the same as development or production.
23
+ test:
24
+ adapter: mysql2
25
+ encoding: utf8
26
+ database: minutes_test
27
+ pool: 5
28
+ username: root
29
+ password:
30
+ socket: /tmp/mysql.sock
31
+
32
+ production:
33
+ adapter: mysql2
34
+ encoding: utf8
35
+ database: minutes_production
36
+ pool: 5
37
+ username: root
38
+ password:
39
+ socket: /tmp/mysql.sock
@@ -0,0 +1,79 @@
1
+ require "spec_helper"
2
+
3
+ describe :Singlettings do
4
+
5
+ describe "class level singletting" do
6
+ before do
7
+ class DevelopmentSample < Singlettings::Base
8
+ source "spec/sample.yml"
9
+ ns :development
10
+ end
11
+
12
+ class Sample < Singlettings::Base
13
+ source "spec/sample.yml"
14
+ end
15
+ end
16
+ context "method test" do
17
+ it "one level sample" do
18
+ DevelopmentSample.adapter.should == "mysql2"
19
+ DevelopmentSample.encoding.should == "utf8"
20
+ DevelopmentSample.password.should == nil
21
+ end
22
+
23
+ it "multiple level sample" do
24
+ Sample.development.adapter.should == "mysql2"
25
+ Sample.development.encoding.should == "utf8"
26
+ Sample.development.password.should == nil
27
+ end
28
+ end
29
+
30
+ context "method test" do
31
+ it "one level sample" do
32
+ DevelopmentSample["adapter"].should == "mysql2"
33
+ DevelopmentSample["encoding"].should == "utf8"
34
+ DevelopmentSample["password"].should == nil
35
+ end
36
+
37
+ it "multiple level sample" do
38
+ Sample[:development][:adapter].should == "mysql2"
39
+ Sample[:development][:encoding].should == "utf8"
40
+ Sample[:development][:password].should == nil
41
+ end
42
+ end
43
+ end
44
+
45
+ describe "instance level singlettings" do
46
+ before do
47
+ @development_settings = Singlettings::Base.new "spec/sample.yml", :development
48
+ @settings = Singlettings::Base.new "spec/sample.yml"
49
+ end
50
+
51
+ context "method test" do
52
+ it "one level sample" do
53
+ @development_settings.adapter.should == "mysql2"
54
+ @development_settings.encoding.should == "utf8"
55
+ @development_settings.password.should == nil
56
+ end
57
+
58
+ it "multiple level sample" do
59
+ @settings.development.adapter.should == "mysql2"
60
+ @settings.development.encoding.should == "utf8"
61
+ @settings.development.password.should == nil
62
+ end
63
+ end
64
+
65
+ context "method test" do
66
+ it "one level sample" do
67
+ @development_settings["adapter"].should == "mysql2"
68
+ @development_settings["encoding"].should == "utf8"
69
+ @development_settings["password"].should == nil
70
+ end
71
+
72
+ it "multiple level sample" do
73
+ @settings[:development][:adapter].should == "mysql2"
74
+ @settings[:development][:encoding].should == "utf8"
75
+ @settings[:development][:password].should == nil
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,11 @@
1
+ require "singlettings"
2
+
3
+ RSpec.configure do |config|
4
+ config.treat_symbols_as_metadata_keys_with_true_values = true
5
+ config.run_all_when_everything_filtered = true
6
+ config.filter_run :focus
7
+
8
+ config.order = 'random'
9
+
10
+ config.color_enabled = true
11
+ end