toolbox 0.1.4 → 0.3.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 (98) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/bake/ruby/gdb.rb +135 -0
  4. data/bake/toolbox/gdb.rb +137 -0
  5. data/bake/toolbox/lldb.rb +137 -0
  6. data/context/fiber-debugging.md +171 -0
  7. data/context/getting-started.md +200 -0
  8. data/context/heap-debugging.md +351 -0
  9. data/context/index.yaml +28 -0
  10. data/context/object-inspection.md +208 -0
  11. data/context/stack-inspection.md +188 -0
  12. data/data/toolbox/command.py +479 -0
  13. data/data/toolbox/constants.py +200 -0
  14. data/data/toolbox/context.py +371 -0
  15. data/data/toolbox/debugger/__init__.py +101 -0
  16. data/data/toolbox/debugger/gdb_backend.py +664 -0
  17. data/data/toolbox/debugger/lldb_backend.py +986 -0
  18. data/data/toolbox/fiber.py +877 -0
  19. data/data/toolbox/format.py +205 -0
  20. data/data/toolbox/heap.py +679 -0
  21. data/data/toolbox/init.py +89 -0
  22. data/data/toolbox/print.py +79 -0
  23. data/data/toolbox/rarray.py +116 -0
  24. data/data/toolbox/rbasic.py +99 -0
  25. data/data/toolbox/rbignum.py +48 -0
  26. data/data/toolbox/rclass.py +136 -0
  27. data/data/toolbox/readme.md +214 -0
  28. data/data/toolbox/rexception.py +150 -0
  29. data/data/toolbox/rfloat.py +88 -0
  30. data/data/toolbox/rhash.py +151 -0
  31. data/data/toolbox/rstring.py +230 -0
  32. data/data/toolbox/rstruct.py +149 -0
  33. data/data/toolbox/rsymbol.py +278 -0
  34. data/data/toolbox/rvalue.py +183 -0
  35. data/data/toolbox/stack.py +620 -0
  36. data/lib/toolbox/gdb.rb +21 -0
  37. data/lib/toolbox/lldb.rb +21 -0
  38. data/lib/toolbox/version.rb +7 -1
  39. data/lib/toolbox.rb +9 -24
  40. data/license.md +21 -0
  41. data/readme.md +64 -0
  42. data/releases.md +9 -0
  43. data.tar.gz.sig +0 -0
  44. metadata +95 -165
  45. metadata.gz.sig +0 -0
  46. data/Rakefile +0 -61
  47. data/lib/dirs.rb +0 -9
  48. data/lib/toolbox/config.rb +0 -211
  49. data/lib/toolbox/default_controller.rb +0 -393
  50. data/lib/toolbox/helpers.rb +0 -11
  51. data/lib/toolbox/rendering.rb +0 -413
  52. data/lib/toolbox/searching.rb +0 -85
  53. data/lib/toolbox/session_params.rb +0 -63
  54. data/lib/toolbox/sorting.rb +0 -74
  55. data/locale/de/LC_MESSAGES/toolbox.mo +0 -0
  56. data/public/images/add.png +0 -0
  57. data/public/images/arrow_down.gif +0 -0
  58. data/public/images/arrow_up.gif +0 -0
  59. data/public/images/close.png +0 -0
  60. data/public/images/edit.gif +0 -0
  61. data/public/images/email.png +0 -0
  62. data/public/images/page.png +0 -0
  63. data/public/images/page_acrobat.png +0 -0
  64. data/public/images/page_add.png +0 -0
  65. data/public/images/page_copy.png +0 -0
  66. data/public/images/page_delete.png +0 -0
  67. data/public/images/page_edit.png +0 -0
  68. data/public/images/page_excel.png +0 -0
  69. data/public/images/page_list.png +0 -0
  70. data/public/images/page_save.png +0 -0
  71. data/public/images/page_word.png +0 -0
  72. data/public/images/remove.png +0 -0
  73. data/public/images/show.gif +0 -0
  74. data/public/images/spinner.gif +0 -0
  75. data/public/javascripts/popup.js +0 -498
  76. data/public/javascripts/toolbox.js +0 -18
  77. data/public/stylesheets/context_menu.css +0 -168
  78. data/public/stylesheets/popup.css +0 -30
  79. data/public/stylesheets/toolbox.css +0 -107
  80. data/view/toolbox/_collection.html.erb +0 -24
  81. data/view/toolbox/_collection_header.html.erb +0 -7
  82. data/view/toolbox/_context_menu.html.erb +0 -17
  83. data/view/toolbox/_dialogs.html.erb +0 -6
  84. data/view/toolbox/_form.html.erb +0 -30
  85. data/view/toolbox/_form_collection_row.html.erb +0 -18
  86. data/view/toolbox/_form_fieldset.html.erb +0 -30
  87. data/view/toolbox/_form_fieldset_row.html.erb +0 -19
  88. data/view/toolbox/_list.html.erb +0 -25
  89. data/view/toolbox/_list_row.html.erb +0 -10
  90. data/view/toolbox/_menu.html.erb +0 -7
  91. data/view/toolbox/_search_field.html.erb +0 -8
  92. data/view/toolbox/_show.html.erb +0 -12
  93. data/view/toolbox/_show_collection_row.html.erb +0 -6
  94. data/view/toolbox/_show_fieldset.html.erb +0 -21
  95. data/view/toolbox/edit.html.erb +0 -5
  96. data/view/toolbox/index.html.erb +0 -3
  97. data/view/toolbox/new.html.erb +0 -9
  98. data/view/toolbox/show.html.erb +0 -39
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2025, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,64 @@
1
+ # Toolbox
2
+
3
+ Ruby debugging toolbox for GDB and LLDB, providing commands for inspecting Ruby objects, fibers, and VM internals across multiple debuggers.
4
+
5
+ [![Development Status](https://github.com/socketry/toolbox/workflows/Test/badge.svg)](https://github.com/socketry/toolbox/actions?workflow=Test)
6
+
7
+ ## Features
8
+
9
+ - **Multi-debugger support**: Works with both GDB and LLDB through a unified abstraction layer.
10
+ - **Object inspection**: Pretty-print Ruby objects, hashes, arrays, and complex structures.
11
+ - **Fiber debugging**: Navigate and inspect Ruby fibers with full backtraces.
12
+ - **Heap scanning**: Search the Ruby heap for objects and diagnose memory issues.
13
+ - **Stack inspection**: Examine both Ruby VM stacks and native C stacks.
14
+ - **Easy installation**: Simple bake tasks for both GDB and LLDB.
15
+
16
+ ## Usage
17
+
18
+ Please see the [project documentation](https://socketry.github.io/toolbox/) for more details.
19
+
20
+ - [Getting Started](https://socketry.github.io/toolbox/guides/getting-started/index) - This guide explains how to install and use Toolbox for debugging Ruby programs and core dumps with GDB or LLDB.
21
+
22
+ - [Object Inspection](https://socketry.github.io/toolbox/guides/object-inspection/index) - This guide explains how to use `rb-print` to inspect Ruby objects, hashes, arrays, and structs in GDB.
23
+
24
+ - [Stack Inspection](https://socketry.github.io/toolbox/guides/stack-inspection/index) - This guide explains how to inspect both Ruby VM stacks and native C stacks when debugging Ruby programs.
25
+
26
+ - [Fiber Debugging](https://socketry.github.io/toolbox/guides/fiber-debugging/index) - This guide explains how to debug Ruby fibers using GDB, including inspecting fiber state, backtraces, and switching between fiber contexts.
27
+
28
+ - [Heap Debugging](https://socketry.github.io/toolbox/guides/heap-debugging/index) - This guide explains how to navigate Ruby's heap to find objects, diagnose memory issues, and understand object relationships.
29
+
30
+ ## Releases
31
+
32
+ Please see the [project releases](https://socketry.github.io/toolbox/releases/index) for all releases.
33
+
34
+ ### v0.2.0
35
+
36
+ - Introduce support for `lldb` using debugger shims.
37
+
38
+ ### v0.1.0
39
+
40
+ - Initial release.
41
+
42
+ ## See Also
43
+
44
+ - [GDB Python API Documentation](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Python-API.html)
45
+ - [LLDB Python API Documentation](https://lldb.llvm.org/use/python-reference.html)
46
+ - [Ruby VM Internals](https://docs.ruby-lang.org/en/master/extension_rdoc.html)
47
+
48
+ ## Contributing
49
+
50
+ We welcome contributions to this project.
51
+
52
+ 1. Fork it.
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
55
+ 4. Push to the branch (`git push origin my-new-feature`).
56
+ 5. Create new Pull Request.
57
+
58
+ ### Developer Certificate of Origin
59
+
60
+ In order to protect users of this project, we require all contributors to comply with the [Developer Certificate of Origin](https://developercertificate.org/). This ensures that all contributions are properly licensed and attributed.
61
+
62
+ ### Community Guidelines
63
+
64
+ This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.
data/releases.md ADDED
@@ -0,0 +1,9 @@
1
+ # Releases
2
+
3
+ ## v0.2.0
4
+
5
+ - Introduce support for `lldb` using debugger shims.
6
+
7
+ ## v0.1.0
8
+
9
+ - Initial release.
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,178 +1,108 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: toolbox
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
5
  platform: ruby
6
- authors:
7
- - David Nyffenegger
8
- autorequire:
6
+ authors:
7
+ - Samuel Williams
9
8
  bindir: bin
10
- cert_chain: []
11
-
12
- date: 2009-01-29 00:00:00 +01:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 2.1.1
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: actionpack
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.1.1
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: actionpack
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 2.1.1
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: gettext
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: 2.1.0
54
- version:
55
- - !ruby/object:Gem::Dependency
56
- name: mislav-will_paginate
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 2.3.3
64
- version:
65
- - !ruby/object:Gem::Dependency
66
- name: calendar_date_select
67
- type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: 1.15.0
74
- version:
75
- - !ruby/object:Gem::Dependency
76
- name: fastercsv
77
- type: :runtime
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: 1.4.0
84
- version:
85
- description: This toolbox goes in the direction of the django admin interface.
86
- email: vidl@sunrise.ch
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
13
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
14
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
15
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
16
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
17
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
18
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
19
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
20
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
21
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
22
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
23
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
24
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
25
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
26
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
27
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
28
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
29
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
30
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
31
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
32
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
33
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
34
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
35
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
36
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
37
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
38
+ -----END CERTIFICATE-----
39
+ date: 1980-01-02 00:00:00.000000000 Z
40
+ dependencies: []
87
41
  executables: []
88
-
89
42
  extensions: []
90
-
91
43
  extra_rdoc_files: []
92
-
93
- files:
94
- - Rakefile
95
- - lib/dirs.rb
96
- - lib/toolbox/config.rb
97
- - lib/toolbox/default_controller.rb
98
- - lib/toolbox/helpers.rb
99
- - lib/toolbox/rendering.rb
100
- - lib/toolbox/searching.rb
101
- - lib/toolbox/session_params.rb
102
- - lib/toolbox/sorting.rb
103
- - lib/toolbox/version.rb
44
+ files:
45
+ - bake/ruby/gdb.rb
46
+ - bake/toolbox/gdb.rb
47
+ - bake/toolbox/lldb.rb
48
+ - context/fiber-debugging.md
49
+ - context/getting-started.md
50
+ - context/heap-debugging.md
51
+ - context/index.yaml
52
+ - context/object-inspection.md
53
+ - context/stack-inspection.md
54
+ - data/toolbox/command.py
55
+ - data/toolbox/constants.py
56
+ - data/toolbox/context.py
57
+ - data/toolbox/debugger/__init__.py
58
+ - data/toolbox/debugger/gdb_backend.py
59
+ - data/toolbox/debugger/lldb_backend.py
60
+ - data/toolbox/fiber.py
61
+ - data/toolbox/format.py
62
+ - data/toolbox/heap.py
63
+ - data/toolbox/init.py
64
+ - data/toolbox/print.py
65
+ - data/toolbox/rarray.py
66
+ - data/toolbox/rbasic.py
67
+ - data/toolbox/rbignum.py
68
+ - data/toolbox/rclass.py
69
+ - data/toolbox/readme.md
70
+ - data/toolbox/rexception.py
71
+ - data/toolbox/rfloat.py
72
+ - data/toolbox/rhash.py
73
+ - data/toolbox/rstring.py
74
+ - data/toolbox/rstruct.py
75
+ - data/toolbox/rsymbol.py
76
+ - data/toolbox/rvalue.py
77
+ - data/toolbox/stack.py
104
78
  - lib/toolbox.rb
105
- - locale/de/LC_MESSAGES/toolbox.mo
106
- - view/toolbox/_collection.html.erb
107
- - view/toolbox/_collection_header.html.erb
108
- - view/toolbox/_context_menu.html.erb
109
- - view/toolbox/_dialogs.html.erb
110
- - view/toolbox/_form.html.erb
111
- - view/toolbox/_form_collection_row.html.erb
112
- - view/toolbox/_form_fieldset.html.erb
113
- - view/toolbox/_form_fieldset_row.html.erb
114
- - view/toolbox/_list.html.erb
115
- - view/toolbox/_list_row.html.erb
116
- - view/toolbox/_menu.html.erb
117
- - view/toolbox/_search_field.html.erb
118
- - view/toolbox/_show.html.erb
119
- - view/toolbox/_show_collection_row.html.erb
120
- - view/toolbox/_show_fieldset.html.erb
121
- - view/toolbox/edit.html.erb
122
- - view/toolbox/index.html.erb
123
- - view/toolbox/new.html.erb
124
- - view/toolbox/show.html.erb
125
- - public/images/add.png
126
- - public/images/arrow_down.gif
127
- - public/images/arrow_up.gif
128
- - public/images/close.png
129
- - public/images/edit.gif
130
- - public/images/email.png
131
- - public/images/page.png
132
- - public/images/page_acrobat.png
133
- - public/images/page_add.png
134
- - public/images/page_copy.png
135
- - public/images/page_delete.png
136
- - public/images/page_edit.png
137
- - public/images/page_excel.png
138
- - public/images/page_list.png
139
- - public/images/page_save.png
140
- - public/images/page_word.png
141
- - public/images/remove.png
142
- - public/images/show.gif
143
- - public/images/spinner.gif
144
- - public/javascripts/popup.js
145
- - public/javascripts/toolbox.js
146
- - public/stylesheets/context_menu.css
147
- - public/stylesheets/popup.css
148
- - public/stylesheets/toolbox.css
149
- has_rdoc: true
150
- homepage: http://github.com/vidl/toolbox
151
- licenses: []
152
-
153
- post_install_message:
79
+ - lib/toolbox/gdb.rb
80
+ - lib/toolbox/lldb.rb
81
+ - lib/toolbox/version.rb
82
+ - license.md
83
+ - readme.md
84
+ - releases.md
85
+ homepage: https://github.com/socketry/toolbox
86
+ licenses:
87
+ - MIT
88
+ metadata:
89
+ documentation_uri: https://socketry.github.io/toolbox/
90
+ source_code_uri: https://github.com/socketry/toolbox
154
91
  rdoc_options: []
155
-
156
- require_paths:
92
+ require_paths:
157
93
  - lib
158
- required_ruby_version: !ruby/object:Gem::Requirement
159
- requirements:
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
160
96
  - - ">="
161
- - !ruby/object:Gem::Version
162
- version: "0"
163
- version:
164
- required_rubygems_version: !ruby/object:Gem::Requirement
165
- requirements:
97
+ - !ruby/object:Gem::Version
98
+ version: '3.2'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ requirements:
166
101
  - - ">="
167
- - !ruby/object:Gem::Version
168
- version: "0"
169
- version:
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
170
104
  requirements: []
171
-
172
- rubyforge_project: toolbox
173
- rubygems_version: 1.3.5
174
- signing_key:
175
- specification_version: 3
176
- summary: Davids toolbox to speedup development with rails (mainly view).
105
+ rubygems_version: 3.6.9
106
+ specification_version: 4
107
+ summary: Ruby debugging toolbox for GDB and LLDB
177
108
  test_files: []
178
-
metadata.gz.sig ADDED
Binary file
data/Rakefile DELETED
@@ -1,61 +0,0 @@
1
- require 'rubygems'
2
- require File.dirname(__FILE__) << "/lib/toolbox/version"
3
-
4
- spec = Gem::Specification.new do |s|
5
- s.name = %q{toolbox}
6
- s.version = Toolbox::VERSION
7
- s.date = %q{2009-01-29}
8
- s.authors = ["David Nyffenegger"]
9
- s.email = %q{vidl@sunrise.ch}
10
- s.summary = %q{Davids toolbox to speedup development with rails (mainly view).}
11
- s.homepage = %q{http://github.com/vidl/toolbox}
12
- s.description = %q{This toolbox goes in the direction of the django admin interface.}
13
- s.rubyforge_project = %q{toolbox}
14
- s.files = FileList["[A-Z]*", "{lib,locale,view,public}/**/*"]
15
-
16
- # rdoc
17
- s.has_rdoc = true
18
- #s.extra_rdoc_files = %w(README.rdoc MIT-LICENSE.txt)
19
-
20
- s.add_dependency "activesupport", ">= 2.1.1"
21
- s.add_dependency "actionpack", ">= 2.1.1"
22
- s.add_dependency "actionpack", ">= 2.1.1"
23
- s.add_dependency "gettext", ">= 2.1.0"
24
- s.add_dependency "mislav-will_paginate", ">= 2.3.3"
25
- s.add_dependency "calendar_date_select", ">= 1.15.0"
26
- s.add_dependency "fastercsv", ">= 1.4.0"
27
-
28
- end
29
-
30
- desc "Generate a gemspec file for GitHup"
31
- task :gemspec do
32
- File.open("#{spec.name}.gemspec", 'w') do |f|
33
- f.write spec.to_ruby
34
- end
35
- end
36
-
37
- desc "Create the gem"
38
- task :gem => [:makemo, :gemspec] do
39
- `gem build #{spec.name}.gemspec`
40
- end
41
-
42
- task :publish => [:gem] do
43
- `gem push toolbox-#{Toolbox::VERSION}.gem`
44
- end
45
-
46
- desc "Generate RDoc"
47
- task :doc do
48
- system "hanna -x Rakefile -x spec --title 'Toolbox #{Toolbox::VERSION} API Documentation'"
49
- end
50
-
51
- desc "Update pot/po files."
52
- task :updatepo do
53
- require 'gettext/tools' #HERE!
54
- GetText.update_pofiles("#{spec.name}", Dir.glob("{lib}/**/*.{rb,erb,rjs}"), "#{spec.name} #{Toolbox::VERSION}")
55
- end
56
-
57
- desc "Create mo-files"
58
- task :makemo do
59
- require 'gettext/tools' #HERE!
60
- GetText.create_mofiles
61
- end
data/lib/dirs.rb DELETED
@@ -1,9 +0,0 @@
1
-
2
- module Toolbox
3
- module Dirs
4
- GEM_ROOT = File.expand_path("../", File.dirname(__FILE__)) unless defined? GEM_ROOT
5
- LOCALE = File.join(GEM_ROOT, '/locale') unless defined? LOCALE
6
- VIEW = File.join(GEM_ROOT, '/view') unless defined? VIEW
7
-
8
- end
9
- end
@@ -1,211 +0,0 @@
1
-
2
- module Toolbox
3
-
4
- class WidgetList
5
- attr_reader :widgets
6
-
7
- def initialize model_name, widgets, type
8
- @widgets = []
9
- last = nil
10
- h = nil
11
- widgets.each do |widget|
12
- h = { :name => last, :model_name => model_name}
13
- if widget.is_a? Hash
14
- raise 'Before an option hash there must be a widget name (string or symbol)' unless last
15
- raise 'The item before a option hash must be a string or a symbol' unless last.is_a?(String) || last.is_a?(Symbol)
16
- h.merge! widget
17
- end
18
- @widgets << type.new(h) if last && !last.is_a?(Hash)
19
- last = widget
20
- end
21
- # add the last field, if it's a symbol
22
- if last && !last.is_a?(Hash)
23
- h = { :name => last, :model_name => model_name}
24
- @widgets << type.new(h)
25
- end
26
- end
27
- end
28
-
29
-
30
- class EditConfig
31
- attr_reader :controlsets
32
-
33
- def initialize model_name, config
34
- @controlsets = []
35
- config.each do |controlset|
36
- raise 'The options aggregation_config and collection_config must not be defined toghether' if controlset[:collection_config] and controlset[:aggregation_config]
37
- h = {}
38
- h.merge! controlset
39
- h[:widget_list] = WidgetList.new(model_name, controlset[:widget_list], controlset[:widget_type] || ControlConfig)
40
- h[:collection_config] = CollectionConfig.new controlset[:collection_config] if controlset[:collection_config]
41
- h[:aggregation_config] = AggregationConfig.new controlset[:aggregation_config] if controlset[:aggregation_config]
42
- @controlsets << WidgetSetConfig.new(h)
43
- end
44
- end
45
- end
46
-
47
- class ShowConfig
48
- attr_reader :fieldsets
49
- attr_reader :embedded_lists
50
- attr_reader :pdf_options
51
-
52
- def initialize model_name, config
53
- @fieldsets = []
54
- config[:fieldsets].each do |fieldset|
55
- h = {}
56
- h.merge! fieldset
57
- h[:widget_list] = WidgetList.new(model_name, fieldset[:widget_list], fieldset[:widget_type] || FieldConfig)
58
- h[:collection_config] = CollectionConfig.new fieldset[:collection_config] if fieldset[:collection_config]
59
- @fieldsets << WidgetSetConfig.new(h)
60
- end
61
- @embedded_lists = []
62
- prefixes = {}
63
- config[:embedded_lists] = config[:embedded_lists] || []
64
- config[:embedded_lists].each do |list|
65
- h = {}
66
- h.merge! list
67
- h[:collection_config] = CollectionConfig.new list[:collection_config]
68
- h[:widget_list] = WidgetList.new(h[:collection_config].type.name, list[:widget_list], FieldConfig)
69
- c = EmbeddedListConfig.new(h)
70
- raise "Prefix #{c.prefix} is already used by #{prefixes[c.prefix].label}" if prefixes[c.prefix]
71
- prefixes[c.prefix] = c
72
- @embedded_lists << c
73
- end
74
- @pdf_options = config[:pdf_options] || {}
75
- end
76
- end
77
-
78
- # The base class of the configuration classes.
79
-
80
- class Config
81
- protected
82
- # Use this methods to easily define which options the configuration class supports.
83
- # This is done by hash, where each key defines a single option by its name.
84
- # The value is a hash that may contain the following keys:
85
- # - :required boolean, if true, this option is mandatory, default is false
86
- # - :type array of class-names. If set, an exception is raised if the given value is not of the specified type
87
- # - :values array of allowed values. If set, an exception is raised if the given value is not withing the specified values.
88
- # - :default a default value, that is set, if the option is not given. Otherwise, nil is assgined
89
- def self.define_options options
90
- # attr_reader for each option
91
- options.each_key { |k| attr_reader k }
92
- write_inheritable_attribute 'options', options || {}
93
- end
94
-
95
- # create the constructor out of the options definition
96
- def initialize vars
97
- vars.each_pair do |k,v|
98
- if respond_to? k.to_sym # set only, if there is an accessor
99
- k = '@' + k.to_s
100
- instance_variable_set(k.to_sym,v)
101
- else
102
- raise "Unkown option #{k.to_s} (#{self.class.name.to_s})"
103
- end
104
- end
105
- # check against the definition
106
- self.class.read_inheritable_attribute('options').each_pair do |name, opt|
107
- val = vars[name]
108
- class_name = "(#{self.class.name.to_s}: #{val.inspect})"
109
- raise "#{name} is required #{class_name}" if opt[:required] && !val
110
- raise "#{name} is #{val.class.to_s} and not of #{opt[:type].join(' or ')} #{class_name}" if opt[:type] && val && !opt[:type].include?(val.class)
111
- raise "#{name} is not in #{opt[:values].join(', ')} #{class_name}" if opt[:values] && val && !opt[:values].include?(val)
112
- instance_variable_set("@#{name.to_s}".to_sym, opt[:default] || nil) unless val
113
- end
114
- end
115
- end
116
-
117
- # Holds the configuration for a collection. This defines how to render a widget if it's not a simple
118
- # type but a collection.
119
- class CollectionConfig < Config
120
- define_options :type => { :type => [Class], :required => true},
121
- :model_method => { :type => [Symbol], :required => true},
122
- :suppress_table_header => { :default => false},
123
- :hide_empty => { :default => false}
124
- end
125
-
126
- # Holds the configuration for other aggregations than collections.
127
- class AggregationConfig < Config
128
- define_options :type => { :type => [Class], :required => true},
129
- :model_method => { :type => [Symbol], :required => true}
130
-
131
- end
132
-
133
- # Holds the configuration for a from control
134
- class ControlConfig < Config
135
- define_options :model_method => { :type => [Symbol, Proc]},
136
- :text_method => { :type => [Symbol]},
137
- :suppress_label => { :default => false },
138
- :label => { :type => [String] },
139
- :name => { :required => true, :type => [Symbol] },
140
- :model_name => { :required => true, :type => [String] },
141
- :type => { :type => [Symbol], :default => :textfield,
142
- :values => [:select, :collection_select, :auto_complete, :textfield,
143
- :textarea, :radio, :date, :check_box, :filefield, :hidden]},
144
- :url => { :type => [Symbol]},
145
- :size => { :type => [Fixnum, String]},
146
- :values => { :type => [Array]},
147
- :info => { :type => [String]},
148
- :css_class => { :type => [String]},
149
- :disabled => { :default => false, :type => [FalseClass, TrueClass, Proc]}
150
- end
151
-
152
- # Holds the configuration for a non-editable field
153
- class FieldConfig < Config
154
- define_options :model_method => { :type => [Symbol, Proc]},
155
- :render_method => { :type => [Symbol, Proc]},
156
- :hide_empty => { :default => false },
157
- :suppress_label => { :default => false },
158
- :suppress_link => { :default => false },
159
- :suppress_sorting => { :default => false },
160
- :suppress_context_menu => { :default => false},
161
- :order_by => { :type => [String, Array] },
162
- :label => { :type => [String] },
163
- :join => {},
164
- :suffix => {},
165
- :name => { :required => true, :type => [String, Symbol] },
166
- :model_name => { :required => true, :type => [String] },
167
- :trunc => { :type => [Fixnum]}
168
-
169
-
170
- def ==(s)
171
- (s.is_a?(Hash) && s[:name] && @name.to_s == s[:name].to_s) ||
172
- (s.is_a?(Symbol) && @name.to_s == s.to_s) ||
173
- (s.is_a?(String) && @name.to_s == s) ||
174
- (s.is_a?(FieldConfig) && s.name.to_s == @name.to_s)
175
- end
176
- end
177
-
178
- # Holds the configuration for a set of widgets. Widgets are either controls of a form
179
- # or un-editable fields.
180
- class WidgetSetConfig < Config
181
- define_options :widget_list => { :type => [WidgetList], :required => true},
182
- :label => { :type => [String], :required => true},
183
- :collection_config => { :type => [CollectionConfig] },
184
- :aggregation_config => { :type => [AggregationConfig] },
185
- :partial => { :type => [String]},
186
- :widget_type => { :type => [Class], :values => [ControlConfig, FieldConfig]},
187
- :condition => { :type => [Proc] } # if set, the fieldset is only rendered, if the proc returns true
188
- end
189
-
190
- # Holds the configuration for an embedded list
191
- class EmbeddedListConfig < Config
192
- define_options :widget_list => { :type => [WidgetList], :required => true},
193
- :label => { :type => [String], :required => true},
194
- :collection_config => { :type => [CollectionConfig], :required => true },
195
- :prefix => { :type => [String], :required => true},
196
- :include_assoc => { :type => [Array]}
197
- end
198
-
199
- class ActionConfig < Config
200
- define_options :label => { :type => [String] },
201
- :name => { :required => true, :type => [Symbol] },
202
- :model_name => { :required => true, :type => [String] },
203
- :url => {:type => [String]},
204
- :direct_link => { :type => [TrueClass, FalseClass], :default => false},
205
- :active => { :type => [Fixnum], :default => 1},
206
- :css_class => { :type => [String]}
207
-
208
- end
209
-
210
-
211
- end