ixtlan-configuration 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -0
- data/lib/ixtlan/configuration/cuba.rb +80 -0
- data/lib/ixtlan/configuration/cuba.rb~ +142 -0
- data/lib/ixtlan/configuration/filter.rb +34 -0
- data/lib/ixtlan/configuration/filter.rb~ +142 -0
- data/lib/ixtlan/configuration/resource.rb +77 -0
- data/lib/ixtlan/configuration/resource.rb~ +57 -0
- data/lib/ixtlan/configuration/serializer.rb +35 -0
- data/lib/ixtlan/configuration.rb +24 -0
- data/lib/ixtlan/configuration.rb~ +3 -0
- data/lib/ixtlan/core.rb~ +3 -0
- data/lib/ixtlan-configuration.rb +21 -0
- data/lib/ixtlan-configuration.rb~ +3 -0
- metadata +79 -0
data/README.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# ixtlan-configuration #
|
2
|
+
|
3
|
+
* [![Build Status](https://secure.travis-ci.org/mkristian/ixtlan-configuration.png)](http://travis-ci.org/mkristian/ixtlan-configuration)
|
4
|
+
* [![Dependency Status](https://gemnasium.com/mkristian/ixtlan-ixtlan-configuration.png)](https://gemnasium.com/mkristian/ixtlan-ixtlan-configuration)
|
5
|
+
* [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mkristian/ixtlan-ixtlan-configuration)
|
6
|
+
|
7
|
+
persistent configuration for the xtlan series. with cuba for composition.
|
8
|
+
|
9
|
+
TODO usage
|
10
|
+
==========
|
11
|
+
|
12
|
+
Contributing
|
13
|
+
------------
|
14
|
+
|
15
|
+
1. Fork it
|
16
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
17
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
18
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
19
|
+
5. Create new Pull Request
|
20
|
+
|
21
|
+
meta-fu
|
22
|
+
-------
|
23
|
+
|
24
|
+
enjoy :)
|
25
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'cuba_api'
|
22
|
+
require 'ixtlan/configuration/resource'
|
23
|
+
require 'ixtlan/configuration/filter'
|
24
|
+
require 'ixtlan/configuration/serializer'
|
25
|
+
|
26
|
+
module Ixtlan
|
27
|
+
module Configuration
|
28
|
+
class Cuba < ::CubaAPI
|
29
|
+
|
30
|
+
define do
|
31
|
+
on get do
|
32
|
+
write Configuration.instance
|
33
|
+
end
|
34
|
+
|
35
|
+
on post do
|
36
|
+
updated_at = keeps( Configuration )[ :updated_at ]
|
37
|
+
config = Configuration.optimistic_get!( updated_at,
|
38
|
+
Configuration.instance.id )
|
39
|
+
config.attributes = params
|
40
|
+
config.modified_by = current_user if config.dirty?
|
41
|
+
config.save
|
42
|
+
write config
|
43
|
+
end
|
44
|
+
|
45
|
+
# on get, :id do |id|
|
46
|
+
# write Configuration.get!( id )
|
47
|
+
# end
|
48
|
+
|
49
|
+
# on get do
|
50
|
+
# write Configuration.all
|
51
|
+
# end
|
52
|
+
|
53
|
+
# on post do
|
54
|
+
# config = new_instance( Configuration )
|
55
|
+
# config.save
|
56
|
+
# write config
|
57
|
+
# end
|
58
|
+
|
59
|
+
# on put, :id do |id|
|
60
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
61
|
+
# config = Configuration.optimistic_get!( updated_at,
|
62
|
+
# id )
|
63
|
+
# config.attributes = params
|
64
|
+
# config.modified_by = current_user if config.dirty?
|
65
|
+
# config.save
|
66
|
+
# write config
|
67
|
+
# end
|
68
|
+
|
69
|
+
# on delete, :id do |id|
|
70
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
71
|
+
# config = Configuration.optimistic_get( updated_at,
|
72
|
+
# id )
|
73
|
+
# config.destroy
|
74
|
+
# head 200
|
75
|
+
# end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'cuba_api'
|
2
|
+
require 'ixtlan/configuration/resource'
|
3
|
+
require 'ixtlan/configuration/serializer'
|
4
|
+
require 'ixtlan/babel/params_filter'
|
5
|
+
class CubaAPI
|
6
|
+
module ResponseStatus
|
7
|
+
def response_status( obj, options = {})
|
8
|
+
if options[:response_status] != false
|
9
|
+
if obj.respond_to?( :errors ) && obj.errors.size > 0
|
10
|
+
res.status = 412 # Precondition Failed
|
11
|
+
obj = obj.errors
|
12
|
+
elsif req.post?
|
13
|
+
res.status = 201 # Created
|
14
|
+
res[ 'Location' ] = env[ 'SCRIPT_NAME' ] + "/#{obj.id}" if obj.respond_to? :id
|
15
|
+
elsif req.delete?
|
16
|
+
res.status = 204 # No Content
|
17
|
+
obj = ''
|
18
|
+
end
|
19
|
+
end
|
20
|
+
obj
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.included( base )
|
24
|
+
base.prepend_aspect :response_status
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module InputFilter
|
29
|
+
|
30
|
+
module ClassMethods
|
31
|
+
def factory
|
32
|
+
@_factory ||= Ixtlan::Babel::Factory.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def new_instance( clazz, context = nil )
|
37
|
+
filter = self.class.factory.new_params_filter( clazz ).use( context )
|
38
|
+
filter.new( parse_request_body )
|
39
|
+
end
|
40
|
+
|
41
|
+
def params( clazz = nil, context = nil )
|
42
|
+
filter_params_and_keeps( clazz, context )
|
43
|
+
@_data[ 0 ] || {}
|
44
|
+
end
|
45
|
+
|
46
|
+
def keeps( clazz = nil, context = nil )
|
47
|
+
filter_params_and_keeps( clazz, context )
|
48
|
+
@_data[ 1 ] || {}
|
49
|
+
end
|
50
|
+
|
51
|
+
def filter_params_and_keeps( clazz, context )
|
52
|
+
if clazz
|
53
|
+
@_data ||=
|
54
|
+
begin
|
55
|
+
filter = self.class.factory.new_filter( clazz ).use( context )
|
56
|
+
filter.filter_it( parse_request_body )
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
private :filter_params_and_keeps
|
61
|
+
|
62
|
+
def parse_request_body
|
63
|
+
if env[ 'CONTENT_TYPE' ] == 'application/json'
|
64
|
+
JSON.parse( req.body.read )
|
65
|
+
else
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
private :parse_request_body
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
CubaAPI.plugin CubaAPI::InputFilter
|
75
|
+
CubaAPI.plugin CubaAPI::ResponseStatus
|
76
|
+
module Ixtlan
|
77
|
+
module Configuration
|
78
|
+
class ConfigurationFilter < Ixtlan::Babel::ParamsFilter
|
79
|
+
|
80
|
+
root 'configuration'
|
81
|
+
|
82
|
+
add_context( :single,
|
83
|
+
:keep => [ :updated_at ],
|
84
|
+
:except => [:id, :created_at, :updated_at, :modified_by_id] )
|
85
|
+
end
|
86
|
+
|
87
|
+
class Cuba < ::CubaAPI
|
88
|
+
|
89
|
+
define do
|
90
|
+
on get do
|
91
|
+
write Configuration.instance
|
92
|
+
end
|
93
|
+
|
94
|
+
on post do
|
95
|
+
updated_at = keeps( Configuration )[ :updated_at ]
|
96
|
+
p keeps
|
97
|
+
puts req.request_method
|
98
|
+
config = Configuration.optimistic_get!( updated_at,
|
99
|
+
Configuration.instance.id )
|
100
|
+
#config = Configuration.instance
|
101
|
+
config.attributes = params
|
102
|
+
config.modified_by = current_user if config.dirty?
|
103
|
+
config.save
|
104
|
+
write config
|
105
|
+
end
|
106
|
+
|
107
|
+
# on get, :id do |id|
|
108
|
+
# write Configuration.get!( id )
|
109
|
+
# end
|
110
|
+
|
111
|
+
# on get do
|
112
|
+
# write Configuration.all
|
113
|
+
# end
|
114
|
+
|
115
|
+
# on post do
|
116
|
+
# config = new_instance( Configuration )
|
117
|
+
# config.save
|
118
|
+
# write config
|
119
|
+
# end
|
120
|
+
|
121
|
+
# on put, :id do |id|
|
122
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
123
|
+
# config = Configuration.optimistic_get!( updated_at,
|
124
|
+
# id )
|
125
|
+
# config.attributes = params
|
126
|
+
# config.modified_by = current_user if config.dirty?
|
127
|
+
# config.save
|
128
|
+
# write config
|
129
|
+
# end
|
130
|
+
|
131
|
+
# on delete, :id do |id|
|
132
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
133
|
+
# config = Configuration.optimistic_get( updated_at,
|
134
|
+
# id )
|
135
|
+
# config.destroy
|
136
|
+
# head 200
|
137
|
+
# end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'ixtlan/babel/params_filter'
|
22
|
+
module Ixtlan
|
23
|
+
module Configuration
|
24
|
+
class ConfigurationFilter < Ixtlan::Babel::ParamsFilter
|
25
|
+
|
26
|
+
root 'configuration'
|
27
|
+
|
28
|
+
add_context( :single,
|
29
|
+
:keep => [ :updated_at ],
|
30
|
+
:except => [:id, :created_at, :updated_at, :modified_by_id] )
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
require 'cuba_api'
|
2
|
+
require 'ixtlan/configuration/resource'
|
3
|
+
require 'ixtlan/configuration/serializer'
|
4
|
+
require 'ixtlan/babel/params_filter'
|
5
|
+
class CubaAPI
|
6
|
+
module ResponseStatus
|
7
|
+
def response_status( obj, options = {})
|
8
|
+
if options[:response_status] != false
|
9
|
+
if obj.respond_to?( :errors ) && obj.errors.size > 0
|
10
|
+
res.status = 412 # Precondition Failed
|
11
|
+
obj = obj.errors
|
12
|
+
elsif req.post?
|
13
|
+
res.status = 201 # Created
|
14
|
+
res[ 'Location' ] = env[ 'SCRIPT_NAME' ] + "/#{obj.id}" if obj.respond_to? :id
|
15
|
+
elsif req.delete?
|
16
|
+
res.status = 204 # No Content
|
17
|
+
obj = ''
|
18
|
+
end
|
19
|
+
end
|
20
|
+
obj
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.included( base )
|
24
|
+
base.prepend_aspect :response_status
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module InputFilter
|
29
|
+
|
30
|
+
module ClassMethods
|
31
|
+
def factory
|
32
|
+
@_factory ||= Ixtlan::Babel::Factory.new
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def new_instance( clazz, context = nil )
|
37
|
+
filter = self.class.factory.new_params_filter( clazz ).use( context )
|
38
|
+
filter.new( parse_request_body )
|
39
|
+
end
|
40
|
+
|
41
|
+
def params( clazz = nil, context = nil )
|
42
|
+
filter_params_and_keeps( clazz, context )
|
43
|
+
@_data[ 0 ] || {}
|
44
|
+
end
|
45
|
+
|
46
|
+
def keeps( clazz = nil, context = nil )
|
47
|
+
filter_params_and_keeps( clazz, context )
|
48
|
+
@_data[ 1 ] || {}
|
49
|
+
end
|
50
|
+
|
51
|
+
def filter_params_and_keeps( clazz, context )
|
52
|
+
if clazz
|
53
|
+
@_data ||=
|
54
|
+
begin
|
55
|
+
filter = self.class.factory.new_filter( clazz ).use( context )
|
56
|
+
filter.filter_it( parse_request_body )
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
private :filter_params_and_keeps
|
61
|
+
|
62
|
+
def parse_request_body
|
63
|
+
if env[ 'CONTENT_TYPE' ] == 'application/json'
|
64
|
+
JSON.parse( req.body.read )
|
65
|
+
else
|
66
|
+
{}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
private :parse_request_body
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
CubaAPI.plugin CubaAPI::InputFilter
|
75
|
+
CubaAPI.plugin CubaAPI::ResponseStatus
|
76
|
+
module Ixtlan
|
77
|
+
module Configuration
|
78
|
+
class ConfigurationFilter < Ixtlan::Babel::ParamsFilter
|
79
|
+
|
80
|
+
root 'configuration'
|
81
|
+
|
82
|
+
add_context( :single,
|
83
|
+
:keep => [ :updated_at ],
|
84
|
+
:except => [:id, :created_at, :updated_at, :modified_by_id] )
|
85
|
+
end
|
86
|
+
|
87
|
+
class Cuba < ::CubaAPI
|
88
|
+
|
89
|
+
define do
|
90
|
+
on get do
|
91
|
+
write Configuration.instance
|
92
|
+
end
|
93
|
+
|
94
|
+
on post do
|
95
|
+
updated_at = keeps( Configuration )[ :updated_at ]
|
96
|
+
p keeps
|
97
|
+
puts req.request_method
|
98
|
+
config = Configuration.optimistic_get!( updated_at,
|
99
|
+
Configuration.instance.id )
|
100
|
+
#config = Configuration.instance
|
101
|
+
config.attributes = params
|
102
|
+
config.modified_by = current_user if config.dirty?
|
103
|
+
config.save
|
104
|
+
write config
|
105
|
+
end
|
106
|
+
|
107
|
+
# on get, :id do |id|
|
108
|
+
# write Configuration.get!( id )
|
109
|
+
# end
|
110
|
+
|
111
|
+
# on get do
|
112
|
+
# write Configuration.all
|
113
|
+
# end
|
114
|
+
|
115
|
+
# on post do
|
116
|
+
# config = new_instance( Configuration )
|
117
|
+
# config.save
|
118
|
+
# write config
|
119
|
+
# end
|
120
|
+
|
121
|
+
# on put, :id do |id|
|
122
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
123
|
+
# config = Configuration.optimistic_get!( updated_at,
|
124
|
+
# id )
|
125
|
+
# config.attributes = params
|
126
|
+
# config.modified_by = current_user if config.dirty?
|
127
|
+
# config.save
|
128
|
+
# write config
|
129
|
+
# end
|
130
|
+
|
131
|
+
# on delete, :id do |id|
|
132
|
+
# updated_at = keeps( Configuration )[ :updated_at ]
|
133
|
+
# config = Configuration.optimistic_get( updated_at,
|
134
|
+
# id )
|
135
|
+
# config.destroy
|
136
|
+
# head 200
|
137
|
+
# end
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
module Ixtlan
|
22
|
+
module Configuration
|
23
|
+
class Configuration
|
24
|
+
|
25
|
+
include DataMapper::Resource
|
26
|
+
|
27
|
+
def self.storage_name(arg)
|
28
|
+
'ixtlan_configuration'
|
29
|
+
end
|
30
|
+
|
31
|
+
property :id, Serial
|
32
|
+
|
33
|
+
if defined? Ixtlan::Session
|
34
|
+
property :idle_session_timeout, Integer, :required => true, :default => 15
|
35
|
+
end
|
36
|
+
|
37
|
+
if defined? Ixtlan::Audit
|
38
|
+
property :audits_keep_logs, Integer, :required => true, :default => 30
|
39
|
+
end
|
40
|
+
|
41
|
+
if defined? Ixtlan::Errors
|
42
|
+
property :errors_keep_dumps, Integer, :required => true, :default => 30
|
43
|
+
property :errors_base_url, String, :required => false, :length => 128, :default => "http://localhost:3000/errors"
|
44
|
+
property :errors_from_email, String, :required => false, :length => 128, :default => 'no-reply@example.com'
|
45
|
+
property :errors_to_emails, String, :required => false, :length => 255, :default => 'developer@example.com'
|
46
|
+
end
|
47
|
+
|
48
|
+
if defined? Ixtlan::Remote
|
49
|
+
property :users_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
50
|
+
property :users_token, String, :required => true, :length => 64, :default => "behappy"
|
51
|
+
end
|
52
|
+
|
53
|
+
if defined? Ixtlan::Gettext
|
54
|
+
property :flash_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
55
|
+
property :translations_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
56
|
+
property :translations_token, String, :required => true, :length => 64, :default => "be happy"
|
57
|
+
end
|
58
|
+
|
59
|
+
timestamps :at
|
60
|
+
|
61
|
+
if defined?( ::User ) && ::User.respond_to?( :properties ) # DataMapper
|
62
|
+
belongs_to :modified_by, ::User
|
63
|
+
elsif defined?( Ixtlan::UserManagement::User ) && Ixtlan::UserManagement::User.respond_to?( :properties ) # DataMapper
|
64
|
+
belongs_to :modified_by, Ixtlan::UserManagement::User
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_s
|
68
|
+
"Configuration( #{updated_at} by #{modified_by} )"
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.instance
|
72
|
+
self.first || self.new
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Ixtlan
|
2
|
+
module Configuration
|
3
|
+
class Configuration
|
4
|
+
|
5
|
+
include DataMapper::Resource
|
6
|
+
|
7
|
+
def self.storage_name(arg)
|
8
|
+
'ixtlan_configuration'
|
9
|
+
end
|
10
|
+
|
11
|
+
property :id, Serial
|
12
|
+
|
13
|
+
if defined? Ixtlan::Session
|
14
|
+
property :idle_session_timeout, Integer, :required => true, :default => 15
|
15
|
+
end
|
16
|
+
|
17
|
+
if defined? Ixtlan::Audit
|
18
|
+
property :audits_keep_logs, Integer, :required => true, :default => 30
|
19
|
+
end
|
20
|
+
|
21
|
+
if defined? Ixtlan::Errors
|
22
|
+
property :errors_keep_dumps, Integer, :required => true, :default => 30
|
23
|
+
property :errors_base_url, String, :required => false, :length => 128, :default => "http://localhost:3000/errors"
|
24
|
+
property :errors_from_email, String, :required => false, :length => 128, :default => 'no-reply@example.com'
|
25
|
+
property :errors_to_emails, String, :required => false, :length => 255, :default => 'developer@example.com'
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined? Ixtlan::Remote
|
29
|
+
property :users_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
30
|
+
property :users_token, String, :required => true, :length => 64, :default => "behappy"
|
31
|
+
end
|
32
|
+
|
33
|
+
if defined? Ixtlan::Gettext
|
34
|
+
property :flash_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
35
|
+
property :translations_url, String, :required => false, :length => 128, :default => "http://localhost:3000"
|
36
|
+
property :translations_token, String, :required => true, :length => 64, :default => "be happy"
|
37
|
+
end
|
38
|
+
|
39
|
+
timestamps :at
|
40
|
+
|
41
|
+
if defined? ::User
|
42
|
+
belongs_to :modified_by, ::User
|
43
|
+
else
|
44
|
+
belongs_to :modified_by, Ixtlan::UserManagement::User
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_s
|
48
|
+
"Configuration( #{updated_at} by #{modified_by} )"
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.instance
|
52
|
+
self.first || self.new
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'ixtlan/babel/serializer'
|
22
|
+
|
23
|
+
class ConfigurationSerializer < Ixtlan::Babel::Serializer
|
24
|
+
|
25
|
+
root 'configuration'
|
26
|
+
|
27
|
+
add_context(:single,
|
28
|
+
:except => [:id, :modified_by_id],
|
29
|
+
:include => {
|
30
|
+
:modified_by => {
|
31
|
+
:only => [:id, :login, :name]
|
32
|
+
}
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
module Ixtlan
|
22
|
+
module Configuration
|
23
|
+
end
|
24
|
+
end
|
data/lib/ixtlan/core.rb~
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'ixtlan/configuration'
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ixtlan-configuration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christian Meier
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: slf4r
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.4.2
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.2
|
27
|
+
none: false
|
28
|
+
prerelease: false
|
29
|
+
type: :development
|
30
|
+
description: configuration for other ixtlan-xyz wth serializer, input-filter and cuba definition
|
31
|
+
email:
|
32
|
+
- m.kristian@web.de
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- README.md
|
38
|
+
- lib/ixtlan-configuration.rb
|
39
|
+
- lib/ixtlan-configuration.rb~
|
40
|
+
- lib/ixtlan/configuration.rb
|
41
|
+
- lib/ixtlan/configuration.rb~
|
42
|
+
- lib/ixtlan/core.rb~
|
43
|
+
- lib/ixtlan/configuration/cuba.rb~
|
44
|
+
- lib/ixtlan/configuration/cuba.rb
|
45
|
+
- lib/ixtlan/configuration/resource.rb~
|
46
|
+
- lib/ixtlan/configuration/resource.rb
|
47
|
+
- lib/ixtlan/configuration/filter.rb
|
48
|
+
- lib/ixtlan/configuration/filter.rb~
|
49
|
+
- lib/ixtlan/configuration/serializer.rb
|
50
|
+
homepage: http://github.com/mkristian/ixtlan-configuration
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options:
|
55
|
+
- "--main"
|
56
|
+
- README.md
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: !binary |-
|
64
|
+
MA==
|
65
|
+
none: false
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: !binary |-
|
71
|
+
MA==
|
72
|
+
none: false
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.24
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: configuration for other ixtlan-xyz wth serializer, input-filter and cuba definition
|
79
|
+
test_files: []
|