mack-facets 0.6.0.1 → 0.6.1

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 (52) hide show
  1. data/README +4 -3
  2. data/lib/{english_extensions → mack-facets/english_extensions}/inflect.rb +0 -0
  3. data/lib/{english_extensions → mack-facets/english_extensions}/numerals.rb +0 -0
  4. data/lib/{extensions → mack-facets/extensions}/array.rb +0 -0
  5. data/lib/{extensions → mack-facets/extensions}/class.rb +0 -0
  6. data/lib/{extensions → mack-facets/extensions}/hash.rb +0 -0
  7. data/lib/{extensions → mack-facets/extensions}/kernel.rb +0 -0
  8. data/lib/{extensions → mack-facets/extensions}/math.rb +0 -0
  9. data/lib/{extensions → mack-facets/extensions}/module.rb +0 -0
  10. data/lib/mack-facets/extensions/nil_class.rb +7 -0
  11. data/lib/{extensions → mack-facets/extensions}/object.rb +0 -0
  12. data/lib/{extensions → mack-facets/extensions}/string.rb +0 -0
  13. data/lib/{extensions → mack-facets/extensions}/symbol.rb +0 -0
  14. data/lib/{utils → mack-facets/utils}/inflections.rb +0 -0
  15. data/lib/{utils → mack-facets/utils}/inflector.rb +0 -0
  16. data/lib/{utils → mack-facets/utils}/options_merger.rb +0 -0
  17. data/lib/mack-facets/utils/registry_list.rb +83 -0
  18. data/lib/mack-facets/utils/registry_map.rb +94 -0
  19. data/lib/mack-facets.rb +11 -8
  20. metadata +29 -48
  21. data/doc/classes/Array.html +0 -408
  22. data/doc/classes/Class.html +0 -233
  23. data/doc/classes/Hash.html +0 -233
  24. data/doc/classes/Kernel.html +0 -184
  25. data/doc/classes/Mack/Utils/Inflector.html +0 -382
  26. data/doc/classes/Math.html +0 -188
  27. data/doc/classes/Module.html +0 -203
  28. data/doc/classes/Object.html +0 -558
  29. data/doc/classes/String.html +0 -451
  30. data/doc/classes/Symbol.html +0 -148
  31. data/doc/created.rid +0 -1
  32. data/doc/files/README.html +0 -111
  33. data/doc/files/lib/english_extensions/inflect_rb.html +0 -101
  34. data/doc/files/lib/english_extensions/numerals_rb.html +0 -101
  35. data/doc/files/lib/extensions/array_rb.html +0 -101
  36. data/doc/files/lib/extensions/class_rb.html +0 -101
  37. data/doc/files/lib/extensions/hash_rb.html +0 -108
  38. data/doc/files/lib/extensions/kernel_rb.html +0 -109
  39. data/doc/files/lib/extensions/math_rb.html +0 -101
  40. data/doc/files/lib/extensions/module_rb.html +0 -101
  41. data/doc/files/lib/extensions/object_rb.html +0 -101
  42. data/doc/files/lib/extensions/string_rb.html +0 -101
  43. data/doc/files/lib/extensions/symbol_rb.html +0 -101
  44. data/doc/files/lib/mack-facets_rb.html +0 -120
  45. data/doc/files/lib/utils/inflections_rb.html +0 -101
  46. data/doc/files/lib/utils/inflector_rb.html +0 -108
  47. data/doc/files/lib/utils/options_merger_rb.html +0 -101
  48. data/doc/fr_class_index.html +0 -36
  49. data/doc/fr_file_index.html +0 -42
  50. data/doc/fr_method_index.html +0 -75
  51. data/doc/index.html +0 -24
  52. data/doc/rdoc-style.css +0 -208
