ru_pol 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.3.0"
10
+ gem "yard", "~> 0.6.0"
11
+ gem "bundler", "~> 1.0.0"
12
+ gem "jeweler", "~> 1.5.2"
13
+ gem "rcov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rcov (0.9.9)
12
+ rspec (2.3.0)
13
+ rspec-core (~> 2.3.0)
14
+ rspec-expectations (~> 2.3.0)
15
+ rspec-mocks (~> 2.3.0)
16
+ rspec-core (2.3.1)
17
+ rspec-expectations (2.3.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.3.0)
20
+ yard (0.6.5)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.0.0)
27
+ jeweler (~> 1.5.2)
28
+ rcov
29
+ rspec (~> 2.3.0)
30
+ yard (~> 0.6.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Kane Baccigalupi
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.
data/README.rdoc ADDED
@@ -0,0 +1,126 @@
1
+ = RuPol
2
+
3
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
4
+ @@;;;;;;;;::::::::::::,,:,,,,:,,,,,,:,,,:;:,,::;';;'+#+'.,,,:+';::::::::::::,:,........,,:::::,,,,,,..,,,,,,,,,:::::::::::;;;;;;;;;#@@
5
+ @@;;;;;;;;:::::::::::::,,,,.,,:,,,,,,,::;,.`.,::;:;+###+,..;'';;;;;::::::::::::...,,,:;;;;;::::,,,.,,.,.,,,,,,,:::::::::::;;;;;;;;;#@@
6
+ @@;;;;;;;;;::::::::::::,,,,.,::,,,,,,::;```..,.:,;'#+#+:.,::+';;;;;;;;;;'''''''';:::,:;;;;;::::,,,......,,,,,,,:::::::::::;;;;;;;;;#@@
7
+ @@;;;;;;;;:::::::::::::.,,.,,::,,,,,:::..``....,,;+##++,,::++''';;;;;;;';''''''+++';::;;;::;;:::,........,,,,,,,:::::::::::;;;;;;;;#@@
8
+ @@;;;;;;;;:::::::::::.,:,:.,,,,,,,,,:,...`.....,.'+##+;,,,;+''';';;;;;;;;''''''''''+';;;;:;;;;;::,........,,,,,,:::::::::::;;;;;;;;#@@
9
+ @@;;;;;;;;:::::::::::.:.,:,:,,,,,,,,,...........,++##+,,:;#+''';;;;;;;;;;'''''''''''''';,;;;;;:::::,,.....,,,,,,:::::::::::;;;;;;;;#@@
10
+ @@;;;;;;;;::::::::::::`.,,.,,,,,:,,,,,,.......,`:###+,:,,++'';;;;;;;;;;;;;;;''''''''+++':;;;;:::::,,:,.....,,,,,::::::::::::;;;;;;;#@@
11
+ @@;;;;;;;;::::::::::::....,,,,,,:,,,,,.,......,.;+#';,,:'+';;;;;;;;;;;;;;;;;;;'''''''+++';;;;:::::::,,,....,,,,,:::::,::::::;;;;;;;#@@
12
+ @@;;;;;;;:::::::::::::..,,,,,,::,,,:,,,,.......,;++:,,::+';;;;;;::::::::::;;;;;'''''''+++';:;;;::::,,,,,....,,,,,:,,:,,,::;:;;;;;;;#@@
13
+ @@;;;;;;;;:::::::::::,,.,,,,,,,,,,,,,,,.....`..;'+;:::,+';;;;;;:::::::::::::;;;;;''''''+++;:;;::::,,,,,,,....,,,,,.,:,,,,::;;;;;;;;#@@
14
+ @@;;;;;;;;:::::::::::,,...,,,,,,,,,,,,,,.......'+;::::+'';;;;;:::::::::::::::;;;;''''''++++::;;;;::,,,,,.....,,,:,,,:,,:,::;;;;;;;;#@@
15
+ @@;;;;;;;;:::::::::::,,,.,,:::,,,,,,,,,,.,...,.;;;:::+'';;;;;::::::::::::::::;;;;'''''''+++':;;;::,,,,,,.,....,,,,,,:,,:,::;;;;;;;;#@@
16
+ @@;;;;;;;;:::::,:,:,,.,,:,,::::,,,,,,:,,,....,.;::;'+''';;;;:::::::::::::::::;;;;;'''''''+++;:;;;;::,,,.......,,,,.::::::::;;;;;;;;#@@
17
+ @@;;;;;;;;:;;.:;...,,,,::::;;::::::::,,.:....,:;::+#''''';;;;:::::::::,,:::::;;;;;;''''''+++;;;;;;;::,,,..,...`,::,,::::::;;;;;;;;;#@@
18
+ @@;;;;;;;;:;:,.`.,,,,,,:;;;;;;;;:;:::,,,,.,..,;;'##+'''';;;::::::::,,,,:,:::::;;;;;''''''++++;;;:::::,,...,..,.,,,,,.:.:::;;;;;;;;;#@@
19
+ @@;;;;;;;;::;.....,..,,,;;;;;;;;:;;;,,,:,.,.,:++##+''';;;;;;:::::::,,,,,,,:::::;'''+++'''++++':;::::::,,...,.,,,::,,,,,::::;;;;;;;;#@@
20
+ @@;;;;;;;;:;,.......,,,,,';;';;;;:;::,,:,,,,:;+'##''';;''''';::,,,,,,,,,,,,,,:''''';;''+''+++':,:::,,,,,,..,.,,:,,::,,,,:::;;;;;;;;#@@
21
+ @@;;;;;;;;;::,......,.,,,;;;;';;;;:::,::,,.,;;++#+''''''''''';:,,,,,,,,,,,,,::;;;:::;;;;''++++::,,,,,,.,:..,,,,,,:::::,,,;;;;;;;;;;#@@
22
+ @@;;;;;;;:;,,,`....,,.,,::;;;;;;;;::::::,,,:';++++''';;::,:;';;:,,,,,,,,,,,::::::::;;;;;''++++;:.....,,.,,,,,,,::,,:::,,.::;;;;;;;;#@@
23
+ @@;;;;;;;;:...``.....,,,:;::;::;:::::::,,,,;''+#++'';;:::::::::::,,,,,,,,,,::,:::;;;;'''''++++':.......,.:,,:,:::,::::,,.::;;;;;;;;#@@
24
+ @@;;;;;;;;,..,`........,::;;:;::::::;::,,,:''+++++';;;;;;;;:::,::,,,,,,,,,,,,:;;''''''+'';+++++:.......,,,,,:::::,,::::,,:;;;:;;;;;#@@
25
+ @@;;;;;;:::..,...`.....,:;;;;;;;;;'':::,,,;;;+++++';;''';''';;:,,,,,,,,,.,,,:;'+++++++++++'++++;,........,,,:;,,,:,:::,,,:;,,,.;;;;#@@
26
+ @@;;;;;;;;:.,,,...`.....::;;::;;;;::::,,:';';+'#++''''++++++++';:,,,,,,..,,:;++##########+'++++;,.........,,,::,:,,:::,,,::.,,.,;;;#@@
27
+ @@;;;;;;:;....,,........,::;':::;:::::::;';''+;+++'+++###+++++++;:,,,,,,,,:;'++;;'+#@@#@##+++++;............,':,:,,,,,,,.',.,.,,;;;#@@
28
+ @@;;;;;;;;..,......,,....,::;+';::::::;';;';'':+++++######++'''++'::,,,,,:'';;:'+#@#@#@####++++'........,,.,,::;:,,,,:,,.,,...,,;;;#@@
29
+ @@;;;;;;;;.,,.......,,,,.,,::;;;'+++'';;;;;;;':++++##@###+#''';;'';;:,,,:'';::+#@@@@@@@@###+++++..,.........,,;;::::::,.,.,..,.;;;;#@@
30
+ @@;;;;;;;;:,:..,.,,,,,,,,,,,:;:;;;''';;;;;;;;;;+++######@##@##';:;'';:::;';,:'+#@#@@@@@@@#+''''+;,.,,,,,..,,,,,:;::::::.,.,....;;;;#@@
31
+ @@;;;;;;;;::,,,.,:::,,::::,;:,,:;;;;;:;;::::::'+++####@@@@@@##@+:,:;;;:;';:,:#@:+'##:#@@@+''''''':,,.,,,...,,,::;;:::,,,......,;;;;#@@
32
+ @@;;;;;;;:::::,,:,,:::::;;;:,:::::::;;;;::::::+++++#@@@@@#+++.+#;,.;';:;';:,'+:,'+@#.'@@+'''''''',,,,,..,....,,:::::,,,......`;;;;;#@@
33
+ @@;;;;;;;:::::::;:::::::;;;:;,:::::::::,,,,,,:+'''++#@@@,##;+',:++:;;;::;';';::.#+#####';:;;;'''',,.,.,......,,,,,:::,,......;;;;;;#@@
34
+ @@;;;;;;;::::::::::::::;;:::::,,,,...,,,,,,,,:'''''+##@@'+'#':;++::;;;::;';::'###+##+'':::;;''''':,,,,....,,.,.,,,,,,,,.....,;;;;;;#@@
35
+ @@;;;;;;;;,::::::::::::::::,,,........,,,.,,,:+';';;;'##+@####';,::;;:::;'';::;'''';;;::::;;;'''';:,,.....,,:,,,,:::::,,,..,,;;;;;;#@@
36
+ @@;;;;;;,.::::::::::,:::::,...........,,:,,..:''';;::::;;''';;::::;;;;::;'';;::::;;:::::::;;'''''';;:..,..,,,::::;;;;:::::::;;;;;;;#@@
37
+ @@;;;;;:.,:,:,:::::::,:,,,.............,,,...:''';;:,,,:::::::,,::;;;;:;;';;;:::::::::::::;;''''''''';,,,,,,,,;:::;;;::::;:,:::;;;;#@@
38
+ @@;;;;;..,,,,,,:;:::,,,,,,,,,...........,..,,,;''';::,,,,,,,,,,,::;;;;::;'';;;:::::::::::;;'''''''++'';,,,,,:::::;;::::;;;;:,;:,;;;#@@
39
+ @@:;;;,..,,::,::::::,,,,,,.........,,,,....,,,;'';;;:,,,,,,,,,,::;;;;:,,:''';:::,,,:::::;;;''''''++++'';,:::::;;;::;;;:;;;;:;,;::;;#@@
40
+ @@:;;;...,,,,,:::::::,,,,,......,,:,,,..,..,,,;;'';;::,,,,,,,,,::;;;;:..,;;;;':,,,,:::::;;''''''''#'+;;';::::;;;;;;;;;;;;;:;:,,,;;;#@@
41
+ @@;;;;...,,,,,,:::::,,,,,,,,..,,:,:,,.,...,::'''''';;:::::,,,,,::;;;;:.,:;;;;;;:,,,::::::;''''''''';'';'''::;;;;';;;;';;';;:,.:,:;;#@@
42
+ @@:;;;..,..,,,,::::::::::,,,,,,,,,.,.....,,:+''''''';;:::::::,,:;;::;:::;;;;::;::,::::::;;'''''''''+''';'';;;;;;;;;;;;;'';;::,,:;;;#@@
43
+ @@,;;;,.,..,.,::::::::::::,,,,,,,,.......,,;+'''''';;;:::::::,,:;::;';;;;+@@#;;;:,,:::::;;'''''''';';;';;';;:;;;;;;;;;;;;';;:,,,;;;#@@
44
+ @@`:;;,,,,..,,:::::::::::::,,,,,,,,.......'+++'''''';;::::::::,:;;#@@#';;+'';;';::::::;;;;;''''''';;;;;;;';;:;;;;;::;';';;;;;:.,;;;#@@
45
+ @@`.;::.,,,,.,:::,,::,::,:,,,,,,..,.....,:+'+''''''';;;:::::::::':,,:;;;:,::;;;:::::::;;;;;''''''';:;;;;;;::::;;;;:,::'';;;;::.,;;;#@@
46
+ @@..:::.,,,..::,,,,,,,,,::,,,,,,,,,...,:;;''';'''''';;;:::::::::';::::,,,,:::;;:::::;;;;;;;';;;''';:';;;:;::;::;:;;,::;;;';;:::,;;;#@@
47
+ @@;.`.:,,::,,:;,,,,,,,,,:,,,,,,,,,,,,:;;;::'';'''''';;;;:;:::::::::::,,,,,,::;;;;:::;;;;;;;;;;;'';''';;;:;;::::;;;;,::::;;'';,,,;;;#@@
48
+ @@;:.....,:.,,:,..,,,.,,:,,,,,,,.,,,'';;:::':;''''';;;;;:;:::::::::::,,,.,,,:;;;;:::;;;;;;;;;;:;';';;;:::;;::,:;;;;,;:::;;;;;,,.;;;#@@
49
+ @@.;:.`...,,:.,,...,.,,,:,,,,,,,,,;+'';;::,;:''+''';;;;;;;::::::::::,,,,,,,,,:;;;;;:;;;;;;;;;;:;';+';:::::;::,,;;;',:,::;:;;:::,;;;#@@
50
+ @@,,::,...,,:,,,..,.,.,::,,,:::::;''';;;::,;;+'+'';;;;;;;;;:::::;:::,,,,,:'++':;;;;;;;;;;;;;;;:;'';,::::::;::.,;;;',:;,;::;:,,:,;;;#@@
51
+ @@:,`:::...,,,,,.....,,:,,,:::;;;;+';;::::,:'''+''';;;::;;;::::;;::'++':,:;''++;;;;;;;;;;;;;;;:';';,':::;::::,,;;;;:::,:,::::,:,;;;#@@
52
+ @@:,:,.,,.,,,,,,.....,,,.,:;;;;;;'+;;::::,,:;;'++'';;:::;;;:::;:;;+';,''',,'''++';;;:;;;;;;;;;:':;:':::;:;:::,:;;;;;.,::,,:,:,;,;;;#@@
53
+ @@:::.;:,,,,,,,,.....,,,,,::;;;;;''::::,,,,``:;;+'';;::::;;::::;;+''''+;':,::'++#';;:;;::;;;;;;'';+,:::;;;:::,:::;;;`,,,,,,,:.;:;;;#@@
54
+ @@::,,,,.,,,,,,....,.:,,,::::;;;;';:,,,,,,:'..':#+';;::::::::::;++';,.``.``.`..+++;;:;;;;;;;;;;''#';::;;:;:::,:::;;;.,:.,,,,,:::;;;#@@
55
+ @@:::.,,.,,.,,,......,,,,::;;;;;'':,,,...,.;;:;;++';;::::::::::;++,`..`````.``.,+#:;:;;;;;;;;;;''#+;:::;:;:::,::,:::.:;.,,::,:,::;;#@@
56
+ @@::::,,...,:,.....,,,::;::;:;;;;:,,.........':+##+';::::::::::+#,``;+ ;`.+#@+'##'::;;;;;;;;;;''#+;;::;;::::,,:,:::.;;..,::::.:::;#@@
57
+ @@:::.,...,,,,.....,,,,:;:::;;;:;,..,.....:;'++#+#+';::::::::::#+;@@@+##@@#@#@##@@+::::;;;;;;;'+''+;:::;:::;:,::,:,,.;,..,::::.::::#@@
58
+ @@......,,,:,....,,,,:::;;:::,,,:........,:'++++++++;::::::::::#@###++++##+++++++#+:::::;;;;;'''+'';;;:;:::::,::,,,,.;...,,:::.::::#@@
59
+ @@`,,...,:,,,...,,,,,:::,,,,:,,,........,:;'++++##++';:::::::,:##++'';''''';::;''#':::::;;;;''+'''+;;;:::::::,,:,,,,.,....,,::,::::#@@
60
+ @@`..,,,,,,.,,.,:,,,,,,,,,,..,..........:;''''+####+';:::::::,:+++;:::::::,,,,::;+':::::;;;;''+''';;;;:,;::,:,.:,,,.......:,:::::::#@@
61
+ @@..,,.....,::,,,::,:,,....,,,,,,,,,:,,:;;'''++++++#+';::::::,:'++:,,....,,,,,,:''':::::;;;''''''';;;::,::,,:,.,,,,,,.....,,:::::::#@@
62
+ @@...,....,,,,:,:,,::`..,,,,,:,::::::::;;'''+++++###+';::::::,::+'',.,.......,::''':::::;;;'''''';;;;::,::,,:,..,,,.......,,:::::::#@@
63
+ @@.,,....,:,::::,:,.....,,::,,::::::::;'';'''+'++###+';;;::::,,:++:;,........,,;,'+:::::;;''++'';;;;;::,:,,,,,.,:,,,..`.:,,,:::::::#@@
64
+ @@,,,,,.,::::::,:,.....,:::::::::::;;;;;;;''';+++###++';;:::::,:'+'',,,.....,,..;++:::::;;''++'+';;;;,:,:,,,,,..,,,,.``.,,,,:::::::#@@
65
+ @@,,,,,,:,:,::,:.....,:,,:;:;;:::;;;;;;;;';:;:''+####+'';;;:::,,;+++,.,,....``.,++'::::::;'+++''';;:;,:,,,,,.,.,,.,....,,,,::::::::#@@
66
+ @@.,,,.,,,:::,,....,:..,''';;;;';;;;''''';:,,:;++####++'';;::,,,;++++:``..`.`.;+++;:::::;;++#++'';';:::,:,,:,,.,,,,....,,::::::::::#@@
67
+ @@..,,,::::::,....,,..,;:'''';;;;;;'++';;;:..:;+#####+++'';;:,,,;;++#++',:,;'#++++;:::::;;++#'++';;;,,,,:,,,,,.:.:,.....,::::::::::#@@
68
+ @@.:,.,,:::::,.......,,';'''';;;:;'+'+;::,,.,,:+#####+++'';;::,::;'++';..`.:;'++#;;:::::;'+#+'''';;':,,:,,,::.`,:,,..,,..::::::::::#@@
69
+ @@.::.,::;;:,......,.`,,:'';;;;;;;'';';:,,,..,;#++###+++++';;:,,:::;++,::.,,:'++;;;:::::''##+#+';;;;:,.:,,,,,.`,,,..,,,,`,:::::::::#@@
70
+ @@.::..::::,.......,.,:,,:,;;;;;;;'';;;,,,,..,'+#####++'++'';:,,:::::'+#+++++';;;;:::::;++##++''';;:,..;,:,....,..,.,,,,,,:::::::::#@@
71
+ @@.,:,.,::,,............,,,:::;;;;'';;:::::,::''++##@++++++';:::::::::::;;;;;:::;:::::;+++#+++'';;;,,,:',:,....,,,...,..:::::::::::#@@
72
+ @@:,,,..,:::............,,,:::;'';;;;;;:':;:::';+++#@#'''+++':::::::::::::::::::::::;:'+'##++'';;;::,.''::,...,:,:,,,,,.:::::::::::#@@
73
+ @@:::,:,.,;;.............,:::;;';;';;;';;:;'::;;'++###''''+++;::::::::,,,,,,,,::::::;;++'#++++';;::,.:;:::,..`::,,:,,:,::::::::::::#@@
74
+ @@:::::,,,:,............,,,::;;';;;;;;';;:;;;:;'''###+'''''+++;::::::,,,,,,,,,,:::::;++'+#++++;';::,,'+::,,.,`:::::::::::::::::::::#@@
75
+ @@:::::::,::......,.,,::,:::::;;;:;;;;'';;:;;;;;:#++++''''''+++;:::,:,,,,,,,,,,,::;;'++'###++'';:::,:+;::,,..,,::::::::::::::::::::#@@
76
+ @@:::::::,,:....`.....,,.:::,,:;;;;;;'';;;:';;;'##++++'''''''++';::::,,,,,,,,,,::;;'+++;####+';;;::,:':::,..,::::::::::::::::::::::#@@
77
+ @@::,:::::,,....`.`...,..,,:,::::;;;;'';;;:';;'+++++'''''''''+++;;::::,,,,,,,:::;;'+++''####++';;:,:'::,,,,.:::::::::::::::::::::::#@@
78
+ @@.:,::::::,..,..``......,,,,:::';;:;'';;;;;;''+#+''''';;;''''+++';;::::::::::;;'+++++++#####++'::::,,,,,,.::::::::::::::::::::::::#@@
79
+ @@::,::::::,..,...`......,,:,::;';;;;;;:::;;;;'#@+''''';;;'''''++++'';;;;;;;;''++++++++#######+;:.:::,,,.::::::::::::::::::::::::::#@@
80
+ @@::::,,,,,,.,,..........,,,,,;;;;::::::::;;;;##@@''''';;;;'''''+++++++''''++++##+++++'#@@@#@#:.'.;::,,.:,::::::::::::::::::::::::;#@@
81
+ @@:;:::::,,,...............:;;::,,,,:::,;:::;#@@@@#';';;;;;''''''+++++++++++++++++++++'@#@@@@@@. .';:,,'::;:::::::::::::::::::::::;#@@
82
+ @@:::::::::,..........,::::,,:::,,,,,:::,::;##@@@@@';';;;;;;''''''+++++++++++++++++++++##@@@@@@@: .`,,::;,::::::::::::::::::::::::;#@@
83
+ @@;;:::,,,..,...,,,,,,,,,,,,,,:..`.,:,,:;.###@@@@@@+;;;;;;;;;'''''''+'+'+'++++++++++''+#@#@@@@@@@@;```.;:;;::::::,::::::::::::::::;#@@
84
+ @@::,,,,,.,,,..........,:,,,,:.,`.,.,;;;;##@@@@@@@@@;;';;;;;;;''''''''''''''++++++''''###@@@@@@@@@@@#:`````;::,.:::::::::::::;;:;:;#@@
85
+ @@::,,,,::,....,,,:::::,,,:::,,.`.`.;';+#@@@@@@@@@@@+;';;;;;;;''''''''''''''''+'''''''+##@#@@@@@@@@@@@@+:``` :;:,..,;;;::;;;::;;::;#@@
86
+ @@:::,,,,,:,,,,,,::::,,,,,,,.,...`,;'###@@@@@@@@@@@@@;'';;;;;;;'';''''''''''''''''''''+####@@@@@@@@@@@@@@@@' `;'':` `:``.``:;:::;#@@
87
+ @@::,,,,:,,,,,,::::::::,,,:::...,;,:#@#@@@@@@@@@@@@@@#''';;;;;;;;;'''''''''''''''''''+++++@@@@@@@@@@@@@@@@@+++++###+++';##++': ,:;;#@@
88
+ @@,,,,,,,:,,,,:::::::::::;,,.,,+:..``:@@#@@@@@@@@@@@@@''';;;;;;;;;;''''''''''''''''''#++++##@@@@@@@@@@@@@@@####@@@##@##@@@@##+'; ;;#@@
89
+ @@,.:,,,,,,,,:::::::::::;:,,:+:...````.@@@@@@@@@@@@@@##'';;';;;;;;;;;;'''''''''''';;'#++++#@@@@@@@@@@@@@@@@@@@@@@@@#@##@@@@####+',.'@@
90
+ @@.,:,,,,..,,,::::::;';':,;:,`.```````;@@@@@@@@@@@@@@@@+';'';;;;;;;;;;'''''''''';;;;++'++++#@@@@@@@@@@@@@#@@@@@@@@@@###@@@@###@##++#@@
91
+ @@,::,,,.....,::::';;;;::```````````,+#@@@@@@@@@@@@@@@@@'';;;;;;;;;;;;;'''''''';;;;;++'''''#@@@@@@@@@@@@#`+@@@@@@@@@@@##@@@#@@@@@@@@@@
92
+ @@,:,:,......,::'';;':.`.```````.````+@@@@@@@@@@@@@@@@@#@';;;;;;;;;;;;;;'''''';;;;:;#''''''+#@@@@@@@@@#+#`#@@@@@@@@@@##@@@@@#@@#@#@@@@
93
+ @@;::,,.....,,:';;;',...` `.,..``````'@@@@@@@@@@@@@@@@@@@#;;;;;;;;;;;;;;''''';;;:::'+'''''''#@#@@@@@@@##+ #@@@@@@@@@@###@@@@@@@##@#@@@
94
+ @@;::,......,;'''+;.` `,'#@@@@'```````@@@@@@@@@@@@@@@@@@@##;;;;;;;;;;;;;'''';;;::::'+''';'''+##@@@@@@@@#``#@@@@@@@@@@@@@@@@@@@@@@@@@@@
95
+ @@:::.......:'':.`.;+####@@@@@@'``````'@@@@@@#@@@@@@@@@@@@#+;;;;;;;;;;;;'''';;::::;++'''';''+###@@@@@##@.+#@@@@@@@@@@@@@@@@@@@@@@@@@@@
96
+ @@,,,......::``:+#########@@@@@@,``````@@@@@@@@@@@@@@@@@@@@#':::;;:;::;;;'';;;:::::+''''';'''+##@@@@@##: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@
97
+ @@,,.....,.`.'##@##@@@@@@@@@@@@@#``````+@@@@@@@@@@@@@@@@@@@@#;:::::::::;;'';;::::::+''''';;;''###@@@@@+`#@#@@@@@@@@@@@@@@@@@@@@@@@@@@@
98
+ @@.......``'##@@@@@@@@@@@@@@@@@@@#`````.@@@@@@@@@@@@@@@@@@@@@;:,,:::::::;;';;::::,:+''''''';;'+###@@##;,#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
99
+ @@......`,####@@@@@@@@@@@@@@@@@@@#````` #@@@@@@@@@@@@@@@@@@@@':,,::::::::;';::::,,:+''''''''';'#@@#@##`##@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
100
+ @@`...``;##@@@@@@@@@@@@@@@@@@@@@@@+.````+@@@@@@@@@@@@@@@@@@@@+;,,.,:::::::;;:,,,:,;+''''''''';;##@@#'.:#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
101
+ @@...``:##@@@@@@@@@@@@@@@@@@@@@@@@+`````:@@@@@@@@@@@@@@@@@@@@#::,#::::::::;;;:,:::;+''''''''';;+#@@+'`@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
102
+ @@.,.`,#@@@@@@@@@@@@@@@@@@@@@@@@@@#:````.@@@@@@@@@@@#@@@@@@@@@@`#+;;:::::::;;:::::;+''''''''''''##@#`'@#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
103
+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
104
+
105
+
106
+ RuPol is a glamorous mixin for instance pooling your Ruby classes.
107
+
108
+ It eases the pain of garbarge collection for classes that are instantiated many times, and then tossed away like runway trash. Instances are cached on the class in a pool (array, in less glamorous terms), and can be recycled at will. Of course, there is no pain without gain, and models will trade collection costs for memory usages. The Swimsuit mixin edition overrides #new and #destroy, for a virtually pain free instance swimming experience.
109
+
110
+ Runway not included.
111
+
112
+ == Contributing to ru_pol
113
+
114
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
115
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
116
+ * Fork the project
117
+ * Start a feature/bugfix branch
118
+ * Commit and push until you are happy with your contribution
119
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
120
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
121
+
122
+ == Copyright
123
+
124
+ Copyright (c) 2011 Kane Baccigalupi. See LICENSE.txt for
125
+ further details.
126
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ru_pol"
16
+ gem.homepage = "http://github.com/baccigalupi/ru_pol"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{RuPol is a glamorous mixin for instance pooling your Ruby classes}
19
+ gem.description = %Q{RuPol is a glamorous mixin for instance pooling your Ruby classes.
20
+ It eases the pain of garbarge collection for classes that are instantiated many times, and then tossed away like runway trash.
21
+ Instances are cached on the class in a pool (array in less glamorous terms), and can be recycled at will.
22
+ Of course there is no pain without gain, and models will trade collection costs for memory usages.
23
+ The Swimsuit mixin edition overrides #new and #destroy, for a virtually pain free instance swimming experience.
24
+ Runway not included.
25
+ }
26
+ gem.email = "baccigalupi@gmail.com"
27
+ gem.authors = ["Kane Baccigalupi"]
28
+
29
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
37
+ end
38
+
39
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
43
+
44
+ task :default => :spec
45
+
46
+ require 'yard'
47
+ YARD::Rake::YardocTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/pool.rb ADDED
@@ -0,0 +1,68 @@
1
+ module RuPol
2
+ class Pool
3
+ attr_accessor :max_size, :cache, :stats, :instance_class,
4
+ :recycledable, :clearable
5
+
6
+ def initialize(max, klass)
7
+ self.max_size = max
8
+ self.instance_class = klass
9
+ self.cache = []
10
+ self.stats = empty_stats
11
+ self.recycledable = class_has_method?(:_recycled)
12
+ self.clearable = class_has_method?(:clear)
13
+ end
14
+
15
+ def class_has_method?(meth)
16
+ instance_class.instance_methods.include?(meth.to_s)
17
+ end
18
+
19
+ def empty_stats
20
+ {
21
+ :gets => 0,
22
+ :pushes => 0,
23
+ :overage => 0
24
+ }
25
+ end
26
+
27
+ def size
28
+ cache.size
29
+ end
30
+
31
+ def push(value)
32
+ if available?
33
+ stats[:pushes] += 1
34
+ value.clear if clearable
35
+ value._recycled = true if recycledable
36
+ cache.push( value )
37
+ else
38
+ stats[:overage] += 1
39
+ end
40
+ value
41
+ end
42
+
43
+ def available?
44
+ size < max_size
45
+ end
46
+
47
+ def include?(value)
48
+ cache.include?(value)
49
+ end
50
+
51
+ def shift
52
+ instance = cache.shift
53
+ if instance
54
+ stats[:gets] += 1
55
+ instance._recycled = false if instance.respond_to?(:_recycled)
56
+ instance
57
+ end
58
+ end
59
+
60
+ def empty!
61
+ self.stats = empty_stats
62
+ cache.clear
63
+ end
64
+
65
+ alias :<< :push
66
+ alias :get :shift
67
+ end
68
+ end
data/lib/ru_pol.rb ADDED
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/pool'
2
+
3
+ # module for inclusion
4
+ module RuPol
5
+ def self.included(base_class)
6
+ base_class.class_eval do
7
+ include InstanceMethods
8
+ extend ClassMethods
9
+
10
+ attr_accessor :_recycled
11
+ end
12
+ end
13
+
14
+ module ClassMethods
15
+ def _pool
16
+ @pool ||= Pool.new(1000, self)
17
+ end
18
+
19
+ def max_pool_size(max_size)
20
+ _pool.max_size = max_size
21
+ end
22
+
23
+ def empty_pool!
24
+ _pool.empty!
25
+ end
26
+
27
+ def rehydrate(*init_opts)
28
+ instance = _pool.get
29
+ if instance
30
+ instance.instance_eval { init_opts.empty? ? initialize : initialize(*init_opts) }
31
+ end
32
+ instance
33
+ end
34
+ end
35
+
36
+ module InstanceMethods
37
+ def recycle
38
+ _pool << self
39
+ self
40
+ end
41
+
42
+ def _pool
43
+ self.class._pool
44
+ end
45
+ end
46
+
47
+ module Swimsuit
48
+ def self.included(base_class)
49
+ base_class.class_eval do
50
+ include ::RuPol
51
+ include InstanceMethods
52
+ extend ClassMethods
53
+ end
54
+ end
55
+
56
+ module InstanceMethods
57
+ def clear
58
+ super rescue nil
59
+ instance_variables.each do |var|
60
+ instance_variable_set(var, nil) unless var == "@_recycled"
61
+ end
62
+ self
63
+ end
64
+
65
+ def destroy
66
+ super rescue nil
67
+ recycle
68
+ end
69
+ end
70
+
71
+ module ClassMethods
72
+ def new(*init_opts)
73
+ rehydrate || ( init_opts.empty? ? super() : super(*init_opts) )
74
+ end
75
+ end
76
+ end
77
+ end
data/ru_pol.gemspec ADDED
@@ -0,0 +1,77 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ru_pol}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kane Baccigalupi"]
12
+ s.date = %q{2011-03-25}
13
+ s.description = %q{RuPol is a glamorous mixin for instance pooling your Ruby classes.
14
+ It eases the pain of garbarge collection for classes that are instantiated many times, and then tossed away like runway trash.
15
+ Instances are cached on the class in a pool (array in less glamorous terms), and can be recycled at will.
16
+ Of course there is no pain without gain, and models will trade collection costs for memory usages.
17
+ The Swimsuit mixin edition overrides #new and #destroy, for a virtually pain free instance swimming experience.
18
+ Runway not included.
19
+ }
20
+ s.email = %q{baccigalupi@gmail.com}
21
+ s.extra_rdoc_files = [
22
+ "LICENSE.txt",
23
+ "README.rdoc"
24
+ ]
25
+ s.files = [
26
+ ".document",
27
+ ".rspec",
28
+ "Gemfile",
29
+ "Gemfile.lock",
30
+ "LICENSE.txt",
31
+ "README.rdoc",
32
+ "Rakefile",
33
+ "VERSION",
34
+ "lib/pool.rb",
35
+ "lib/ru_pol.rb",
36
+ "ru_pol.gemspec",
37
+ "spec/pool_spec.rb",
38
+ "spec/ru_pol_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/baccigalupi/ru_pol}
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.7}
45
+ s.summary = %q{RuPol is a glamorous mixin for instance pooling your Ruby classes}
46
+ s.test_files = [
47
+ "spec/pool_spec.rb",
48
+ "spec/ru_pol_spec.rb",
49
+ "spec/spec_helper.rb"
50
+ ]
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
58
+ s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
59
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
61
+ s.add_development_dependency(%q<rcov>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
67
+ s.add_dependency(%q<rcov>, [">= 0"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
71
+ s.add_dependency(%q<yard>, ["~> 0.6.0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ end
76
+ end
77
+
data/spec/pool_spec.rb ADDED
@@ -0,0 +1,162 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe RuPol::Pool do
4
+ before do
5
+ @pool = RuPol::Pool.new(2, Array)
6
+ @empty_stats = {
7
+ :gets => 0,
8
+ :pushes => 0,
9
+ :overage => 0
10
+ }
11
+ @arrays = [
12
+ [1], [2], [3]
13
+ ]
14
+ end
15
+
16
+ describe 'initialization' do
17
+ it 'should require two arguments, first for the size, second for the class being stored' do
18
+ lambda{ RuPol::Pool.new }.should raise_error
19
+ end
20
+
21
+ it 'sets the max size' do
22
+ @pool.max_size.should == 2
23
+ end
24
+
25
+ it 'sets the instance_class' do
26
+ @pool.instance_class.should == Array
27
+ end
28
+
29
+ it 'sets the stats to empty' do
30
+ @pool.stats.should == @empty_stats
31
+ end
32
+
33
+ it 'calculates and caches #clearable' do
34
+ @pool.clearable.should == true
35
+ end
36
+
37
+ it 'calculates and caches #recycledable' do
38
+ @pool.recycledable.should == false
39
+ end
40
+
41
+ it 'should have a cache' do
42
+ @pool.cache.should == []
43
+ end
44
+ end
45
+
46
+ describe 'delegates' do
47
+ it 'should have a size that corresponds to the cache size' do
48
+ @pool.size.should == 0
49
+ @pool.cache.size.should == 0
50
+
51
+ @pool.cache << ['foo']
52
+ @pool.size.should == 1
53
+ end
54
+
55
+ it 'should know if it has room' do
56
+ @pool.available?.should be_true
57
+ @pool << @arrays[0]
58
+ @pool << @arrays[1]
59
+ @pool.available?.should be_false
60
+ end
61
+
62
+ it 'should delegate include? to the cache' do
63
+ @pool.include?(@arrays[0]).should be_false
64
+ @pool << @arrays[0]
65
+ @pool.include?(@arrays[0]).should be_true
66
+ end
67
+
68
+ it 'can be emptied' do
69
+ @pool << @arrays[0]
70
+ @pool.size.should == 1
71
+ @pool.empty!
72
+ @pool.size.should == 0
73
+ end
74
+ end
75
+
76
+ describe '#push' do
77
+ it 'should push' do
78
+ @pool.push(@arrays[0])
79
+ @pool.push(@arrays[1])
80
+ @pool.cache.first.should == @arrays[0]
81
+ end
82
+
83
+ it 'should call #clear on the object' do
84
+ array = [1,2,3]
85
+ array.should_receive(:clear)
86
+ @pool.push array
87
+ end
88
+
89
+ it 'aliases #<< to push' do
90
+ @pool << @arrays[0]
91
+ @pool.cache.should == [@arrays[0]]
92
+ end
93
+
94
+ it 'should not grow larger than the max size' do
95
+ @pool << @arrays[0]
96
+ @pool << @arrays[1]
97
+ @pool.size.should == 2
98
+ @pool << @arrays[2]
99
+ @pool.size.should == 2
100
+ end
101
+ end
102
+
103
+
104
+ describe 'get' do
105
+ it 'should shift values from the top of the cache' do
106
+ @pool << @arrays[0]
107
+ @pool << @arrays[1]
108
+ @pool.size.should == 2
109
+
110
+ value = @pool.shift
111
+ value.should == @arrays[0]
112
+
113
+ @pool.size.should == 1
114
+ end
115
+
116
+ it 'should have aliased methods #get' do
117
+ @pool << @arrays[0]
118
+ @pool << @arrays[1]
119
+ @pool.get.should == @arrays[0]
120
+ @pool.get.should == @arrays[1]
121
+ @pool.size.should == 0
122
+ end
123
+ end
124
+
125
+
126
+ describe 'stats' do
127
+ it 'keeps track of get requests' do
128
+ @pool << [1]
129
+ @pool.get
130
+ @pool.stats[:gets].should == 1
131
+ end
132
+
133
+ it 'does not log a get request when there when the cache is empty' do
134
+ @pool.get
135
+ @pool.stats[:gets].should == 0
136
+ end
137
+
138
+ it 'keeps track of push requests' do
139
+ @pool << [1]
140
+ @pool.stats[:pushes].should == 1
141
+ end
142
+
143
+ it 'keeps track of failed pushes' do
144
+ @pool << [1]
145
+ @pool << [2]
146
+ @pool << [3]
147
+ @pool.stats.should == {
148
+ :gets => 0,
149
+ :pushes => 2,
150
+ :overage => 1
151
+ }
152
+ end
153
+
154
+ it 'clears when empty' do
155
+ @pool << [1]
156
+ @pool.get
157
+ @pool.stats.should_not == @empty_stats
158
+ @pool.empty!
159
+ @pool.stats.should == @empty_stats
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,205 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe RuPol do
4
+ class Irreplacable
5
+ include RuPol::Swimsuit
6
+
7
+ def initialize(opts={})
8
+ @foo = opts[:foo] || 'bar'
9
+ end
10
+
11
+ def foo
12
+ @foo = "foo"
13
+ end
14
+ end
15
+
16
+ class Replacing < Array
17
+ include RuPol
18
+ end
19
+
20
+ describe 'class level pool' do
21
+ it 'adds a _pool to the class' do
22
+ Irreplacable._pool.class.should == RuPol::Pool
23
+ end
24
+
25
+ it 'sets the default size to 1000' do
26
+ Irreplacable._pool.max_size.should == 1000
27
+ end
28
+
29
+ it 'pool max size is settable via the #max_pool_size class method' do
30
+ Irreplacable.max_pool_size 42
31
+ Irreplacable._pool.max_size.should == 42
32
+ end
33
+
34
+ it 'has a method for clearing' do
35
+ Irreplacable._pool << Irreplacable.new
36
+ Irreplacable._pool.size.should == 1
37
+ Irreplacable.empty_pool!
38
+ Irreplacable._pool.size.should == 0
39
+ end
40
+ end
41
+
42
+ describe '#recycle' do
43
+ before :all do
44
+ @instance = Irreplacable.new
45
+ @replacable_instance = Replacing.new
46
+
47
+ @instance._recycled.should be_false
48
+ @replacable_instance._recycled.should be_false
49
+
50
+ @instance.recycle
51
+ @replacable_instance.recycle
52
+ end
53
+
54
+ it 'adds it to the pool' do
55
+ Irreplacable._pool.should include @instance
56
+ Replacing._pool.should include @replacable_instance
57
+ end
58
+
59
+ it 'sets the _recycled flag to true' do
60
+ @instance._recycled.should be_true
61
+ @replacable_instance._recycled.should be_true
62
+ end
63
+ end
64
+
65
+ describe '#rehydrate' do
66
+ before :all do
67
+ Irreplacable.empty_pool!
68
+ Replacing.empty_pool!
69
+
70
+ @instance = Irreplacable.new
71
+ @replacable_instance = Replacing.new
72
+
73
+ @instance.recycle
74
+ @replacable_instance.recycle
75
+
76
+ @new_instance = Irreplacable.rehydrate(:foo => 'foof')
77
+ end
78
+
79
+ it 'should remove the instance from the cache' do
80
+ Irreplacable._pool.should_not include(@instance)
81
+ end
82
+
83
+ it 'should set the _recycled flag to false' do
84
+ @instance._recycled.should be_false
85
+ end
86
+
87
+ it 'should initialize the instance with the passed in options' do
88
+ @new_instance.instance_variable_get('@foo').should == 'foof'
89
+ end
90
+
91
+ it 'works with an initialize method that takes no aruments' do
92
+ Replacing.rehydrate
93
+ Replacing._pool.should_not include(@replacable_instance)
94
+ @replacable_instance._recycled.should be_false
95
+ end
96
+
97
+ it 'replaces content in a replacable object' do
98
+ @replacable_instance.recycle
99
+
100
+ instance = Replacing.rehydrate(['foo', 'bar'])
101
+ instance.should == ['foo', 'bar']
102
+ end
103
+
104
+ it 'returns nil if there is nothing in the cache' do
105
+ Replacing.empty_pool!
106
+ Replacing.rehydrate(['bar']).should == nil
107
+ end
108
+
109
+ it 'should return the instance' do
110
+ @new_instance.should === @instance
111
+ end
112
+ end
113
+
114
+
115
+ describe RuPol::Swimsuit do
116
+ describe '#clear' do
117
+ it 'calls super' do
118
+ instance = Replacing.new
119
+ instance.clear
120
+ instance.should be_empty
121
+ end
122
+
123
+ it 'does not freak on super if ther is no superclass' do
124
+ instance = Irreplacable.new
125
+ instance.clear
126
+ end
127
+
128
+ it 'clears instance variables' do
129
+ instance = Irreplacable.new
130
+ instance.foo
131
+ instance.instance_variable_get('@foo').should == "foo"
132
+
133
+ instance.clear
134
+ instance.instance_variable_get('@foo').should == nil
135
+ end
136
+
137
+ it 'returns self for chaining' do
138
+ instance = Replacing.new
139
+ instance.clear.should === instance
140
+ end
141
+ end
142
+
143
+ describe 'overwriting new' do
144
+ before do
145
+ Irreplacable.empty_pool!
146
+ end
147
+
148
+ it 'will return a brand new instance if the pool is empty' do
149
+ Irreplacable._pool.size.should == 0
150
+ instance = Irreplacable.new
151
+ instance.class.should == Irreplacable
152
+ end
153
+
154
+ it 'rehydrate if there are instances in the pool' do
155
+ instance = Irreplacable.new
156
+ instance.recycle
157
+
158
+ Irreplacable.new.should === instance
159
+ end
160
+ end
161
+
162
+ describe 'destroy' do
163
+ class Destroyable
164
+ def self.destroyed
165
+ @destroyed ||= false
166
+ end
167
+
168
+ def self.destroyed=(value)
169
+ @destroyed = value
170
+ end
171
+
172
+ def destroy
173
+ self.class.destroyed = true
174
+ end
175
+ end
176
+
177
+ class DestroyableDescendant < Destroyable
178
+ include RuPol::Swimsuit
179
+ end
180
+
181
+ before do
182
+ DestroyableDescendant.destroyed = false
183
+ DestroyableDescendant.empty_pool!
184
+ Irreplacable.empty_pool!
185
+ @instance = DestroyableDescendant.new
186
+ end
187
+
188
+ it 'calls super' do
189
+ @instance.destroy
190
+ DestroyableDescendant.destroyed.should == true
191
+ end
192
+
193
+ it 'recycles the instance' do
194
+ @instance.destroy
195
+ DestroyableDescendant._pool.should include @instance
196
+ end
197
+
198
+ it 'does not fail if there is no #destroy method in the ancestor chain' do
199
+ instance = Irreplacable.new
200
+ instance.destroy
201
+ Irreplacable._pool.should include instance
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'ru_pol'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ru_pol
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Kane Baccigalupi
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-25 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 2
30
+ - 3
31
+ - 0
32
+ version: 2.3.0
33
+ type: :development
34
+ name: rspec
35
+ prerelease: false
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 0
46
+ - 6
47
+ - 0
48
+ version: 0.6.0
49
+ type: :development
50
+ name: yard
51
+ prerelease: false
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 0
64
+ version: 1.0.0
65
+ type: :development
66
+ name: bundler
67
+ prerelease: false
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 7
76
+ segments:
77
+ - 1
78
+ - 5
79
+ - 2
80
+ version: 1.5.2
81
+ type: :development
82
+ name: jeweler
83
+ prerelease: false
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ name: rcov
97
+ prerelease: false
98
+ version_requirements: *id005
99
+ description: "RuPol is a glamorous mixin for instance pooling your Ruby classes. \n It eases the pain of garbarge collection for classes that are instantiated many times, and then tossed away like runway trash.\n Instances are cached on the class in a pool (array in less glamorous terms), and can be recycled at will. \n Of course there is no pain without gain, and models will trade collection costs for memory usages.\n The Swimsuit mixin edition overrides #new and #destroy, for a virtually pain free instance swimming experience.\n Runway not included. \n "
100
+ email: baccigalupi@gmail.com
101
+ executables: []
102
+
103
+ extensions: []
104
+
105
+ extra_rdoc_files:
106
+ - LICENSE.txt
107
+ - README.rdoc
108
+ files:
109
+ - .document
110
+ - .rspec
111
+ - Gemfile
112
+ - Gemfile.lock
113
+ - LICENSE.txt
114
+ - README.rdoc
115
+ - Rakefile
116
+ - VERSION
117
+ - lib/pool.rb
118
+ - lib/ru_pol.rb
119
+ - ru_pol.gemspec
120
+ - spec/pool_spec.rb
121
+ - spec/ru_pol_spec.rb
122
+ - spec/spec_helper.rb
123
+ has_rdoc: true
124
+ homepage: http://github.com/baccigalupi/ru_pol
125
+ licenses:
126
+ - MIT
127
+ post_install_message:
128
+ rdoc_options: []
129
+
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ hash: 3
138
+ segments:
139
+ - 0
140
+ version: "0"
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ requirements: []
151
+
152
+ rubyforge_project:
153
+ rubygems_version: 1.3.7
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: RuPol is a glamorous mixin for instance pooling your Ruby classes
157
+ test_files:
158
+ - spec/pool_spec.rb
159
+ - spec/ru_pol_spec.rb
160
+ - spec/spec_helper.rb