sbsm 1.0.0

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 (50) hide show
  1. data/COPYING +515 -0
  2. data/History.txt +5 -0
  3. data/Manifest.txt +49 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +28 -0
  6. data/data/_flavored_uri.grammar +24 -0
  7. data/data/_uri.grammar +22 -0
  8. data/data/_zone_uri.grammar +24 -0
  9. data/data/flavored_uri.grammar +24 -0
  10. data/data/uri.grammar +22 -0
  11. data/data/zone_uri.grammar +24 -0
  12. data/install.rb +1098 -0
  13. data/lib/cgi/drbsession.rb +37 -0
  14. data/lib/sbsm/cgi.rb +79 -0
  15. data/lib/sbsm/drb.rb +19 -0
  16. data/lib/sbsm/drbserver.rb +162 -0
  17. data/lib/sbsm/exception.rb +28 -0
  18. data/lib/sbsm/flavored_uri_parser.rb +47 -0
  19. data/lib/sbsm/index.rb +66 -0
  20. data/lib/sbsm/lookandfeel.rb +176 -0
  21. data/lib/sbsm/lookandfeelfactory.rb +50 -0
  22. data/lib/sbsm/lookandfeelwrapper.rb +109 -0
  23. data/lib/sbsm/redefine_19_cookie.rb +4 -0
  24. data/lib/sbsm/redirector.rb +37 -0
  25. data/lib/sbsm/request.rb +162 -0
  26. data/lib/sbsm/session.rb +542 -0
  27. data/lib/sbsm/state.rb +301 -0
  28. data/lib/sbsm/time.rb +29 -0
  29. data/lib/sbsm/trans_handler.rb +119 -0
  30. data/lib/sbsm/turing.rb +25 -0
  31. data/lib/sbsm/uri_parser.rb +45 -0
  32. data/lib/sbsm/user.rb +47 -0
  33. data/lib/sbsm/validator.rb +256 -0
  34. data/lib/sbsm/viralstate.rb +47 -0
  35. data/lib/sbsm/zone_uri_parser.rb +48 -0
  36. data/test/data/dos_file.txt +2 -0
  37. data/test/data/lnf_file.txt +2 -0
  38. data/test/data/mac_file.txt +1 -0
  39. data/test/stub/cgi.rb +35 -0
  40. data/test/suite.rb +29 -0
  41. data/test/test_drbserver.rb +83 -0
  42. data/test/test_index.rb +90 -0
  43. data/test/test_lookandfeel.rb +230 -0
  44. data/test/test_session.rb +372 -0
  45. data/test/test_state.rb +176 -0
  46. data/test/test_trans_handler.rb +447 -0
  47. data/test/test_user.rb +44 -0
  48. data/test/test_validator.rb +126 -0
  49. data/usage-en.txt +112 -0
  50. metadata +142 -0
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # State Based Session Management
4
+ # Copyright (C) 2004 Hannes Wyss
5
+ #
6
+ # This library is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU Lesser General Public
8
+ # License as published by the Free Software Foundation; either
9
+ # version 2.1 of the License, or (at your option) any later version.
10
+ #
11
+ # This library is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Lesser General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Lesser General Public
17
+ # License along with this library; if not, write to the Free Software
18
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ #
20
+ # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
21
+ # hwyss@ywesee.com
22
+ #
23
+ # TestValidator -- sbsm -- 15.11.2002 -- hwyss@ywesee.com
24
+
25
+ $: << File.dirname(__FILE__)
26
+ $: << File.expand_path("../lib", File.dirname(__FILE__))
27
+
28
+ require 'test/unit'
29
+ require 'sbsm/validator'
30
+
31
+ class Validator < SBSM::Validator
32
+ attr_accessor :errors
33
+ DATES = [
34
+ :date
35
+ ]
36
+ ENUMS = {
37
+ :enum => ['foo'],
38
+ :values => ['1', '2', '3', '4', '7'],
39
+ }
40
+ EVENTS = [
41
+ :logout,
42
+ ]
43
+ BOOLEAN = [ :bool ]
44
+ PATTERNS = {
45
+ :pattern => /(^\d+$)|(^[a-z]{1,3}$)/,
46
+ }
47
+ HTML = [ :html ]
48
+ end
49
+
50
+ class TestValidator < Test::Unit::TestCase
51
+ def setup
52
+ @val = Validator.new
53
+ end
54
+ def test_reset_errors
55
+ assert_equal({}, @val.errors)
56
+ @val.errors = {:foo=>:bar}
57
+ assert_nothing_raised {
58
+ @val.reset_errors
59
+ }
60
+ assert_equal({}, @val.errors)
61
+ end
62
+ def test_validate
63
+ assert_nothing_raised { @val.validate(:something, :other) }
64
+ end
65
+ def test_boolean
66
+ assert_equal(true, @val.validate(:bool, 'true'))
67
+ assert_equal(true, @val.validate(:bool, 'TRUE'))
68
+ assert_equal(true, @val.validate(:bool, 1))
69
+ assert_equal(true, @val.validate(:bool, true))
70
+ assert_equal(true, @val.validate(:bool, 'Y'))
71
+ assert_equal(true, @val.validate(:bool, 'j'))
72
+ assert_equal(false, @val.validate(:bool, 'false'))
73
+ assert_equal(false, @val.validate(:bool, 'FALSE'))
74
+ assert_equal(false, @val.validate(:bool, 0))
75
+ assert_equal(false, @val.validate(:bool, false))
76
+ assert_equal(false, @val.validate(:bool, 'N'))
77
+ end
78
+ def test_enum
79
+ assert_equal('foo', @val.validate(:enum, 'foo'))
80
+ end
81
+ def test_event
82
+ assert_equal(:logout, @val.validate(:event, 'logout'))
83
+ assert_equal(:logout, @val.validate(:event, ['logout']))
84
+ end
85
+ def test_email1
86
+ assert_equal('e_invalid_email_address', @val.validate(:email, 'test').message)
87
+ assert_equal('test@com', @val.validate(:email, 'test@com'))
88
+ assert_equal('test@test.com', @val.validate(:email, 'test@test.com'))
89
+ assert_equal(SBSM::InvalidDataError, @val.validate(:email, 'test@test@test').class)
90
+ end
91
+ def test_pass
92
+ assert_equal('098f6bcd4621d373cade4e832627b4f6', @val.validate(:pass, 'test'))
93
+ end
94
+ def test_valid_values
95
+ expected = ['1', '2', '3', '4', '7']
96
+ assert_equal(expected, @val.valid_values(:values))
97
+ assert_equal(expected, @val.valid_values('values'))
98
+ end
99
+ def test_date
100
+ assert_equal(Date.new(2002,1,2), @val.validate(:date, '2.1.2002'))
101
+ assert_equal(SBSM::InvalidDataError, @val.validate(:date, '13.13.1234').class)
102
+ assert_equal(nil, @val.validate(:date, " \t"))
103
+ end
104
+ def test_state_id
105
+ assert_equal(nil, @val.validate(:state_id, nil))
106
+ assert_equal(nil, @val.validate(:state_id, "df"))
107
+ assert_equal(1245, @val.validate(:state_id, "1245"))
108
+ assert_equal(-1245, @val.validate(:state_id, "-1245"))
109
+ end
110
+ def test_pattern
111
+ assert_equal('new', @val.validate(:pattern, 'new'))
112
+ assert_equal('12345', @val.validate(:pattern, '12345'))
113
+ assert_equal(nil, @val.validate(:pattern, '23foo45'))
114
+ assert_equal(nil, @val.validate(:pattern, 'abfoodc'))
115
+ end
116
+ def test_validate_html
117
+ src = "<SPAN style=\"PADDING-BOTTOM: 4px; LINE-HEIGHT: 1.4em; WHITE-SPACE: normal\"><P class=MsoNormal style=\"MARGIN: 0cm -0.3pt 0pt 0cm; TEXT-ALIGN: justify\"><SPAN lang=DE style=\"FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'\">Wirkstoff: Ibuprofenum. <?xml:namespace prefix = o ns = \"urn:schemas-microsoft-com:office:office\" /><o:p></o:p></SPAN></P><P class=MsoNormal style=\"MARGIN: 0cm -0.3pt 0pt 0cm; TEXT-ALIGN: justify\"><SPAN lang=DE style=\"FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'\">Hilfsstoffe: Conserv.: Sorbins\344ure (E 200), Excipiens pro compr. obducto<o:p></o:p></SPAN></P><P style=\"MARGIN-TOP: 4px; FONT-SIZE: 13px; LINE-HEIGHT: 1.4em\"></SPAN><BR>&nbsp;</P>"
118
+ expected = "<span style=\"PADDING-BOTTOM: 4px; LINE-HEIGHT: 1.4em; WHITE-SPACE: normal\"><p class=\"MsoNormal\" style=\"MARGIN: 0cm -0.3pt 0pt 0cm; TEXT-ALIGN: justify\"><span lang=\"DE\" style=\"FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'\">Wirkstoff: Ibuprofenum. </span></p><p class=\"MsoNormal\" style=\"MARGIN: 0cm -0.3pt 0pt 0cm; TEXT-ALIGN: justify\"><span lang=\"DE\" style=\"FONT-SIZE: 11pt; FONT-FAMILY: Arial; mso-bidi-font-size: 10.0pt; mso-bidi-font-family: 'Times New Roman'\">Hilfsstoffe: Conserv.: Sorbins\344ure (E 200), Excipiens pro compr. obducto</span></p><p style=\"MARGIN-TOP: 4px; FONT-SIZE: 13px; LINE-HEIGHT: 1.4em\"></p></span><br />&nbsp;"
119
+ assert_equal expected, @val.validate(:html, src)
120
+ end
121
+ def test_validate_html__pre
122
+ src = "<pre> fooo </pre>"
123
+ expected = "<pre> fooo </pre>"
124
+ assert_equal expected, @val.validate(:html, src)
125
+ end
126
+ end
data/usage-en.txt ADDED
@@ -0,0 +1,112 @@
1
+ Installing Programs with install.rb / setup.rb
2
+ ==============================================
3
+
4
+ Overview
5
+ --------
6
+
7
+ Type these lines on command line:
8
+ ("#" line may require root privilege)
9
+
10
+ $ ruby install.rb config
11
+ $ ruby install.rb setup
12
+ # ruby install.rb install
13
+
14
+
15
+ There's no difference in a usage between install.rb
16
+ and setup.rb.
17
+
18
+ $ ruby setup.rb config
19
+ $ ruby setup.rb setup
20
+ # ruby setup.rb install
21
+
22
+
23
+ Details
24
+ -------
25
+
26
+ Usage of install.rb/setup.rb is:
27
+
28
+ ruby install.rb <global options>
29
+ ruby install.rb [<global options>] <task> [<task options>]
30
+
31
+
32
+ -q,--quiet
33
+ suppress message outputs
34
+ --verbose
35
+ output messages verbosely (default)
36
+ -h,--help
37
+ prints help and quit
38
+ -v,--version
39
+ prints version and quit
40
+ --copyright
41
+ prints copyright and quit
42
+
43
+ These are acceptable tasks:
44
+ config
45
+ saves configurations
46
+ show
47
+ prints current configurations
48
+ setup
49
+ compiles extentions
50
+ install
51
+ installs files
52
+ clean
53
+ cleans created files
54
+
55
+ Task Options for Config
56
+ -----------------------
57
+
58
+ --prefix=PATH
59
+ a prefix of the installing directory path
60
+ --std-ruby=PATH
61
+ the directory for standard ruby libraries
62
+ --site-ruby-common=PATH
63
+ the directory for version-independent non-standard
64
+ ruby libraries
65
+ --site-ruby=PATH
66
+ the directory for non-standard ruby libraries
67
+ --bin-dir=PATH
68
+ the directory for commands
69
+ --rb-dir=PATH
70
+ the directory for ruby scripts
71
+ --so-dir=PATH
72
+ the directory for ruby extentions
73
+ --data-dir=PATH
74
+ the directory for shared data
75
+ --ruby-path=PATH
76
+ path to set to #! line
77
+ --ruby-prog=PATH
78
+ the ruby program using for installation
79
+ --make-prog=NAME
80
+ the make program to compile ruby extentions
81
+ --without-ext
82
+ forces to install.rb never to compile/install
83
+ ruby extentions.
84
+ --rbconfig=PATH
85
+ your rbconfig.rb to load
86
+
87
+ You can view default values of these options by typing
88
+
89
+ $ ruby install.rb --help
90
+
91
+
92
+ In addition, setup.rb accepts these options:
93
+ --with=NAME,NAME,NAME...
94
+ package names which you want to install
95
+ --without=NAME,NAME,NAME...
96
+ package names which you do not want to install
97
+
98
+ [NOTE] You can pass options for extconf.rb like this:
99
+
100
+ ruby install.rb config -- --with-tklib=/usr/lib/libtk-ja.so.8.0
101
+
102
+
103
+ Task Options for Install
104
+ ------------------------
105
+
106
+ --no-harm
107
+ prints what to do and done nothing really.
108
+ --prefix=PATH
109
+ a prefix of the installing directory path.
110
+ This option may help binary package maintainers.
111
+ A default value is an empty string.
112
+
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sbsm
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-16 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 47
30
+ segments:
31
+ - 2
32
+ - 8
33
+ - 0
34
+ version: 2.8.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Application framework for state based session management
38
+ email:
39
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ - usage-en.txt
49
+ files:
50
+ - COPYING
51
+ - History.txt
52
+ - Manifest.txt
53
+ - README.txt
54
+ - Rakefile
55
+ - data/_flavored_uri.grammar
56
+ - data/_uri.grammar
57
+ - data/_zone_uri.grammar
58
+ - data/flavored_uri.grammar
59
+ - data/uri.grammar
60
+ - data/zone_uri.grammar
61
+ - install.rb
62
+ - lib/cgi/drbsession.rb
63
+ - lib/sbsm/cgi.rb
64
+ - lib/sbsm/drb.rb
65
+ - lib/sbsm/drbserver.rb
66
+ - lib/sbsm/exception.rb
67
+ - lib/sbsm/flavored_uri_parser.rb
68
+ - lib/sbsm/index.rb
69
+ - lib/sbsm/lookandfeel.rb
70
+ - lib/sbsm/lookandfeelfactory.rb
71
+ - lib/sbsm/lookandfeelwrapper.rb
72
+ - lib/sbsm/redefine_19_cookie.rb
73
+ - lib/sbsm/redirector.rb
74
+ - lib/sbsm/request.rb
75
+ - lib/sbsm/session.rb
76
+ - lib/sbsm/state.rb
77
+ - lib/sbsm/time.rb
78
+ - lib/sbsm/trans_handler.rb
79
+ - lib/sbsm/turing.rb
80
+ - lib/sbsm/uri_parser.rb
81
+ - lib/sbsm/user.rb
82
+ - lib/sbsm/validator.rb
83
+ - lib/sbsm/viralstate.rb
84
+ - lib/sbsm/zone_uri_parser.rb
85
+ - test/data/dos_file.txt
86
+ - test/data/lnf_file.txt
87
+ - test/data/mac_file.txt
88
+ - test/stub/cgi.rb
89
+ - test/suite.rb
90
+ - test/test_drbserver.rb
91
+ - test/test_index.rb
92
+ - test/test_lookandfeel.rb
93
+ - test/test_session.rb
94
+ - test/test_state.rb
95
+ - test/test_trans_handler.rb
96
+ - test/test_user.rb
97
+ - test/test_validator.rb
98
+ - usage-en.txt
99
+ has_rdoc: true
100
+ homepage: http://scm.ywesee.com/?p=sbsm/.git;a=summary
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options:
105
+ - --main
106
+ - README.txt
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ requirements: []
128
+
129
+ rubyforge_project: sbsm
130
+ rubygems_version: 1.3.7
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: Application framework for state based session management
134
+ test_files:
135
+ - test/test_drbserver.rb
136
+ - test/test_index.rb
137
+ - test/test_lookandfeel.rb
138
+ - test/test_session.rb
139
+ - test/test_state.rb
140
+ - test/test_trans_handler.rb
141
+ - test/test_user.rb
142
+ - test/test_validator.rb