data/README CHANGED
@@ -1,3 +1,4 @@
1
- README
2
- ========================================================================
3
- mack-facets was developed by: markbates
1
+ Mack facets is a collection of Ruby extensions and utilities to enhance Mack
2
+ and any other Ruby application.
3
+
4
+ Mack-facets leverages the 'facets' and 'english' gems.
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ class NilClass
2
+
3
+ def to_param
4
+ raise NoMethodError.new(:to_param)
5
+ end
6
+
7
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,83 @@
1
+ require 'singleton'
2
+ module Mack
3
+ module Utils
4
+ # This is a general purpose Singleton Registry class.
5
+ # It takes the drudgery out of creating registry classes, that
6
+ # are, let's face it, all pretty much the same.
7
+ class RegistryList
8
+ include Singleton
9
+ include Extlib::Hook
10
+
11
+ # The list of registered items
12
+ attr_reader :registered_items
13
+
14
+ def initialize # :nodoc:
15
+ reset!
16
+ end
17
+
18
+ # Override this method to set the initial state of the registered_items Array.
19
+ # By default this list is empty.
20
+ def initial_state
21
+ []
22
+ end
23
+
24
+ # Resets the registered_items list to the list specified by the initial_state method.
25
+ def reset!
26
+ @registered_items = self.initial_state.dup
27
+ end
28
+
29
+ # Adds an object to the list at a specified position. By default the position is last.
30
+ def add(klass, position = self.registered_items.size)
31
+ self.registered_items.insert(position, klass)
32
+ self.registered_items.uniq!
33
+ self.registered_items.compact!
34
+ end
35
+
36
+ # Removes an object from the list.
37
+ def remove(klass)
38
+ self.registered_items.delete(klass)
39
+ end
40
+
41
+ class << self
42
+
43
+ # Returns the list of registered items.
44
+ def registered_items
45
+ self.instance.registered_items
46
+ end
47
+
48
+ # Emptys out the list of registered_items.
49
+ def clear!
50
+ registered_items.clear
51
+ end
52
+
53
+ # Resets the registered_items list to the list specified by the initial_state method.
54
+ def reset!
55
+ self.instance.reset!
56
+ end
57
+
58
+ # Adds an object to the list at a specified position. By default the position is last.
59
+ def add(klass, position = registered_items.size)
60
+ self.instance.add(klass, position)
61
+ end
62
+
63
+ # Removes an object from the list.
64
+ def remove(klass)
65
+ self.instance.remove(klass)
66
+ end
67
+
68
+ # Moves an object to the top of the registered_items list.
69
+ def move_to_top(klass)
70
+ self.instance.add(klass, 0)
71
+ end
72
+
73
+ # Moves an object to the bottom of the registered_items list.
74
+ def move_to_bottom(klass)
75
+ remove(klass)
76
+ self.instance.add(klass)
77
+ end
78
+
79
+ end
80
+
81
+ end # RegistryList
82
+ end # Utils
83
+ end # Mack
@@ -0,0 +1,94 @@
1
+ require 'singleton'
2
+ module Mack
3
+ module Utils
4
+
5
+ #
6
+ # Provides a convenient way to register items in a map.
7
+ #
8
+ # The structure of the registry is { :tag => [content] }, and the items
9
+ # within the array can be arranged anyway the user sees fit.
10
+ #
11
+ # ds - july 2008
12
+ #
13
+ class RegistryMap
14
+ include Singleton
15
+ include Extlib::Hook
16
+
17
+ # The list of registered items
18
+ attr_reader :registered_items
19
+
20
+ def initialize # :nodoc:
21
+ reset!
22
+ end
23
+
24
+ # Override this method to set the initial state of the registered_items Array.
25
+ # By default this list is empty.
26
+ def initial_state
27
+ {}
28
+ end
29
+
30
+ # Resets the registered_items list to the list specified by the initial_state method.
31
+ def reset!
32
+ @registered_items = self.initial_state.dup
33
+ end
34
+
35
+ # Adds an object to the list at a specified position. By default the position is last.
36
+ def add(tag, klass, position = -1)
37
+ @registered_items[tag] ||= []
38
+ arr = self.registered_items[tag]
39
+ position = arr.size if position == -1
40
+
41
+ arr.insert(position, klass)
42
+ arr.uniq!
43
+ arr.compact!
44
+ end
45
+
46
+ # Removes an object from the list.
47
+ def remove(tag, klass)
48
+ return false if @registered_items[tag] == nil
49
+ self.registered_items[tag].delete(klass)
50
+ end
51
+
52
+ class << self
53
+
54
+ # Returns the list of registered items.
55
+ def registered_items
56
+ self.instance.registered_items
57
+ end
58
+
59
+ # Emptys out the list of registered_items.
60
+ def clear!
61
+ registered_items.clear
62
+ end
63
+
64
+ # Resets the registered_items list to the list specified by the initial_state method.
65
+ def reset!
66
+ self.instance.reset!
67
+ end
68
+
69
+ # Adds an object to the list at a specified position. By default the position is last.
70
+ def add(tag, klass, position = -1)
71
+ self.instance.add(tag, klass, position)
72
+ end
73
+
74
+ # Removes an object from the list.
75
+ def remove(tag, klass)
76
+ self.instance.remove(tag, klass)
77
+ end
78
+
79
+ # Moves an object to the top of the registered_items list.
80
+ def move_to_top(tag, klass)
81
+ self.instance.add(tag, klass, 0)
82
+ end
83
+
84
+ # Moves an object to the bottom of the registered_items list.
85
+ def move_to_bottom(tag, klass)
86
+ remove(tag, klass)
87
+ self.instance.add(tag, klass)
88
+ end
89
+
90
+ end
91
+
92
+ end # RegistryMap
93
+ end # Utils
94
+ end # Mack
data/lib/mack-facets.rb CHANGED
@@ -9,23 +9,26 @@ require 'facets/hash/symbolize_keys'
9
9
  require 'facets/hash/stringify_keys'
10
10
  require 'facets/module'
11
11
  require 'facets/infinity'
12
+ require 'facets/times'
12
13
  require 'english/inflect'
13
14
  require 'english/numerals'
