parlement 0.10 → 0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/CHANGES +11 -0
  2. data/MEMORY +9 -1
  3. data/README +5 -4
  4. data/app/controllers/account_controller.rb +10 -13
  5. data/app/controllers/application.rb +4 -5
  6. data/app/controllers/elt_controller.rb +9 -7
  7. data/app/controllers/person_controller.rb +1 -3
  8. data/app/controllers/subscriber_controller.rb +10 -10
  9. data/app/helpers/elt_helper.rb +2 -0
  10. data/app/models/elt.rb +28 -19
  11. data/app/models/mail.rb +26 -14
  12. data/app/models/mail_notify.rb +5 -4
  13. data/app/models/person.rb +11 -2
  14. data/app/views/account/_login.rhtml +3 -3
  15. data/app/views/account/_show.rhtml +12 -14
  16. data/app/views/elt/_choice.rhtml +3 -3
  17. data/app/views/elt/_elt.rhtml +4 -4
  18. data/app/views/elt/_list.rhtml +2 -2
  19. data/app/views/elt/_listByDate.rhtml +1 -1
  20. data/app/views/elt/_listByVote.rhtml +1 -1
  21. data/app/views/elt/new.rhtml +3 -3
  22. data/app/views/elt/show.rhtml +2 -2
  23. data/app/views/layouts/top.rhtml +6 -0
  24. data/app/views/mail_notify/publish.text.html.rhtml +1 -1
  25. data/app/views/person/_listElts.rhtml +5 -3
  26. data/app/views/person/show.rhtml +1 -2
  27. data/config/boot.rb +5 -4
  28. data/config/environment.rb +6 -4
  29. data/config/routes.rb +3 -2
  30. data/db/development_structure.sql +15 -4
  31. data/db/migrate/006_last_activity.rb +10 -0
  32. data/db/schema.rb +67 -49
  33. data/public/dispatch.fcgi +1 -0
  34. data/public/javascripts/controls.js +41 -23
  35. data/public/javascripts/dragdrop.js +317 -99
  36. data/public/javascripts/effects.js +301 -166
  37. data/public/javascripts/prototype.js +932 -402
  38. data/public/stylesheets/default.css +3 -2
  39. data/test/unit/elt_test.rb +13 -0
  40. data/test/unit/mail_test.rb +3 -1
  41. data/vendor/plugins/engines/CHANGELOG +203 -99
  42. data/vendor/plugins/engines/MIT-LICENSE +1 -1
  43. data/vendor/plugins/engines/README +32 -384
  44. data/vendor/plugins/engines/Rakefile +14 -0
  45. data/vendor/plugins/engines/UPGRADING +93 -0
  46. data/vendor/plugins/engines/about.yml +7 -0
  47. data/vendor/plugins/engines/generators/plugin_migration/USAGE +45 -0
  48. data/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +79 -0
  49. data/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +13 -0
  50. data/vendor/plugins/engines/init.rb +34 -47
  51. data/vendor/plugins/engines/install.rb +32 -0
  52. data/vendor/plugins/engines/lib/engines/{ruby_extensions.rb → deprecated_config_support.rb} +135 -113
  53. data/vendor/plugins/engines/lib/engines/plugin.rb +214 -0
  54. data/vendor/plugins/engines/lib/engines/plugin_list.rb +31 -0
  55. data/vendor/plugins/engines/lib/engines/plugin_migrator.rb +60 -0
  56. data/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +19 -0
  57. data/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +143 -0
  58. data/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +155 -0
  59. data/vendor/plugins/engines/lib/engines/rails_extensions/public_asset_helpers.rb +116 -0
  60. data/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +20 -0
  61. data/vendor/plugins/engines/lib/engines/rails_extensions/rails_initializer.rb +86 -0
  62. data/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +77 -0
  63. data/vendor/plugins/engines/lib/engines/rails_extensions/templates.rb +140 -0
  64. data/vendor/plugins/engines/lib/engines/rails_extensions.rb +6 -0
  65. data/vendor/plugins/engines/lib/engines/testing.rb +88 -0
  66. data/vendor/plugins/engines/lib/engines.rb +281 -425
  67. data/vendor/plugins/engines/tasks/engines.rake +108 -137
  68. metadata +218 -250
  69. data/db/ROOT/perso.txt +0 -214
  70. data/public/images/indicator.gif +0 -0
  71. data/public/images/orange_by_darren_Hester_350o.jpg +0 -0
  72. data/public/images/smile.png +0 -0
  73. data/vendor/plugins/engines/generators/engine/USAGE +0 -26
  74. data/vendor/plugins/engines/generators/engine/engine_generator.rb +0 -199
  75. data/vendor/plugins/engines/generators/engine/templates/README +0 -85
  76. data/vendor/plugins/engines/generators/engine/templates/init_engine.erb +0 -15
  77. data/vendor/plugins/engines/generators/engine/templates/install.erb +0 -4
  78. data/vendor/plugins/engines/generators/engine/templates/lib/engine.erb +0 -6
  79. data/vendor/plugins/engines/generators/engine/templates/licenses/GPL +0 -18
  80. data/vendor/plugins/engines/generators/engine/templates/licenses/LGPL +0 -19
  81. data/vendor/plugins/engines/generators/engine/templates/licenses/MIT +0 -22
  82. data/vendor/plugins/engines/generators/engine/templates/licenses/None +0 -1
  83. data/vendor/plugins/engines/generators/engine/templates/public/javascripts/engine.js +0 -0
  84. data/vendor/plugins/engines/generators/engine/templates/public/stylesheets/engine.css +0 -0
  85. data/vendor/plugins/engines/generators/engine/templates/tasks/engine.rake +0 -0
  86. data/vendor/plugins/engines/generators/engine/templates/test/test_helper.erb +0 -17
  87. data/vendor/plugins/engines/lib/bundles/require_resource.rb +0 -124
  88. data/vendor/plugins/engines/lib/bundles.rb +0 -77
  89. data/vendor/plugins/engines/lib/engines/action_mailer_extensions.rb +0 -140
  90. data/vendor/plugins/engines/lib/engines/action_view_extensions.rb +0 -141
  91. data/vendor/plugins/engines/lib/engines/active_record_extensions.rb +0 -21
  92. data/vendor/plugins/engines/lib/engines/dependencies_extensions.rb +0 -129
  93. data/vendor/plugins/engines/lib/engines/migration_extensions.rb +0 -53
  94. data/vendor/plugins/engines/lib/engines/routing_extensions.rb +0 -28
  95. data/vendor/plugins/engines/lib/engines/testing_extensions.rb +0 -327
  96. data/vendor/plugins/engines/tasks/deprecated_engines.rake +0 -7
  97. data/vendor/plugins/engines/test/action_view_extensions_test.rb +0 -9
  98. data/vendor/plugins/engines/test/ruby_extensions_test.rb +0 -115
  99. data/vendor/plugins/guid/README.TXT +0 -29
  100. data/vendor/plugins/guid/init.rb +0 -30
  101. data/vendor/plugins/guid/lib/usesguid.rb +0 -37
  102. data/vendor/plugins/guid/lib/uuid22.rb +0 -43
  103. data/vendor/plugins/guid/lib/uuidtools.rb +0 -572
  104. data/vendor/plugins/responds_to_parent/MIT-LICENSE +0 -20
  105. data/vendor/plugins/responds_to_parent/README +0 -42
  106. data/vendor/plugins/responds_to_parent/Rakefile +0 -22
  107. data/vendor/plugins/responds_to_parent/init.rb +0 -1
  108. data/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +0 -46
  109. data/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +0 -115
