webinkforms 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +22 -0
- data/lib/webinkforms.rb +71 -0
- metadata +62 -0
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013, Matthias Geier
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
- Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
- Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
17
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
18
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
19
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
20
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
21
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
22
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/webinkforms.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
class Ink::Controller
|
3
|
+
def params(method)
|
4
|
+
return if @params[method].nil? or @params[method].empty?
|
5
|
+
objects = {:params => {}, :refs => {}, :others => {}}
|
6
|
+
@params[method].keys.each do |k|
|
7
|
+
if k =~ /^#{prefix_submit}(.*)$/
|
8
|
+
name = $1
|
9
|
+
objects[:submit] = Ink::Model.from_refstr(name) || name
|
10
|
+
objects[:submit_value] = @params[method][k]
|
11
|
+
elsif k =~ /^#{prefix_set}(.*)$/
|
12
|
+
name = $1
|
13
|
+
obj = nil
|
14
|
+
if @params[method][k].is_a? Array
|
15
|
+
obj = @params[method][k].map{|i| Ink::Model.from_refstr(i) || i}
|
16
|
+
else
|
17
|
+
obj = Ink::Model.from_refstr(@params[method][k]) ||
|
18
|
+
@params[method][k]
|
19
|
+
end
|
20
|
+
objects[:params][name] = obj
|
21
|
+
elsif k =~ /^#{prefix_ref}(.*)$/
|
22
|
+
name = $1
|
23
|
+
obj = nil
|
24
|
+
if @params[method][k].is_a? Array
|
25
|
+
obj = @params[method][k].map{|i| Ink::Model.from_refstr(i) || i}
|
26
|
+
else
|
27
|
+
obj = Ink::Model.from_refstr(@params[method][k]) ||
|
28
|
+
@params[method][k]
|
29
|
+
end
|
30
|
+
ref = Ink::Model.from_refstr(name) || name
|
31
|
+
objects[:refs][ref] = obj
|
32
|
+
else
|
33
|
+
objects[:others][k] = @params[method][k]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if block_given?
|
38
|
+
yield(objects)
|
39
|
+
nil
|
40
|
+
else
|
41
|
+
objects
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def prefix_submit
|
46
|
+
"submit_"
|
47
|
+
end
|
48
|
+
|
49
|
+
def prefix_ref
|
50
|
+
"ref_"
|
51
|
+
end
|
52
|
+
|
53
|
+
def prefix_set
|
54
|
+
"set_"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
class Ink::Model
|
59
|
+
def to_refstr(prefix="")
|
60
|
+
pk ? "#{prefix}#{self.class.class_name}:#{pk}" : nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.from_refstr(refstr)
|
64
|
+
if refstr =~ /^([^:]+):(.+)$/ and klass = self.classname($1)
|
65
|
+
Ink::Database.database.find(klass, "WHERE #{klass.primary_key}=#{$2}").
|
66
|
+
first
|
67
|
+
else
|
68
|
+
nil
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webinkforms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matthias Geier
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: webink
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.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.0
|
30
|
+
description:
|
31
|
+
email:
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- lib/webinkforms.rb
|
37
|
+
- LICENSE.md
|
38
|
+
homepage: https://github.com/matthias-geier/WebInkForms
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.9.3
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project:
|
58
|
+
rubygems_version: 1.8.23
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: A form processing extension for webink
|
62
|
+
test_files: []
|