14
- [:inflector, :inflections, :options_merger].each do |k|
15
- path = File.join File.dirname(__FILE__), "utils", "#{k}"
16
- #puts "requiring #{path}"
15
+ require 'extlib/assertions'
16
+ require 'extlib/hook'
17
+
18
+ fl = File.join(File.dirname(__FILE__), "mack-facets")
19
+
20
+ [:inflector, :inflections, :options_merger, :registry_list, :registry_map].each do |k|
21
+ path = File.join(fl, "utils", "#{k}")
17
22
  require path
18
23
  end
19
24
 
20
- [:array, :class, :hash, :kernel, :math, :module, :object, :string, :symbol].each do |k|
21
- path = File.join File.dirname(__FILE__), "extensions", "#{k}"
22
- #puts "requiring #{path}"
25
+ [:array, :class, :hash, :kernel, :math, :module, :object, :string, :symbol, :nil_class].each do |k|
26
+ path = File.join(fl, "extensions", "#{k}")
23
27
  require path
24
28
  end
25
29
 
26
30
  [:numerals, :inflect].each do |k|
27
- path = File.join File.dirname(__FILE__), "english_extensions", "#{k}"
28
- #puts "requiring #{path}"
31
+ path = File.join(fl, "english_extensions", "#{k}")
29
32
  require path
30
33
  end
31
34
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mack-facets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.1
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - markbates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-18 00:00:00 -04:00
12
+ date: 2008-08-04 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.2.0
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: extlib
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.3
44
+ version:
35
45
  description: "mack-facets was developed by: markbates"
36
46
  email: mark@mackframework.com
37
47
  executables: []
@@ -41,54 +51,25 @@ extensions: []
41
51
  extra_rdoc_files:
42
52
  - README
43
53
  files:
44
- - lib/english_extensions/inflect.rb
45
- - lib/english_extensions/numerals.rb
46
- - lib/extensions/array.rb
47
- - lib/extensions/class.rb
48
- - lib/extensions/hash.rb
49
- - lib/extensions/kernel.rb
50
- - lib/extensions/math.rb
51
- - lib/extensions/module.rb
52
- - lib/extensions/object.rb
53
- - lib/extensions/string.rb
54
- - lib/extensions/symbol.rb
54
+ - lib/mack-facets/english_extensions/inflect.rb
55
+ - lib/mack-facets/english_extensions/numerals.rb
56
+ - lib/mack-facets/extensions/array.rb
57
+ - lib/mack-facets/extensions/class.rb
58
+ - lib/mack-facets/extensions/hash.rb
59
+ - lib/mack-facets/extensions/kernel.rb
60
+ - lib/mack-facets/extensions/math.rb
61
+ - lib/mack-facets/extensions/module.rb
62
+ - lib/mack-facets/extensions/nil_class.rb
63
+ - lib/mack-facets/extensions/object.rb
64
+ - lib/mack-facets/extensions/string.rb
65
+ - lib/mack-facets/extensions/symbol.rb
66
+ - lib/mack-facets/utils/inflections.rb
67
+ - lib/mack-facets/utils/inflector.rb
68
+ - lib/mack-facets/utils/options_merger.rb
69
+ - lib/mack-facets/utils/registry_list.rb
70
+ - lib/mack-facets/utils/registry_map.rb
55
71
  - lib/mack-facets.rb
56
- - lib/utils/inflections.rb
57
- - lib/utils/inflector.rb
58
- - lib/utils/options_merger.rb
59
72
  - README
60
- - doc/classes/Array.html
61
- - doc/classes/Class.html
62
- - doc/classes/Hash.html
63
- - doc/classes/Kernel.html
64
- - doc/classes/Mack/Utils/Inflector.html
65
- - doc/classes/Math.html
66
- - doc/classes/Module.html
67
- - doc/classes/Object.html
68
- - doc/classes/String.html
69
- - doc/classes/Symbol.html
70
- - doc/created.rid
71
- - doc/files/lib/english_extensions/inflect_rb.html
72
- - doc/files/lib/english_extensions/numerals_rb.html
73
- - doc/files/lib/extensions/array_rb.html
74
- - doc/files/lib/extensions/class_rb.html
75
- - doc/files/lib/extensions/hash_rb.html
76
- - doc/files/lib/extensions/kernel_rb.html
77
- - doc/files/lib/extensions/math_rb.html
78
- - doc/files/lib/extensions/module_rb.html
79
- - doc/files/lib/extensions/object_rb.html
80
- - doc/files/lib/extensions/string_rb.html
81
- - doc/files/lib/extensions/symbol_rb.html
82
- - doc/files/lib/mack-facets_rb.html
83
- - doc/files/lib/utils/inflections_rb.html
84
- - doc/files/lib/utils/inflector_rb.html
85
- - doc/files/lib/utils/options_merger_rb.html
86
- - doc/files/README.html
87
- - doc/fr_class_index.html
88
- - doc/fr_file_index.html
89
- - doc/fr_method_index.html
90
- - doc/index.html
91
- - doc/rdoc-style.css
92
73
  has_rdoc: true
93
74
  homepage: http://www.mackframework.com
94
75
  post_install_message: