Ruby-MemCache 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.irbrc ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/ruby
2
+
3
+ puts ">>> Adding lib and ext to load path..."
4
+ $LOAD_PATH.unshift( "lib" )
5
+
6
+ require './utils'
7
+ include UtilityFunctions
8
+
9
+ def colored( prompt, *args )
10
+ return ansiCode( *(args.flatten) ) + prompt + ansiCode( 'reset' )
11
+ end
12
+
13
+
14
+ # Modify prompt to do highlighting unless we're running in an inferior shell.
15
+ unless ENV['EMACS']
16
+ IRB.conf[:PROMPT][:memcache] = { # name of prompt mode
17
+ :PROMPT_I => colored( "%N(%m):%03n:%i>", %w{bold white on_blue} ) + " ",
18
+ :PROMPT_S => colored( "%N(%m):%03n:%i%l", %w{white on_blue} ) + " ",
19
+ :PROMPT_C => colored( "%N(%m):%03n:%i*", %w{white on_blue} ) + " ",
20
+ :RETURN => " ==> %s\n\n" # format to return value
21
+ }
22
+ IRB.conf[:PROMPT_MODE] = :memcache
23
+ end
24
+
25
+ # Try to require the 'memcache' library
26
+ begin
27
+ puts "Requiring Memcache..."
28
+ require "memcache"
29
+ rescue => e
30
+ $stderr.puts "Ack! Memcache library failed to load: #{e.message}\n\t" +
31
+ e.backtrace.join( "\n\t" )
32
+ end
33
+
34
+
35
+ __END__
36
+ Local Variables:
37
+ mode: ruby
38
+
data/README ADDED
@@ -0,0 +1,69 @@
1
+
2
+ = Ruby-MemCache
3
+
4
+ A Ruby memcache client library.
5
+
6
+ == Authors
7
+
8
+ Michael Granger <mgranger@RubyCrafters.com>
9
+
10
+ Thanks to Martin Chase and Rick Bradley for peer review, suggestions, and
11
+ bugfixes.
12
+
13
+
14
+ == General Information
15
+
16
+ According to its documentation, memcache "is a high-performance, distributed
17
+ memory object caching system, generic in nature, but intended for use in
18
+ speeding up dynamic web applications by alleviating database load."
19
+
20
+ This is a Ruby client library for accessing one or more memcache servers.
21
+
22
+
23
+ == Installation
24
+
25
+ === Requirements
26
+
27
+ * Ruby 1.8.2
28
+ * Memcached 1.1.11
29
+
30
+
31
+ ==== Quickstart
32
+
33
+ Install:
34
+
35
+ $ install.rb
36
+
37
+ The install script will check for dependencies and install the libraries.
38
+
39
+
40
+ == Current Status
41
+
42
+ This is a beta release. It might eat your house, set your dog on fire, or
43
+ baptize your children against your will.
44
+
45
+ Comments welcomed.
46
+
47
+
48
+ == Contact
49
+
50
+ * Project Page: http://www.deveiate.org/code/Ruby-MemCache.html
51
+
52
+
53
+ == Legal
54
+
55
+ Copyright (c) 2004 The FaerieMUD Consortium. Most rights reserved.
56
+
57
+ This library is licensed under the Creative Commons Attribution License. To view
58
+ a copy of this license, visit http://creativecommons.org/licenses/by/1.0/ or
59
+ send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
60
+ 94305, USA.
61
+
62
+ THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
63
+ INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
64
+ FITNESS FOR A PARTICULAR PURPOSE.
65
+
66
+
67
+ $Id: README 26 2004-11-12 18:12:15Z ged $
68
+
69
+
@@ -0,0 +1,9 @@
1
+ #
2
+ # Title: Ruby MemCache Client Library
3
+ # Main: README
4
+ # Upload: ssh://yhaliwell/usr/local/www/devEiate.org/4.0/code/Ruby-MemCache/
5
+ # Webcvs: http://svn.faeriemud.org/index.cgi/RMemCache/log/trunk/
6
+ #
7
+ lib/memcache.rb
8
+ README
9
+ TODO
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # RDoc Documentation Generation Script
4
+ # $Id: makedocs.rb 12 2004-10-03 21:04:34Z ged $
5
+ #
6
+ # Copyright (c) 2001-2004 The FaerieMUD Consortium.
7
+ #
8
+ # This is free software. You may use, modify, and/or redistribute this
9
+ # software under the terms of the Perl Artistic License. (See
10
+ # http://language.perl.com/misc/Artistic.html)
11
+ #
12
+
13
+ # Make sure we're in the correct directory, and if not, change there.
14
+ BEGIN {
15
+ basedir = File::dirname(File::dirname( File::expand_path(__FILE__) ))
16
+ unless Dir::pwd == basedir
17
+ Dir::chdir( basedir )
18
+ end
19
+ $LOAD_PATH.unshift basedir
20
+ }
21
+
22
+ # Load modules
23
+ require 'getoptlong'
24
+ require 'rdoc/rdoc'
25
+ require 'utils'
26
+ include UtilityFunctions
27
+
28
+ def makeDocs( docsdir, template='html', diagrams=false, upload=nil, ridocs=false )
29
+ debugMsg "docsdir = %p, template = %p, diagrams = %p, upload = %p, ridocs = %p" %
30
+ [docsdir, template, diagrams, upload, ridocs]
31
+
32
+ title = findRdocTitle()
33
+ docs = findRdocableFiles()
34
+ main = findRdocMain()
35
+ webcvs = findRdocCvsURL()
36
+
37
+ header "Making documentation in #{docsdir}."
38
+ header "Will upload to '#{upload}'\n" if upload
39
+ header "Will also create/install 'ri' source" if ridocs
40
+
41
+ flags = [
42
+ '--all',
43
+ '--inline-source',
44
+ '--fmt', 'html',
45
+ '--include', 'docs',
46
+ '--template', template,
47
+ '--op', docsdir,
48
+ '--title', title,
49
+ '--tab-width', 4,
50
+ ]
51
+
52
+ flags += [ '--quiet' ] unless $VERBOSE
53
+ flags += [ '--diagram' ] if diagrams
54
+ flags += [ '--main', main ] if main
55
+ flags += [ '--webcvs', webcvs ] if webcvs
56
+
57
+ buildDocs( flags, docs )
58
+ uploadDocs( upload, docsdir ) if upload
59
+ buildRi( docs ) if ridocs
60
+ end
61
+
62
+
63
+ def buildDocs( flags, docs )
64
+ message "Running 'rdoc #{flags.join(' ')} #{docs.join(' ')}'\n" if $VERBOSE
65
+ unless $DEBUG
66
+ begin
67
+ r = RDoc::RDoc.new
68
+ r.document( flags + docs )
69
+ rescue RDoc::RDocError => e
70
+ $stderr.puts e.message
71
+ exit(1)
72
+ end
73
+ end
74
+ end
75
+
76
+
77
+ def uploadDocs( url, docsdir )
78
+ header "Uploading new docs snapshot to #{url}."
79
+
80
+ case url
81
+
82
+ # SSH target
83
+ when %r{^ssh://(.*)}
84
+ target = $1
85
+ if target =~ %r{^([^/]+)/(.*)}
86
+ host, path = $1, $2
87
+ path = "/" + path unless path =~ /^(\/|\.)/
88
+ cmd = "tar -C #{docsdir} -cf - . | ssh #{host} 'tar -C #{path} -xvf -'"
89
+ unless $DEBUG
90
+ system( cmd )
91
+ else
92
+ message "Would have uploaded using the command:\n #{cmd}\n\n"
93
+ end
94
+ else
95
+ abort "--upload ssh://host/path"
96
+ end
97
+ when %r{^file://(.*)}
98
+ targetdir = $1
99
+ targetdir.gsub!( %r{^file://}, '' )
100
+
101
+ File.makedirs targetdir, true
102
+ Dir["#{docsdir}/**/*"].each {|file|
103
+ fname = file.gsub( %r:#{docsdir}/:, '' )
104
+ if File.directory? file
105
+ unless $DEBUG
106
+ File.makedirs File.join(targetdir, fname), true
107
+ else
108
+ message %{File.makedirs %s, true\n} % File.join(targetdir, fname)
109
+ end
110
+ else
111
+ unless $DEBUG
112
+ File.install( file, File.join(targetdir, fname), 0444, true )
113
+ else
114
+ message %{File.install( %s, %s, 0444, true )\n} % [
115
+ file,
116
+ File.join(targetdir, fname),
117
+ ]
118
+ end
119
+ end
120
+ }
121
+
122
+ else
123
+ raise "I don't know how to upload to urls like '#{url}'."
124
+ end
125
+ end
126
+
127
+ def buildRi( docs )
128
+ message "Running 'rdoc #{flags.join(' ')} #{docs.join(' ')}'\n" if $VERBOSE
129
+ unless $DEBUG
130
+ begin
131
+ r = RDoc::RDoc.new
132
+ r.document([ '-i', 'docs', '-f', 'xml', 'lib', 'ext' ])
133
+ rescue RDoc::RDocError => e
134
+ $stderr.puts e.message
135
+ exit(1)
136
+ end
137
+ end
138
+
139
+ end
140
+
141
+
142
+ if $0 == __FILE__
143
+ opts = GetoptLong.new
144
+ opts.set_options(
145
+ [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
146
+ [ '--verbose', '-v', GetoptLong::NO_ARGUMENT ],
147
+ [ '--upload', '-u', GetoptLong::OPTIONAL_ARGUMENT ],
148
+ [ '--diagrams', '-D', GetoptLong::NO_ARGUMENT ],
149
+ [ '--template', '-T', GetoptLong::REQUIRED_ARGUMENT ],
150
+ [ '--output', '-o', GetoptLong::REQUIRED_ARGUMENT ]
151
+ #[ '--ri', '-r', GetoptLong::NO_ARGUMENT ],
152
+ )
153
+
154
+ debug = false
155
+ verbose = false
156
+ upload = nil
157
+ diagrams = false
158
+ template = 'html'
159
+ docsdir = "docs/html"
160
+ rimode = false
161
+
162
+ opts.each {|opt,val|
163
+ case opt
164
+
165
+ when '--debug'
166
+ debug = true
167
+
168
+ when '--verbose'
169
+ verbose = true
170
+
171
+ when '--upload'
172
+ upload = val
173
+ upload = findRdocUpload() if val.nil? || val.empty?
174
+
175
+ when '--diagrams'
176
+ diagrams = true
177
+
178
+ when '--output'
179
+ docsdir = val
180
+
181
+ when '--ri'
182
+ rimode = true
183
+
184
+ end
185
+ }
186
+
187
+ $DEBUG = true if debug
188
+ $VERBOSE = true if verbose
189
+
190
+ makeDocs( docsdir, template, diagrams, upload, rimode )
191
+ end
@@ -0,0 +1,185 @@
1
+ #!/usr/bin/ruby
2
+ #
3
+ # Module Install Script
4
+ # $Id: install.rb 12 2004-10-03 21:04:34Z ged $
5
+ #
6
+ # Thanks to Masatoshi SEKI for ideas found in his install.rb.
7
+ #
8
+ # Copyright (c) 2001-2004 The FaerieMUD Consortium.
9
+ #
10
+ # This is free software. You may use, modify, and/or redistribute this
11
+ # software under the terms of the Perl Artistic License. (See
12
+ # http://language.perl.com/misc/Artistic.html)
13
+ #
14
+
15
+ require './utils.rb'
16
+ include UtilityFunctions
17
+
18
+ require 'rbconfig'
19
+ include Config
20
+
21
+ require 'find'
22
+ require 'ftools'
23
+ require 'optparse'
24
+
25
+ $version = %q$Rev: 12 $
26
+ $rcsId = %q$Id: install.rb 12 2004-10-03 21:04:34Z ged $
27
+
28
+ # Define required libraries
29
+ RequiredLibraries = [
30
+ # libraryname, nice name, RAA URL, Download URL, e.g.,
31
+ [ 'io/reactor', "IO-Reactor",
32
+ 'http://raa.ruby-lang.org/project/io-reactor/',
33
+ 'http://www.deveiate.org/code/IO-Reactor-0.05.tar.gz',
34
+ ],
35
+ ]
36
+
37
+ class Installer
38
+
39
+ @@PrunePatterns = [
40
+ /CVS/,
41
+ /~$/,
42
+ %r:(^|/)\.:,
43
+ /\.tpl$/,
44
+ ]
45
+
46
+ def initialize( testing=false )
47
+ @ftools = (testing) ? self : File
48
+ end
49
+
50
+ ### Make the specified dirs (which can be a String or an Array of Strings)
51
+ ### with the specified mode.
52
+ def makedirs( dirs, mode=0755, verbose=false )
53
+ dirs = [ dirs ] unless dirs.is_a? Array
54
+
55
+ oldumask = File::umask
56
+ File::umask( 0777 - mode )
57
+
58
+ for dir in dirs
59
+ if @ftools == File
60
+ File::mkpath( dir, $verbose )
61
+ else
62
+ $stderr.puts "Make path %s with mode %o" % [ dir, mode ]
63
+ end
64
+ end
65
+
66
+ File::umask( oldumask )
67
+ end
68
+
69
+ def install( srcfile, dstfile, mode=nil, verbose=false )
70
+ dstfile = File.catname(srcfile, dstfile)
71
+ unless FileTest.exist? dstfile and File.cmp srcfile, dstfile
72
+ $stderr.puts " install #{srcfile} -> #{dstfile}"
73
+ else
74
+ $stderr.puts " skipping #{dstfile}: unchanged"
75
+ end
76
+ end
77
+
78
+ public
79
+
80
+ def installFiles( src, dstDir, mode=0444, verbose=false )
81
+ directories = []
82
+ files = []
83
+
84
+ if File.directory?( src )
85
+ Find.find( src ) {|f|
86
+ Find.prune if @@PrunePatterns.find {|pat| f =~ pat}
87
+ next if f == src
88
+
89
+ if FileTest.directory?( f )
90
+ directories << f.gsub( /^#{src}#{File::Separator}/, '' )
91
+ next
92
+
93
+ elsif FileTest.file?( f )
94
+ files << f.gsub( /^#{src}#{File::Separator}/, '' )
95
+
96
+ else
97
+ Find.prune
98
+ end
99
+ }
100
+ else
101
+ files << File.basename( src )
102
+ src = File.dirname( src )
103
+ end
104
+
105
+ dirs = [ dstDir ]
106
+ dirs |= directories.collect {|d| File.join(dstDir,d)}
107
+ makedirs( dirs, 0755, verbose )
108
+ files.each {|f|
109
+ srcfile = File.join(src,f)
110
+ dstfile = File.dirname(File.join( dstDir,f ))
111
+
112
+ if verbose
113
+ if mode
114
+ $stderr.puts "Install #{srcfile} -> #{dstfile} (mode %o)" % mode
115
+ else
116
+ $stderr.puts "Install #{srcfile} -> #{dstfile}"
117
+ end
118
+ end
119
+
120
+ @ftools.install( srcfile, dstfile, mode, verbose )
121
+ }
122
+ end
123
+
124
+ end
125
+
126
+
127
+ if $0 == __FILE__
128
+ dryrun = false
129
+
130
+ # Parse command-line switches
131
+ ARGV.options {|oparser|
132
+ oparser.banner = "Usage: #$0 [options]\n"
133
+
134
+ oparser.on( "--verbose", "-v", TrueClass, "Make progress verbose" ) {
135
+ $VERBOSE = true
136
+ debugMsg "Turned verbose on."
137
+ }
138
+
139
+ oparser.on( "--dry-run", "-n", TrueClass, "Don't really install anything" ) {
140
+ debugMsg "Turned dry-run on."
141
+ dryrun = true
142
+ }
143
+
144
+ # Handle the 'help' option
145
+ oparser.on( "--help", "-h", "Display this text." ) {
146
+ $stderr.puts oparser
147
+ exit!(0)
148
+ }
149
+
150
+ oparser.parse!
151
+ }
152
+
153
+ # Don't do anything if they expect this to be the three-step install script
154
+ # and they aren't doing the 'install' step.
155
+ if ARGV.include?( "config" )
156
+ for lib in RequiredLibraries
157
+ testForRequiredLibrary( *lib )
158
+ end
159
+ puts "Done."
160
+ elsif ARGV.include?( "setup" )
161
+ puts "Done."
162
+ elsif ARGV.empty?
163
+ for lib in RequiredLibraries
164
+ testForRequiredLibrary( *lib )
165
+ end
166
+ end
167
+
168
+ if ARGV.empty? || ARGV.include?( "install" )
169
+ debugMsg "Sitelibdir = '#{CONFIG['sitelibdir']}'"
170
+ sitelibdir = CONFIG['sitelibdir']
171
+ debugMsg "Sitearchdir = '#{CONFIG['sitearchdir']}'"
172
+ sitearchdir = CONFIG['sitearchdir']
173
+
174
+ message "Installing..."
175
+ i = Installer.new( dryrun )
176
+ #i.installFiles( "redist", sitelibdir, 0444, verbose )
177
+ i.installFiles( "lib", sitelibdir, 0444, $VERBOSE )
178
+
179
+ message "done.\n"
180
+ end
181
+ end
182
+
183
+
184
+
185
+