catarse_settings_db 0.0.1

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: b36c108217855da398664c3a59c028fc313df67b
4
+ data.tar.gz: f7854ce879ddbae0559be4de10b84494aa0bcb1b
5
+ SHA512:
6
+ metadata.gz: 62bde62f65c46700f280b1d50a6a8c889ee384bbe3bef320cd4d512079397ea1e4213c24e1389435696f053207276f53d1f7de6d4e3ba17b12d510628c42c18e
7
+ data.tar.gz: 496712e6bfd22124b2bf9a77cf63a126934343a5d89de47a6369625e713c4bda6ac6bf296eba3dd7fd20c26877ce4a7aa51854d9cb652349ca08896d653cd3ff
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = CatarseSettingsDb
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'CatarseSettingsDb'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,43 @@
1
+ module CatarseSettingsDb
2
+ class Setting < ActiveRecord::Base
3
+ self.table_name = 'settings'
4
+
5
+ validates_presence_of :name
6
+ class << self
7
+ # This method returns the values of the config simulating a Hash, like:
8
+ # Configuration[:foo]
9
+ # It can also bring Arrays of keys, like:
10
+ # Configuration[:foo, :bar]
11
+ # ... so you can pass it to a method using *.
12
+ # It is memoized, so it will be correctly cached.
13
+ def [] *keys
14
+ if keys.size == 1
15
+ get keys.shift
16
+ else
17
+ keys.map{|key| get key }
18
+ end
19
+ end
20
+ def []= key, value
21
+ set key, value
22
+ end
23
+
24
+ private
25
+ def get key
26
+ Rails.cache.fetch("/configurations/#{key}") do
27
+ find_by_name(key).value rescue nil
28
+ end
29
+ end
30
+
31
+ def set key, value
32
+ begin
33
+ find_by_name(key).update_attribute :value, value
34
+ rescue
35
+ create!(name: key, value: value)
36
+ end
37
+ Rails.cache.write("/configurations/#{key}", value)
38
+ value
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1 @@
1
+ ::CatarseSettings = CatarseSettingsDb::Setting
@@ -0,0 +1,5 @@
1
+ module CatarseSettingsDb
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CatarseSettingsDb
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module CatarseSettingsDb
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'catarse_settings_db/engine'
2
+ module CatarseSettingsDb
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :catarse_settings_db do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: catarse_settings_db
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Antônio Roberto Silva
8
+ - Diogo Biazus
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 4.0.3
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 4.0.3
28
+ - !ruby/object:Gem::Dependency
29
+ name: pg
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec-rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: shoulda
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: database_cleaner
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Provide a Settings class to be used in Catarse that will store all data
85
+ on a table containing key/value pairs.
86
+ email:
87
+ - forevertonny@gmail.com
88
+ - diogob@gmail.com
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - MIT-LICENSE
94
+ - README.rdoc
95
+ - Rakefile
96
+ - app/models/catarse_settings_db/setting.rb
97
+ - config/initializers/catarse_settings_db.rb
98
+ - lib/catarse_settings_db.rb
99
+ - lib/catarse_settings_db/engine.rb
100
+ - lib/catarse_settings_db/version.rb
101
+ - lib/tasks/catarse_settings_db_tasks.rake
102
+ homepage: http://github.com/catarse/catarse_settings_db
103
+ licenses: []
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.0
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Engine to store catarse settings in the database.
125
+ test_files: []