hexoid 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ HEXOID, CHANGES
2
+
3
+
4
+ #### 0.2.0 (2009-09-??) ###############################
5
+
6
+ * Initial public release
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Solutious Inc, Delano Mandelbaum
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ = Hexoid v0.2
2
+
3
+ <b>Generate Ruby style object ids</b>
4
+
5
+ The default <tt>to_s</tt> method for Ruby objects includes the object id encoded as a hexadecimal: <tt>#<Object:0x000001009e60f8></tt>. When you add a <tt>to_s</tt> method to your own objects, you lose that hexadecimal value. Hexoid gives it back.
6
+
7
+ == Usage
8
+
9
+ require 'hexoid'
10
+
11
+ class A
12
+ def to_s
13
+ "<A:%s>" % self.hexoid
14
+ end
15
+ end
16
+
17
+ obj = A.new
18
+ puts obj # => "<A:0x10103a380>"
19
+ puts obj.hexoid # => "0x10103a380"
20
+
21
+ == Installation
22
+
23
+ Get it in one of the following ways:
24
+
25
+ * <tt>gem install hexoid</tt>
26
+ * <tt>git clone git://github.com/delano/hexoid.git</tt>
27
+ * <tt>gem install delano-hexoid --source http://gems.github.com</tt>
28
+
29
+
30
+ == Known Issues
31
+
32
+ * Does not work in JRuby
33
+
34
+
35
+ == More Information
36
+
37
+ * Codes[http://github.com/delano/hexoid]
38
+ * RDocs[http://delano.github.com/hexoid]
39
+ * Story[http://solutious.com/blog/2009/09/22/secret-of-object-to_s/]
40
+
41
+ == Credits
42
+
43
+ * Delano Mandelbaum (http://solutious.com)
44
+
45
+ == License
46
+
47
+ See LICENSE.txt
@@ -0,0 +1,73 @@
1
+
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'hanna/rdoctask'
5
+ require 'rake/testtask'
6
+ require 'shoulda/tasks'
7
+ require 'rake/runtest'
8
+ require 'monkeyspecdoc' # http://jgre.org/2008/09/03/monkeyspecdoc/
9
+ require 'fileutils'
10
+ include FileUtils
11
+
12
+ task :default => :test
13
+
14
+
15
+ # PACKAGE =============================================================
16
+
17
+ name = "hexoid"
18
+ load "#{name}.gemspec"
19
+
20
+ version = @spec.version
21
+
22
+ Rake::GemPackageTask.new(@spec) do |p|
23
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
24
+ end
25
+
26
+ task :release => [ "publish:gem", :clean, "publish:rdoc" ] do
27
+ $: << File.join(File.dirname(__FILE__), 'lib')
28
+ require "rudy"
29
+ abort if Drydock.debug?
30
+ end
31
+
32
+ task :install => [ :rdoc, :package ] do
33
+ sh %{sudo gem install pkg/#{name}-#{version}.gem}
34
+ end
35
+
36
+ task :uninstall => [ :clean ] do
37
+ sh %{sudo gem uninstall #{name}}
38
+ end
39
+
40
+
41
+ # Rubyforge Release / Publish Tasks ==================================
42
+
43
+ #about 'Publish website to rubyforge'
44
+ task 'publish:rdoc' => 'doc/index.html' do
45
+ sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
46
+ end
47
+
48
+ #about 'Public release to rubyforge'
49
+ task 'publish:gem' => [:package] do |t|
50
+ sh <<-end
51
+ rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
52
+ rubyforge add_file -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
53
+ end
54
+ end
55
+
56
+
57
+ Rake::RDocTask.new do |t|
58
+ t.rdoc_dir = 'doc'
59
+ t.title = @spec.summary
60
+ t.options << '--line-numbers' << '-A cattr_accessor=object'
61
+ t.options << '--charset' << 'utf-8'
62
+ t.rdoc_files.include('LICENSE.txt')
63
+ t.rdoc_files.include('README.rdoc')
64
+ t.rdoc_files.include('CHANGES.txt')
65
+ #t.rdoc_files.include('Rudyfile') # why is the formatting f'd?
66
+ t.rdoc_files.include('bin/*')
67
+ t.rdoc_files.include('lib/**/*.rb')
68
+ end
69
+
70
+ CLEAN.include [ 'pkg', '*.gem', '.config', 'doc', 'coverage*' ]
71
+
72
+
73
+
@@ -0,0 +1,28 @@
1
+ @spec = Gem::Specification.new do |s|
2
+ s.name = "hexoid"
3
+ s.rubyforge_project = 'hexoid'
4
+ s.version = "0.2.0"
5
+ s.summary = "Hexoid: Encode your object IDs like Ruby does."
6
+ s.description = s.summary
7
+ s.author = "Delano Mandelbaum"
8
+ s.email = "delano@solutious.com"
9
+ s.homepage = "http://github.com/delano/hexoid"
10
+
11
+ s.extra_rdoc_files = %w[README.rdoc LICENSE.txt CHANGES.txt]
12
+ s.has_rdoc = true
13
+ s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"]
14
+ s.require_paths = %w[lib]
15
+
16
+ # = MANIFEST =
17
+ # git ls-files
18
+ s.files = %w(
19
+ CHANGES.txt
20
+ LICENSE.txt
21
+ README.rdoc
22
+ Rakefile
23
+ hexoid.gemspec
24
+ lib/hexoid.rb
25
+ )
26
+
27
+
28
+ end
@@ -0,0 +1,9 @@
1
+
2
+
3
+ class Object
4
+ def hex_object_id
5
+ prefix = RUBY_VERSION >= '1.9' ? '0x00000' : '0x'
6
+ "%s%x" % [prefix, (self.object_id << 1)]
7
+ end
8
+ alias hexoid hex_object_id
9
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hexoid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Delano Mandelbaum
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-21 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "Hexoid: Encode your object IDs like Ruby does."
17
+ email: delano@solutious.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE.txt
25
+ - CHANGES.txt
26
+ files:
27
+ - CHANGES.txt
28
+ - LICENSE.txt
29
+ - README.rdoc
30
+ - Rakefile
31
+ - hexoid.gemspec
32
+ - lib/hexoid.rb
33
+ has_rdoc: true
34
+ homepage: http://github.com/delano/hexoid
35
+ licenses: []
36
+
37
+ post_install_message:
38
+ rdoc_options:
39
+ - --line-numbers
40
+ - --title
41
+ - "Hexoid: Encode your object IDs like Ruby does."
42
+ - --main
43
+ - README.rdoc
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project: hexoid
61
+ rubygems_version: 1.3.2
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: "Hexoid: Encode your object IDs like Ruby does."
65
+ test_files: []
66
+