@@ -1,572 +0,0 @@
1
- #--
2
- # Copyright (c) 2005 Robert Aman
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- UUID_TOOLS_VERSION = "1.0.0"
25
-
26
- $:.unshift(File.dirname(__FILE__))
27
-
28
- require 'uri'
29
- require 'time'
30
- require 'thread'
31
- require 'digest/sha1'
32
- require 'digest/md5'
33
-
34
- # Because it's impossible to hype a UUID generator on its genuine merits,
35
- # I give you... Really bad ASCII art in the comments:
36
- #
37
- #
38
- # \
39
- # /
40
- # +
41
- # ]
42
- # ]
43
- # |
44
- # /
45
- # Mp___
46
- # `~0NNp,
47
- # __ggM'
48
- # g0M~"`
49
- # ]0M*-
50
- #
51
- # ___
52
- # _g000M00g,
53
- # j0M~ ~M&
54
- # j0M" ~N,
55
- # j0P M&
56
- # jM 1
57
- # j0 ]1
58
- # .0P 0,
59
- # 00' M&
60
- # 0M ]0L
61
- # ]0f ___ M0
62
- # M0NN0M00MMM~"'M 0&
63
- # `~ ~0 ]0,
64
- # ]M ]0&
65
- # M& M0,
66
- # ____gp_ M& M0_
67
- # __p0MPM8MM&_ M/ ^0&_
68
- # gN"` M0N_j0, MM&__
69
- # _gF `~M0P` __ M00g
70
- # g0' gM0&, ~M0&
71
- # _pM` 0, ]M1 "00&
72
- # _00 /g1MMgj01 ]0MI
73
- # _0F t"M,7MMM 00I
74
- # g0' _ N&j& 40'
75
- # g0' _p0Mq_ ' N0QQNM#g,
76
- # 0' _g0000000g__ ~M@MMM000g
77
- # f _jM00@` ~M0000Mgppg, "P00&
78
- # | g000~ `~M000000&_ ~0&
79
- # ]M _M00F "00MM` ~#&
80
- # `0L m000F #E "0f
81
- # 9r j000M` 40, 00
82
- # ]0g_ j00M` ^M0MNggp#gqpg M0&
83
- # ~MPM0f ~M000000000g_ ,_ygg&M00f
84
- # `~~~M00000000000000
85
- # `M0000000000f
86
- # ~@@@MF~`
87
- #
88
- #
89
-
90
- #= uuidtools.rb
91
- #
92
- # UUIDTools was designed to be a simple library for generating any
93
- # of the various types of UUIDs. It conforms to RFC 4122 whenever
94
- # possible.
95
- #
96
- #== Example
97
- # UUID.md5_create(UUID_DNS_NAMESPACE, "www.widgets.com")
98
- # => #<UUID:0x287576 UUID:3d813cbb-47fb-32ba-91df-831e1593ac29>
99
- # UUID.sha1_create(UUID_DNS_NAMESPACE, "www.widgets.com")
100
- # => #<UUID:0x2a0116 UUID:21f7f8de-8051-5b89-8680-0195ef798b6a>
101
- # UUID.timestamp_create
102
- # => #<UUID:0x2adfdc UUID:64a5189c-25b3-11da-a97b-00c04fd430c8>
103
- # UUID.random_create
104
- # => #<UUID:0x19013a UUID:984265dc-4200-4f02-ae70-fe4f48964159>
105
- class UUID
106
- @@mac_address = nil
107
- @@last_timestamp = nil
108
- @@last_node_id = nil
109
- @@last_clock_sequence = nil
110
- @@state_file = nil
111
- @@mutex = Mutex.new
112
-
113
- def initialize(time_low, time_mid, time_hi_and_version,
114
- clock_seq_hi_and_reserved, clock_seq_low, nodes)
115
- unless time_low >= 0 && time_low < 4294967296
116
- raise ArgumentError,
117
- "Expected unsigned 32-bit number for time_low, got #{time_low}."
118
- end
119
- unless time_mid >= 0 && time_mid < 65536
120
- raise ArgumentError,
121
- "Expected unsigned 16-bit number for time_mid, got #{time_mid}."
122
- end
123
- unless time_hi_and_version >= 0 && time_hi_and_version < 65536
124
- raise ArgumentError,
125
- "Expected unsigned 16-bit number for time_hi_and_version, " +
126
- "got #{time_hi_and_version}."
127
- end
128
- unless clock_seq_hi_and_reserved >= 0 && clock_seq_hi_and_reserved < 256
129
- raise ArgumentError,
130
- "Expected unsigned 8-bit number for clock_seq_hi_and_reserved, " +
131
- "got #{clock_seq_hi_and_reserved}."
132
- end
133
- unless clock_seq_low >= 0 && clock_seq_low < 256
134
- raise ArgumentError,
135
- "Expected unsigned 8-bit number for clock_seq_low, " +
136
- "got #{clock_seq_low}."
137
- end
138
- unless nodes.respond_to? :size
139
- raise ArgumentError,
140
- "Expected nodes to respond to :size."
141
- end
142
- unless nodes.size == 6
143
- raise ArgumentError,
144
- "Expected nodes to have size of 6."
145
- end
146
- for node in nodes
147
- unless node >= 0 && node < 256
148
- raise ArgumentError,
149
- "Expected unsigned 8-bit number for each node, " +
150
- "got #{node}."
151
- end
152
- end
153
- @time_low = time_low
154
- @time_mid = time_mid
155
- @time_hi_and_version = time_hi_and_version
156
- @clock_seq_hi_and_reserved = clock_seq_hi_and_reserved
157
- @clock_seq_low = clock_seq_low
158
- @nodes = nodes
159
- end
160
-
161
- attr_accessor :time_low
162
- attr_accessor :time_mid
163
- attr_accessor :time_hi_and_version
164
- attr_accessor :clock_seq_hi_and_reserved
165
- attr_accessor :clock_seq_low
166
- attr_accessor :nodes
167
-
168
- # Parses a UUID from a string.
169
- def UUID.parse(uuid_string)
170
- unless uuid_string.kind_of? String
171
- raise ArgumentError,
172
- "Expected String, got #{uuid_string.class.name} instead."
173
- end
174
- uuid_components = uuid_string.downcase.scan(
175
- Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-" +
176
- "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$")).first
177
- raise ArgumentError, "Invalid UUID format." if uuid_components.nil?
178
- time_low = uuid_components[0].to_i(16)
179
- time_mid = uuid_components[1].to_i(16)
180
- time_hi_and_version = uuid_components[2].to_i(16)
181
- clock_seq_hi_and_reserved = uuid_components[3].to_i(16)
182
- clock_seq_low = uuid_components[4].to_i(16)
183
- nodes = []
184
- for i in 0..5
185
- nodes << uuid_components[5][(i * 2)..(i * 2) + 1].to_i(16)
186
- end
187
- return UUID.new(time_low, time_mid, time_hi_and_version,
188
- clock_seq_hi_and_reserved, clock_seq_low, nodes)
189
- end
190
-
191
- # Parses a UUID from a raw byte string.
192
- def UUID.parse_raw(raw_string)
193
- unless raw_string.kind_of? String
194
- raise ArgumentError,
195
- "Expected String, got #{raw_string.class.name} instead."
196
- end
197
- integer = UUID.convert_byte_string_to_int(raw_string)
198
-
199
- time_low = (integer >> 96) & 0xFFFFFFFF
200
- time_mid = (integer >> 80) & 0xFFFF
201
- time_hi_and_version = (integer >> 64) & 0xFFFF
202
- clock_seq_hi_and_reserved = (integer >> 56) & 0xFF
203
- clock_seq_low = (integer >> 48) & 0xFF
204
- nodes = []
205
- for i in 0..5
206
- nodes << ((integer >> (40 - (i * 8))) & 0xFF)
207
- end
208
- return UUID.new(time_low, time_mid, time_hi_and_version,
209
- clock_seq_hi_and_reserved, clock_seq_low, nodes)
210
- end
211
-
212
- # Creates a UUID from a random value.
213
- def UUID.random_create()
214
- new_uuid = UUID.parse_raw(UUID.true_random)
215
- new_uuid.time_hi_and_version &= 0x0FFF
216
- new_uuid.time_hi_and_version |= (4 << 12)
217
- new_uuid.clock_seq_hi_and_reserved &= 0x3F
218
- new_uuid.clock_seq_hi_and_reserved |= 0x80
219
- return new_uuid
220
- end
221
-
222
- # Creates a UUID from a timestamp.
223
- def UUID.timestamp_create(timestamp=nil)
224
- # We need a lock here to prevent two threads from ever
225
- # getting the same timestamp.
226
- @@mutex.synchronize do
227
- # Always use GMT to generate UUIDs.
228
- if timestamp.nil?
229
- gmt_timestamp = Time.now.gmtime
230
- else
231
- gmt_timestamp = timestamp.gmtime
232
- end
233
- # Convert to 100 nanosecond blocks
234
- gmt_timestamp_100_nanoseconds = (gmt_timestamp.tv_sec * 10000000) +
235
- (gmt_timestamp.tv_usec * 10) + 0x01B21DD213814000
236
- nodes = UUID.get_mac_address.split(":").collect do |octet|
237
- octet.to_i(16)
238
- end
239
- node_id = 0
240
- for i in 0..5
241
- node_id += (nodes[i] << (40 - (i * 8)))
242
- end
243
- clock_sequence = @@last_clock_sequence
244
- if clock_sequence.nil?
245
- clock_sequence = UUID.convert_byte_string_to_int(UUID.true_random)
246
- end
247
- if @@last_node_id != nil && @@last_node_id != node_id
248
- # The node id has changed. Change the clock id.
249
- clock_sequence = UUID.convert_byte_string_to_int(UUID.true_random)
250
- elsif @@last_timestamp != nil &&
251
- gmt_timestamp_100_nanoseconds <= @@last_timestamp
252
- clock_sequence = clock_sequence + 1
253
- end
254
- @@last_timestamp = gmt_timestamp_100_nanoseconds
255
- @@last_node_id = node_id
256
- @@last_clock_sequence = clock_sequence
257
-
258
- time_low = gmt_timestamp_100_nanoseconds & 0xFFFFFFFF
259
- time_mid = ((gmt_timestamp_100_nanoseconds >> 32) & 0xFFFF)
260
- time_hi_and_version = ((gmt_timestamp_100_nanoseconds >> 48) & 0x0FFF)
261
- time_hi_and_version |= (1 << 12)
262
- clock_seq_low = clock_sequence & 0xFF;
263
- clock_seq_hi_and_reserved = (clock_sequence & 0x3F00) >> 8
264
- clock_seq_hi_and_reserved |= 0x80
265
-
266
- return UUID.new(time_low, time_mid, time_hi_and_version,
267
- clock_seq_hi_and_reserved, clock_seq_low, nodes)
268
- end
269
- end
270
-
271
- # Creates a UUID using the MD5 hash. (Version 3)
272
- def UUID.md5_create(namespace, name)
273
- return UUID.create_from_hash(Digest::MD5, namespace, name)
274
- end
275
-
276
- # Creates a UUID using the SHA1 hash. (Version 5)
277
- def UUID.sha1_create(namespace, name)
278
- return UUID.create_from_hash(Digest::SHA1, namespace, name)
279
- end
280
-
281
- # This method applies only to version 1 UUIDs.
282
- # Checks if the node ID was generated from a random number
283
- # or from an IEEE 802 address (MAC address).
284
- # Always returns false for UUIDs that aren't version 1.
285
- # This should not be confused with version 4 UUIDs where
286
- # more than just the node id is random.
287
- def random_node_id?
288
- return false if self.version != 1
289
- return ((self.nodes.first & 0x01) == 1)
290
- end
291
-
292
- # Returns true if this UUID is the
293
- # nil UUID (00000000-0000-0000-0000-000000000000).
294
- def nil_uuid?
295
- return false if self.time_low != 0
296
- return false if self.time_mid != 0
297
- return false if self.time_hi_and_version != 0
298
- return false if self.clock_seq_hi_and_reserved != 0
299
- return false if self.clock_seq_low != 0
300
- self.nodes.each do |node|
301
- return false if node != 0
302
- end
303
- return true
304
- end
305
-
306
- # Returns the UUID version type.
307
- # Possible values:
308
- # 1 - Time-based with unique or random host identifier
309
- # 2 - DCE Security version (with POSIX UIDs)
310
- # 3 - Name-based (MD5 hash)
311
- # 4 - Random
312
- # 5 - Name-based (SHA-1 hash)
313
- def version
314
- return (time_hi_and_version >> 12)
315
- end
316
-
317
- # Returns the UUID variant.
318
- # Possible values:
319
- # 0b000 - Reserved, NCS backward compatibility.
320
- # 0b100 - The variant specified in this document.
321
- # 0b110 - Reserved, Microsoft Corporation backward compatibility.
322
- # 0b111 - Reserved for future definition.
323
- def variant
324
- variant_raw = (clock_seq_hi_and_reserved >> 5)
325
- result = nil
326
- if (variant_raw >> 2) == 0
327
- result = 0x000
328
- elsif (variant_raw >> 1) == 2
329
- result = 0x100
330
- else
331
- result = variant_raw
332
- end
333
- return (result >> 6)
334
- end
335
-
336
- # Returns true if this UUID is valid.
337
- def valid?
338
- if [0b000, 0b100, 0b110, 0b111].include?(self.variant) &&
339
- (1..5).include?(self.version)
340
- return true
341
- else
342
- return false
343
- end
344
- end
345
-
346
- # Returns the IEEE 802 address used to generate this UUID or
347
- # nil if a MAC address was not used.
348
- def mac_address
349
- return nil if self.version != 1
350
- return nil if self.random_node_id?
351
- return (self.nodes.collect do |node|
352
- sprintf("%2.2x", node)
353
- end).join(":")
354
- end
355
-
356
- # Returns the timestamp used to generate this UUID
357
- def timestamp
358
- return nil if self.version != 1
359
- gmt_timestamp_100_nanoseconds = 0
360
- gmt_timestamp_100_nanoseconds +=
361
- ((self.time_hi_and_version & 0x0FFF) << 48)
362
- gmt_timestamp_100_nanoseconds += (self.time_mid << 32)
363
- gmt_timestamp_100_nanoseconds += self.time_low
364
- return Time.at(
365
- (gmt_timestamp_100_nanoseconds - 0x01B21DD213814000) / 10000000.0)
366
- end
367
-
368
- # Compares two UUIDs lexically
369
- def <=>(other_uuid)
370
- check = self.time_low <=> other_uuid.time_low
371
- return check if check != 0
372
- check = self.time_mid <=> other_uuid.time_mid
373
- return check if check != 0
374
- check = self.time_hi_and_version <=> other_uuid.time_hi_and_version
375
- return check if check != 0
376
- check = self.clock_seq_hi_and_reserved <=>
377
- other_uuid.clock_seq_hi_and_reserved
378
- return check if check != 0
379
- check = self.clock_seq_low <=> other_uuid.clock_seq_low
380
- return check if check != 0
381
- for i in 0..5
382
- if (self.nodes[i] < other_uuid.nodes[i])
383
- return -1
384
- end
385
- if (self.nodes[i] > other_uuid.nodes[i])
386
- return 1
387
- end
388
- end
389
- return 0
390
- end
391
-
392
- # Returns a representation of the object's state
393
- def inspect
394
- return "#<UUID:0x#{self.object_id.to_s(16)} UUID:#{self.to_s}>"
395
- end
396
-
397
- # Returns the hex digest of the UUID object.
398
- def hexdigest
399
- return self.to_i.to_s(16)
400
- end
401
-
402
- # Returns the raw bytes that represent this UUID.
403
- def raw
404
- return UUID.convert_int_to_byte_string(self.to_i, 16)
405
- end
406
-
407
- # Returns a string representation for this UUID.
408
- def to_s
409
- result = sprintf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", @time_low, @time_mid,
410
- @time_hi_and_version, @clock_seq_hi_and_reserved, @clock_seq_low);
411
- for i in 0..5
412
- result << sprintf("%2.2x", @nodes[i])
413
- end
414
- return result
415
- end
416
-
417
- # Returns an integer representation for this UUID.
418
- def to_i
419
- bytes = (time_low << 96) + (time_mid << 80) +
420
- (time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) +
421
- (clock_seq_low << 48)
422
- for i in 0..5
423
- bytes += (nodes[i] << (40 - (i * 8)))
424
- end
425
- return bytes
426
- end
427
-
428
- # Returns a URI for this UUID.
429
- def to_uri
430
- return URI.parse(self.to_uri_string)
431
- end
432
-
433
- # Returns a URI string for this UUID.
434
- def to_uri_string
435
- return "urn:uuid:#{self.to_s}"
436
- end
437
-
438
- def UUID.create_from_hash(hash_class, namespace, name) #:nodoc:
439
- if hash_class == Digest::MD5
440
- version = 3
441
- elsif hash_class == Digest::SHA1
442
- version = 5
443
- else
444
- raise ArgumentError,
445
- "Expected Digest::SHA1 or Digest::MD5, got #{hash_class.name}."
446
- end
447
- hash = hash_class.new
448
- hash.update(namespace.raw)
449
- hash.update(name)
450
- hash_string = hash.to_s[0..31]
451
- new_uuid = UUID.parse("#{hash_string[0..7]}-#{hash_string[8..11]}-" +
452
- "#{hash_string[12..15]}-#{hash_string[16..19]}-#{hash_string[20..31]}")
453
-
454
- new_uuid.time_hi_and_version &= 0x0FFF
455
- new_uuid.time_hi_and_version |= (version << 12)
456
- new_uuid.clock_seq_hi_and_reserved &= 0x3F
457
- new_uuid.clock_seq_hi_and_reserved |= 0x80
458
- return new_uuid
459
- end
460
-
461
- # Returns the MAC address of the current computer's network card.
462
- # Returns nil if a MAC address could not be found.
463
- def UUID.get_mac_address #:nodoc:
464
- if @@mac_address.nil?
465
- if RUBY_PLATFORM =~ /win/ && !(RUBY_PLATFORM =~ /darwin/)
466
- begin
467
- ifconfig_output = `ipconfig /all`
468
- mac_addresses = ifconfig_output.scan(
469
- Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join("-")})"))
470
- if mac_addresses.size > 0
471
- @@mac_address = mac_addresses.first.first.downcase.gsub(/-/, ":")
472
- end
473
- rescue
474
- end
475
- else
476
- begin
477
- mac_addresses = []
478
- if File.exists?('/sbin/ifconfig')
479
- ifconfig_output =
480
- `/sbin/ifconfig 2>&1`
481
- mac_addresses = ifconfig_output.scan(
482
- Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
483
- if mac_addresses.size == 0
484
- ifconfig_output =
485
- `/sbin/ifconfig | grep HWaddr | cut -c39- 2>&1`
486
- mac_addresses = ifconfig_output.scan(
487
- Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
488
- end
489
- else
490
- ifconfig_output =
491
- `ifconfig 2>&1`
492
- mac_addresses = ifconfig_output.scan(
493
- Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
494
- if mac_addresses.size == 0
495
- ifconfig_output =
496
- `ifconfig | grep HWaddr | cut -c39- 2>&1`
497
- mac_addresses = ifconfig_output.scan(
498
- Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
499
- end
500
- end
501
- if mac_addresses.size > 0
502
- @@mac_address = mac_addresses.first.first
503
- end
504
- rescue
505
- end
506
- end
507
- end
508
- return @@mac_address
509
- end
510
-
511
- # Returns 128 bits of highly unpredictable data.
512
- # The random number generator isn't perfect, but it's
513
- # much, much better than the built-in pseudorandom number generators.
514
- def UUID.true_random #:nodoc:
515
- require 'benchmark'
516
- hash = Digest::SHA1.new
517
- performance = Benchmark.measure do
518
- hash.update(rand.to_s)
519
- hash.update(srand.to_s)
520
- hash.update(rand.to_s)
521
- hash.update(srand.to_s)
522
- hash.update(Time.now.to_s)
523
- hash.update(rand.to_s)
524
- hash.update(self.object_id.to_s)
525
- hash.update(rand.to_s)
526
- hash.update(hash.object_id.to_s)
527
- hash.update(self.methods.inspect)
528
- hash.update($:.to_s)
529
- begin
530
- random_device = nil
531
- if File.exists? "/dev/urandom"
532
- random_device = File.open "/dev/urandom", "r"
533
- elsif File.exists? "/dev/random"
534
- random_device = File.open "/dev/random", "r"
535
- end
536
- hash.update(random_device.read(20)) if random_device != nil
537
- rescue
538
- end
539
- begin
540
- srand(hash.to_s.to_i(16) >> 128)
541
- rescue
542
- end
543
- hash.update(rand.to_s)
544
- hash.update(UUID.true_random) if (rand(2) == 0)
545
- end
546
- hash.update(performance.real.to_s)
547
- hash.update(performance.inspect)
548
- return UUID.convert_int_to_byte_string(hash.to_s[4..35].to_i(16), 16)
549
- end
550
-
551
- def UUID.convert_int_to_byte_string(integer, size) #:nodoc:
552
- byte_string = ""
553
- for i in 0..(size - 1)
554
- byte_string << ((integer >> (((size - 1) - i) * 8)) & 0xFF)
555
- end
556
- return byte_string
557
- end
558
-
559
- def UUID.convert_byte_string_to_int(byte_string) #:nodoc:
560
- integer = 0
561
- size = byte_string.size
562
- for i in 0..(size - 1)
563
- integer += (byte_string[i] << (((size - 1) - i) * 8))
564
- end
565
- return integer
566
- end
567
- end
568
-
569
- UUID_DNS_NAMESPACE = UUID.parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
570
- UUID_URL_NAMESPACE = UUID.parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
571
- UUID_OID_NAMESPACE = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
572
- UUID_X500_NAMESPACE = UUID.parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
@@ -1,20 +0,0 @@
1
- Copyright (c) 2006 Sean Treadway
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.
@@ -1,42 +0,0 @@
1
- RespondsToParent
2
- ================
3
-
4
- Adds responds_to_parent to your controller to respond to the parent document of your page.
5
- Make Ajaxy file uploads by posting the form to a hidden iframe, and respond with
6
- RJS to the parent window.
7
-
8
- Example
9
- =======
10
-
11
- Controller:
12
-
13
- class Test < ActionController::Base
14
- def main
15
- end
16
-
17
- def form_action
18
- # Do stuff with params[:uploaded_file]
19
-
20
- responds_to_parent do
21
- render :update do |page|
22
- page << "alert($('stuff').innerHTML)"
23
- end
24
- end
25
- end
26
- end
27
-
28
- main.rhtml:
29
-
30
- <html>
31
- <body>
32
- <div id="stuff">Here is some stuff</div>
33
-
34
- <form target="frame" action="form_action">
35
- <input type="file" name="uploaded_file"/>
36
- <input type="submit"/>
37
- </form>
38
-
39
- <iframe id='frame' name="frame"></iframe>
40
- </body>
41
- </html>
42
-
@@ -1,22 +0,0 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- desc 'Default: run unit tests.'
6
- task :default => :test
7
-
8
- desc 'Test the responds_to_parent plugin.'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.pattern = 'test/**/*_test.rb'
12
- t.verbose = true
13
- end
14
-
15
- desc 'Generate documentation for the responds_to_parent plugin.'
16
- Rake::RDocTask.new(:rdoc) do |rdoc|
17
- rdoc.rdoc_dir = 'rdoc'
18
- rdoc.title = 'RespondsToParent'
19
- rdoc.options << '--line-numbers' << '--inline-source'
20
- rdoc.rdoc_files.include('README')
21
- rdoc.rdoc_files.include('lib/**/*.rb')
22
- end
@@ -1 +0,0 @@
1
- ActionController::Base.send :include, RespondsToParent