druid 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ === 0.1.0 2009-09-01
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
5
+ * Adds support for Array.shuffle
6
+ * Adds support for Object marshalling to/from file methods
@@ -0,0 +1,15 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/druid.rb
7
+ lib/druid/Array.rb
8
+ lib/druid/Object.rb
9
+ script/console
10
+ script/destroy
11
+ script/generate
12
+ test/test_array_shuffle.rb
13
+ test/test_druid.rb
14
+ test/test_helper.rb
15
+ website/index.txt
@@ -0,0 +1,5 @@
1
+
2
+ For more information on I)ruidLib, see http://druid.rubyforge.org
3
+
4
+ Enjoy!!!
5
+
@@ -0,0 +1,70 @@
1
+ = druid
2
+
3
+ * http://druid.rubyforge.org/
4
+
5
+ == DESCRIPTION:
6
+
7
+ I)ruidLib is a package of new classes and standard class extensions
8
+ that I personally find useful and hope that you do too.
9
+
10
+ == FEATURES:
11
+
12
+ Class Extensions:
13
+ Array.shuffle
14
+ Shuffles the elements of an Array.
15
+
16
+ Object.load_from_file(filename)
17
+ Loads a marshalled object from a file.
18
+
19
+ Object.save_to_file(object, filename, options)
20
+ Saves a marshalled object to a file, optionally gzipped.
21
+ options = {:gzip => true}
22
+
23
+ == SYNOPSIS:
24
+
25
+ === Array.shuffle
26
+
27
+ a = [0,1,2,3,4,5,6,7,8,9]
28
+ a.shuffle
29
+
30
+ === Object.load_from_file and Object.save_to_file
31
+
32
+ myobject = Object.new
33
+ Object.save_to_file(myobject, filename, {:gzip => true})
34
+ myobject = Object.load_from_file(filename)
35
+
36
+ == REQUIREMENTS:
37
+
38
+ None
39
+
40
+ == INSTALL:
41
+
42
+ sudo gem install druid
43
+
44
+ == LICENSE:
45
+
46
+ Copyright (c) 2009, I)ruid <druid@caughq.org>
47
+ All rights reserved.
48
+
49
+ Redistribution and use in source and binary forms, with or without
50
+ modification, are permitted provided that the following conditions are met:
51
+ * Redistributions of source code must retain the above copyright
52
+ notice, this list of conditions and the following disclaimer.
53
+ * Redistributions in binary form must reproduce the above copyright
54
+ notice, this list of conditions and the following disclaimer in the
55
+ documentation and/or other materials provided with the distribution.
56
+ * Neither the name of the I)ruidLib project nor the
57
+ names of its contributors may be used to endorse or promote products
58
+ derived from this software without specific prior written permission.
59
+
60
+ THIS SOFTWARE IS PROVIDED BY I)RUID ''AS IS'' AND ANY
61
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
62
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
63
+ DISCLAIMED. IN NO EVENT SHALL I)RUID BE LIABLE FOR ANY
64
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
65
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
66
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
67
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
68
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
69
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
70
+
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/druid'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'druid' do
14
+ self.developer 'I)ruid', 'druid@caughq.org'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
@@ -0,0 +1,9 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'druid/Array'
5
+ require 'druid/Object'
6
+
7
+ module Druid
8
+ VERSION = '0.1.0'
9
+ end
@@ -0,0 +1,7 @@
1
+ class Array
2
+ def shuffle(times = 1)
3
+ (0...times).each {|shuffle|
4
+ (0...self.size).each {|i| self.insert(rand(self.size), self.delete_at(i)) }
5
+ }
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'zlib'
2
+
3
+ # Extend Object class to include save_to_file and load_from_file methods
4
+ class Object
5
+ def self.save_to_file obj, filename, options={}
6
+ #obj = self
7
+ marshal_dump = Marshal.dump(obj)
8
+ file = File.new(filename,'w')
9
+ file = Zlib::GzipWriter.new(file) unless options[:gzip] == false
10
+ file.write marshal_dump
11
+ file.close
12
+ return obj
13
+ end
14
+
15
+ def self.load_from_file filename
16
+ begin
17
+ file = Zlib::GzipReader.open(filename)
18
+ rescue Zlib::GzipFile::Error
19
+ file = File.open(filename, 'r')
20
+ ensure
21
+ return nil if ! file
22
+ #obj = Marshal.load file.read
23
+ obj = Marshal.load file.read
24
+ file.close
25
+ return obj
26
+ end
27
+ end
28
+ end
29
+
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/druid.rb'}"
9
+ puts "Loading druid gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestArrayShuffle < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @a = [0,1,2,3,4,5,6,7,8,9]
7
+ @b = @a
8
+ end
9
+
10
+ def test_truth
11
+ @a.shuffle
12
+ assert @a != @b and @a.size == @b.size
13
+ end
14
+ end
15
+
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestDruid < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/druid'
File without changes
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: druid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - I)ruid
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-02 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hoe
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.3.3
24
+ version:
25
+ description: |-
26
+ I)ruidLib is a package of new classes and standard class extensions
27
+ that I personally find useful and hope that you do too.
28
+ email:
29
+ - druid@caughq.org
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files:
35
+ - History.txt
36
+ - Manifest.txt
37
+ - PostInstall.txt
38
+ - website/index.txt
39
+ files:
40
+ - History.txt
41
+ - Manifest.txt
42
+ - PostInstall.txt
43
+ - README.rdoc
44
+ - Rakefile
45
+ - lib/druid.rb
46
+ - lib/druid/Array.rb
47
+ - lib/druid/Object.rb
48
+ - script/console
49
+ - script/destroy
50
+ - script/generate
51
+ - test/test_array_shuffle.rb
52
+ - test/test_druid.rb
53
+ - test/test_helper.rb
54
+ - website/index.txt
55
+ has_rdoc: true
56
+ homepage: http://druid.rubyforge.org/
57
+ licenses: []
58
+
59
+ post_install_message: PostInstall.txt
60
+ rdoc_options:
61
+ - --main
62
+ - README.rdoc
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: "0"
70
+ version:
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "0"
76
+ version:
77
+ requirements: []
78
+
79
+ rubyforge_project: druid
80
+ rubygems_version: 1.3.4
81
+ signing_key:
82
+ specification_version: 3
83
+ summary: I)ruidLib is a package of new classes and standard class extensions that I personally find useful and hope that you do too.
84
+ test_files:
85
+ - test/test_helper.rb
86
+ - test/test_array_shuffle.rb
87
+ - test/test_druid.rb