constructor 1.0.4 → 2.0.0
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/History.rdoc +5 -0
- data/README.rdoc +1 -1
- data/Rakefile +17 -23
- data/constructor.gemspec +24 -0
- data/lib/constructor.rb +38 -117
- data/lib/constructor/constructor.rb +59 -0
- data/lib/constructor/version.rb +3 -0
- data/{specs → spec}/constructor_spec.rb +9 -9
- data/{specs → spec}/constructor_struct_spec.rb +0 -0
- metadata +72 -26
- data/homepage/Notes.txt +0 -27
- data/homepage/Rakefile +0 -15
- data/homepage/index.erb +0 -27
- data/homepage/index.html +0 -36
- data/homepage/page_header.graffle +0 -0
- data/homepage/page_header.html +0 -9
- data/homepage/page_header.png +0 -0
- data/homepage/sample_code.png +0 -0
- data/homepage/sample_code.rb +0 -12
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 2.0 / 2010-12-27
|
2
|
+
|
3
|
+
* Now uses an included module with an initialize method instead of a class_eval-ed initialize to better handle inheritance and mixins, and to simplify the code.
|
4
|
+
* Removed Jeweler, replaced with Bundler
|
5
|
+
|
1
6
|
== 1.0.4 / 2009-12-01
|
2
7
|
|
3
8
|
* Building is now done with Jeweler.
|
data/README.rdoc
CHANGED
@@ -50,7 +50,7 @@ to the Donkey constructor.
|
|
50
50
|
|
51
51
|
(The MIT License)
|
52
52
|
|
53
|
-
Copyright (c) 2007 Atomic Object
|
53
|
+
Copyright (c) 2007-2010 Atomic Object
|
54
54
|
|
55
55
|
Permission is hereby granted, free of charge, to any person obtaining
|
56
56
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -1,33 +1,27 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
begin
|
5
|
+
require 'rake/rdoctask'
|
6
|
+
require 'spec/rake/spectask'
|
7
|
+
rescue
|
8
|
+
puts "You need to: bundle install"
|
9
|
+
end
|
2
10
|
|
3
11
|
desc 'Default: run specs'
|
4
12
|
task :default => :spec
|
5
13
|
|
6
|
-
require 'spec/rake/spectask'
|
7
14
|
desc 'Run constructor specs'
|
8
15
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
9
|
-
t.spec_files = FileList['specs/*_spec.rb']
|
10
16
|
t.spec_opts << '-c -f s'
|
11
17
|
end
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
gemspec.homepage = 'http://atomicobject.github.com/constructor'
|
23
|
-
gemspec.authors = 'Atomic Object'
|
24
|
-
gemspec.email = 'github@atomicobject.com'
|
25
|
-
gemspec.test_files = FileList['specs/*_spec.rb']
|
26
|
-
end
|
27
|
-
|
28
|
-
Jeweler::GemcutterTasks.new
|
29
|
-
|
30
|
-
rescue LoadError
|
31
|
-
puts "(jeweler not installed)"
|
32
|
-
end
|
33
|
-
|
19
|
+
desc 'Generate documentation'
|
20
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
21
|
+
rdoc.rdoc_dir = 'doc'
|
22
|
+
rdoc.title = 'constructor'
|
23
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
24
|
+
rdoc.rdoc_files.include('README.rdoc')
|
25
|
+
rdoc.rdoc_files.include('History.rdoc')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
data/constructor.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "constructor/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "constructor"
|
7
|
+
s.version = Constructor::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Atomic Object"]
|
10
|
+
s.email = ["github@atomicobject.com"]
|
11
|
+
s.homepage = "http://atomicobject.github.com/constructor"
|
12
|
+
s.summary = %q{Declarative named-argument object initialization.}
|
13
|
+
s.description = %q{Declarative means to define object properties by passing a hash to the constructor, which will set the corresponding ivars.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "constructor"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n").reject {|f| f =~ /homepage/}
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec", ">= 1", "<= 1.3.1"
|
23
|
+
s.add_development_dependency "rake", ">= 0.8.7"
|
24
|
+
end
|
data/lib/constructor.rb
CHANGED
@@ -1,127 +1,48 @@
|
|
1
|
-
|
1
|
+
require 'constructor/constructor'
|
2
2
|
|
3
|
-
class Class
|
3
|
+
class Class
|
4
|
+
def _constructor_config #:nodoc:#
|
5
|
+
# Inherit an existing config from an ancestor if possible
|
6
|
+
@constructor_config ||= (@constructor_config ? @constructor_config : (superclass ? superclass._constructor_config.dup : nil)) || {}
|
7
|
+
end
|
8
|
+
|
9
|
+
# Access the constructor keys for this class
|
10
|
+
def constructor_keys
|
11
|
+
# Inherit keys from an ancestor if possible
|
12
|
+
@_ctor_keys ||= (@_ctor_keys ? @_ctor_keys : (superclass ? superclass.constructor_keys.dup : nil)) || []
|
13
|
+
end
|
14
|
+
|
15
|
+
# Defines an initialize method for the class that expects a hash
|
16
|
+
# of named arguments
|
17
|
+
#
|
18
|
+
#
|
19
|
+
# class Horse
|
20
|
+
# construct :name, :breed, :weight
|
21
|
+
# end
|
22
|
+
# Horse.new :name => 'Ed', :breed => 'Mustang', :weight => 342
|
4
23
|
def constructor(*attrs, &block)
|
5
|
-
|
6
|
-
if block_given?
|
7
|
-
@constructor_block = block
|
8
|
-
call_block = 'self.instance_eval(&self.class.constructor_block)'
|
9
|
-
end
|
10
|
-
# Look for embedded options in the listing:
|
11
|
-
opts = attrs.find { |a| a.kind_of?(Hash) and attrs.delete(a) }
|
12
|
-
do_acc = opts.nil? ? false : opts[:accessors] == true
|
13
|
-
do_reader = opts.nil? ? false : opts[:readers] == true
|
14
|
-
require_args = opts.nil? ? true : opts[:strict] != false
|
15
|
-
super_args = opts.nil? ? nil : opts[:super]
|
16
|
-
|
17
|
-
# Incorporate superclass's constructor keys, if our superclass
|
18
|
-
if superclass.constructor_keys
|
24
|
+
if superclass.constructor_keys.any?
|
19
25
|
similar_keys = superclass.constructor_keys & attrs
|
20
26
|
raise "Base class already has keys #{similar_keys.inspect}" unless similar_keys.empty?
|
21
|
-
attrs = [attrs,superclass.constructor_keys].flatten
|
22
|
-
end
|
23
|
-
# Generate ivar assigner code lines
|
24
|
-
assigns = ''
|
25
|
-
attrs.each do |k|
|
26
|
-
assigns += "@#{k.to_s} = args[:#{k.to_s}]\n"
|
27
|
-
end
|
28
|
-
|
29
|
-
# If accessors option is on, declare accessors for the attributes:
|
30
|
-
if do_acc
|
31
|
-
add_accessors = "attr_accessor " + attrs.reject {|x| superclass.constructor_keys.include?(x.to_sym)}.map {|x| ":#{x.to_s}"}.join(',')
|
32
|
-
#add_accessors = "attr_accessor " + attrs.map {|x| ":#{x.to_s}"}.join(',')
|
33
|
-
self.class_eval add_accessors
|
34
|
-
end
|
35
|
-
|
36
|
-
# If readers option is on, declare readers for the attributes:
|
37
|
-
if do_reader
|
38
|
-
self.class_eval "attr_reader " + attrs.reject {|x| superclass.constructor_keys.include?(x.to_sym)}.map {|x| ":#{x.to_s}"}.join(',')
|
39
27
|
end
|
40
28
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
%|:#{a}|
|
50
|
-
end
|
51
|
-
end
|
52
|
-
super_call = %|super(#{list.join(',')})|
|
53
|
-
end
|
54
|
-
|
55
|
-
# If strict is on, define the constructor argument validator method,
|
56
|
-
# and setup the initializer to invoke the validator method.
|
57
|
-
# Otherwise, insert lax code into the initializer.
|
58
|
-
validation_code = "return if args.nil?"
|
59
|
-
if require_args
|
60
|
-
self.class_eval do
|
61
|
-
def _validate_constructor_args(args)
|
62
|
-
# First, make sure we've got args of some kind
|
63
|
-
unless args and args.keys and args.keys.size > 0
|
64
|
-
raise ConstructorArgumentError.new(self.class.constructor_keys)
|
65
|
-
end
|
66
|
-
# Scan for missing keys in the argument hash
|
67
|
-
a_keys = args.keys
|
68
|
-
missing = []
|
69
|
-
self.class.constructor_keys.each do |ck|
|
70
|
-
unless a_keys.member?(ck)
|
71
|
-
missing << ck
|
72
|
-
end
|
73
|
-
a_keys.delete(ck) # Delete inbound keys as we address them
|
74
|
-
end
|
75
|
-
if missing.size > 0 || a_keys.size > 0
|
76
|
-
raise ConstructorArgumentError.new(missing,a_keys)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
# Setup the code to insert into the initializer:
|
81
|
-
validation_code = "_validate_constructor_args args "
|
29
|
+
# Look for embedded options in the listing:
|
30
|
+
opts = attrs.find { |a| a.kind_of?(Hash) and attrs.delete(a) }
|
31
|
+
do_accessors = opts.nil? ? false : opts[:accessors] == true
|
32
|
+
do_readers = opts.nil? ? false : opts[:readers] == true
|
33
|
+
_constructor_config[:require_args] = opts.nil? ? true : opts[:strict] != false
|
34
|
+
_constructor_config[:super_args] = opts.nil? ? nil : opts[:super]
|
35
|
+
if block_given?
|
36
|
+
_constructor_config[:constructor_block] = block
|
82
37
|
end
|
83
38
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
93
|
-
}
|
94
|
-
|
95
|
-
# Remember our constructor keys
|
96
|
-
@_ctor_keys = attrs
|
97
|
-
end
|
98
|
-
|
99
|
-
# Access the constructor keys for this class
|
100
|
-
def constructor_keys; @_ctor_keys ||=[]; end
|
101
|
-
|
102
|
-
def constructor_block #:nodoc:#
|
103
|
-
@constructor_block
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
# Fancy validation exception, based on missing and extraneous keys.
|
109
|
-
class ConstructorArgumentError < RuntimeError #:nodoc:#
|
110
|
-
def initialize(missing,rejected=[])
|
111
|
-
err_msg = ''
|
112
|
-
if missing.size > 0
|
113
|
-
err_msg = "Missing constructor args [#{missing.join(',')}]"
|
114
|
-
end
|
115
|
-
if rejected.size > 0
|
116
|
-
# Some inbound keys were not addressed earlier; this means they're unwanted
|
117
|
-
if err_msg
|
118
|
-
err_msg << "; " # Appending to earlier message about missing items
|
119
|
-
else
|
120
|
-
err_msg = ''
|
121
|
-
end
|
122
|
-
# Enumerate the rejected key names
|
123
|
-
err_msg << "Rejected constructor args [#{rejected.join(',')}]"
|
124
|
-
end
|
125
|
-
super err_msg
|
39
|
+
attr_accessor(*attrs) if do_accessors
|
40
|
+
attr_reader(*attrs) if do_readers
|
41
|
+
|
42
|
+
# Remember all constructor keys
|
43
|
+
@_ctor_keys = [attrs,superclass.constructor_keys].flatten
|
44
|
+
|
45
|
+
# Build the new initialize method
|
46
|
+
include Constructor
|
126
47
|
end
|
127
48
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Constructor #:nodoc:#
|
2
|
+
def initialize(args = nil)
|
3
|
+
config = self.class._constructor_config
|
4
|
+
super(*config[:super_args]) if config[:super_args] && defined?(super)
|
5
|
+
|
6
|
+
keys = self.class.constructor_keys
|
7
|
+
if config[:require_args]
|
8
|
+
# First, make sure we've got args of some kind
|
9
|
+
unless args and args.keys and args.keys.size > 0
|
10
|
+
raise ArgumentError.new(keys)
|
11
|
+
end
|
12
|
+
# Scan for missing keys in the argument hash
|
13
|
+
a_keys = args.keys
|
14
|
+
missing = []
|
15
|
+
keys.each do |ck|
|
16
|
+
unless a_keys.member?(ck)
|
17
|
+
missing << ck
|
18
|
+
end
|
19
|
+
a_keys.delete(ck) # Delete inbound keys as we address them
|
20
|
+
end
|
21
|
+
if missing.size > 0 || a_keys.size > 0
|
22
|
+
raise ArgumentError.new(missing,a_keys)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if args
|
27
|
+
keys.each do |key|
|
28
|
+
instance_variable_set "@#{key}", args[key]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
setup if respond_to?(:setup)
|
33
|
+
|
34
|
+
if config[:constructor_block]
|
35
|
+
instance_eval(&config[:constructor_block])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Fancy validation exception, based on missing and extraneous keys.
|
40
|
+
class ArgumentError < RuntimeError #:nodoc:#
|
41
|
+
def initialize(missing,rejected=[])
|
42
|
+
err_msg = ''
|
43
|
+
if missing.size > 0
|
44
|
+
err_msg = "Missing constructor args [#{missing.join(',')}]"
|
45
|
+
end
|
46
|
+
if rejected.size > 0
|
47
|
+
# Some inbound keys were not addressed earlier; this means they're unwanted
|
48
|
+
if err_msg
|
49
|
+
err_msg << "; " # Appending to earlier message about missing items
|
50
|
+
else
|
51
|
+
err_msg = ''
|
52
|
+
end
|
53
|
+
# Enumerate the rejected key names
|
54
|
+
err_msg << "Rejected constructor args [#{rejected.join(',')}]"
|
55
|
+
end
|
56
|
+
super err_msg
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -191,12 +191,12 @@ describe 'stict mode usage' do
|
|
191
191
|
# Omit foo
|
192
192
|
lambda {
|
193
193
|
TestingStrictArgsDefault.new :bar => 'ok,yeah'
|
194
|
-
}.should raise_error(
|
194
|
+
}.should raise_error(Constructor::ArgumentError, /foo/)
|
195
195
|
|
196
196
|
# Omit bar
|
197
197
|
lambda {
|
198
198
|
TestingStrictArgsDefault.new :foo => 'ok,yeah'
|
199
|
-
}.should raise_error(
|
199
|
+
}.should raise_error(Constructor::ArgumentError, /bar/)
|
200
200
|
end
|
201
201
|
|
202
202
|
it 'defaults to strict argument enforcement' do
|
@@ -208,16 +208,16 @@ describe 'stict mode usage' do
|
|
208
208
|
end
|
209
209
|
|
210
210
|
it 'does not allow empty constructor arguments when strict option is true' do
|
211
|
-
lambda {TestingStrictArgs.new {}}.should raise_error(
|
212
|
-
lambda {TestingStrictArgs.new}.should raise_error(
|
213
|
-
lambda {TestingStrictArgs.new nil}.should raise_error(
|
211
|
+
lambda {TestingStrictArgs.new {}}.should raise_error(Constructor::ArgumentError,/foo,bar/)
|
212
|
+
lambda {TestingStrictArgs.new}.should raise_error(Constructor::ArgumentError,/foo,bar/)
|
213
|
+
lambda {TestingStrictArgs.new nil}.should raise_error(Constructor::ArgumentError,/foo,bar/)
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'does not allow extraneous arguments when strict option is true' do
|
217
217
|
[ /thing/, /other/ ].each do |rejected_arg|
|
218
218
|
lambda {
|
219
219
|
TestingStrictArgs.new(:foo => 1, :bar => 2, :other => 3, :thing => 4)
|
220
|
-
}.should raise_error(
|
220
|
+
}.should raise_error(Constructor::ArgumentError, rejected_arg)
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
@@ -229,16 +229,16 @@ describe 'stict mode usage' do
|
|
229
229
|
t2.bar.should eql(2)
|
230
230
|
|
231
231
|
# See that strictness still applies
|
232
|
-
lambda {TestingStrictArgs2.new :no => 'good'}.should raise_error(
|
232
|
+
lambda {TestingStrictArgs2.new :no => 'good'}.should raise_error(Constructor::ArgumentError)
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
describe 'catching
|
236
|
+
describe 'catching Constructor::ArgumentError' do
|
237
237
|
it 'allows for generic rescuing of constructor argument errors' do
|
238
238
|
begin
|
239
239
|
TestingStrictArgs.new :broken => 'yoobetcha'
|
240
240
|
rescue => bad_news
|
241
|
-
bad_news.should be_kind_of(
|
241
|
+
bad_news.should be_kind_of(Constructor::ArgumentError)
|
242
242
|
end
|
243
243
|
end
|
244
244
|
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Atomic Object
|
@@ -9,63 +15,103 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2010-12-30 00:00:00 -05:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
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: 1
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
version: "1"
|
31
|
+
- - <=
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
hash: 25
|
34
|
+
segments:
|
35
|
+
- 1
|
36
|
+
- 3
|
37
|
+
- 1
|
38
|
+
version: 1.3.1
|
39
|
+
type: :development
|
40
|
+
name: rspec
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: *id001
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 49
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
- 8
|
53
|
+
- 7
|
54
|
+
version: 0.8.7
|
55
|
+
type: :development
|
56
|
+
name: rake
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: *id002
|
16
59
|
description: Declarative means to define object properties by passing a hash to the constructor, which will set the corresponding ivars.
|
17
|
-
email:
|
60
|
+
email:
|
61
|
+
- github@atomicobject.com
|
18
62
|
executables: []
|
19
63
|
|
20
64
|
extensions: []
|
21
65
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
66
|
+
extra_rdoc_files: []
|
67
|
+
|
24
68
|
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
25
71
|
- History.rdoc
|
26
72
|
- README.rdoc
|
27
73
|
- Rakefile
|
28
|
-
-
|
29
|
-
- homepage/Rakefile
|
30
|
-
- homepage/index.erb
|
31
|
-
- homepage/index.html
|
32
|
-
- homepage/page_header.graffle
|
33
|
-
- homepage/page_header.html
|
34
|
-
- homepage/page_header.png
|
35
|
-
- homepage/sample_code.png
|
36
|
-
- homepage/sample_code.rb
|
74
|
+
- constructor.gemspec
|
37
75
|
- lib/constructor.rb
|
76
|
+
- lib/constructor/constructor.rb
|
77
|
+
- lib/constructor/version.rb
|
38
78
|
- lib/constructor_struct.rb
|
39
|
-
-
|
40
|
-
-
|
79
|
+
- spec/constructor_spec.rb
|
80
|
+
- spec/constructor_struct_spec.rb
|
41
81
|
has_rdoc: true
|
42
82
|
homepage: http://atomicobject.github.com/constructor
|
43
83
|
licenses: []
|
44
84
|
|
45
85
|
post_install_message:
|
46
|
-
rdoc_options:
|
47
|
-
|
86
|
+
rdoc_options: []
|
87
|
+
|
48
88
|
require_paths:
|
49
89
|
- lib
|
50
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
51
92
|
requirements:
|
52
93
|
- - ">="
|
53
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
54
98
|
version: "0"
|
55
|
-
version:
|
56
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
57
101
|
requirements:
|
58
102
|
- - ">="
|
59
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
60
107
|
version: "0"
|
61
|
-
version:
|
62
108
|
requirements: []
|
63
109
|
|
64
|
-
rubyforge_project:
|
65
|
-
rubygems_version: 1.3.
|
110
|
+
rubyforge_project: constructor
|
111
|
+
rubygems_version: 1.3.7
|
66
112
|
signing_key:
|
67
113
|
specification_version: 3
|
68
114
|
summary: Declarative named-argument object initialization.
|
69
115
|
test_files:
|
70
|
-
-
|
71
|
-
-
|
116
|
+
- spec/constructor_spec.rb
|
117
|
+
- spec/constructor_struct_spec.rb
|
data/homepage/Notes.txt
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
Wed Nov 21 21:49:27 EST 2007
|
2
|
-
crosby
|
3
|
-
|
4
|
-
1. Edit page_header.graffle
|
5
|
-
2. Export as HTML imagemap
|
6
|
-
3. Open ../sample_code/synopsis.rb
|
7
|
-
4. Screen shot, save as sample_code.png
|
8
|
-
5. rake (rewrites index.html)
|
9
|
-
6. cd ..
|
10
|
-
7. rake publish_docs
|
11
|
-
|
12
|
-
page_header.graffle
|
13
|
-
Export-as-HTML-Imagemap
|
14
|
-
Use png
|
15
|
-
Use 125% scale
|
16
|
-
Remember to use the style inspector to assign actions to things that should be links.
|
17
|
-
|
18
|
-
rake index
|
19
|
-
Rewrites index.html using index.erb and page_header.html (and some values in the Rakefile)
|
20
|
-
|
21
|
-
The code sample screenshot:
|
22
|
-
Taken with Snapz Pro X (this is important, as Snapz is providing the
|
23
|
-
dropshadow and about 28 extra pixels widthwise)
|
24
|
-
|
25
|
-
Should be 650 px wide to line up with the page header.
|
26
|
-
|
27
|
-
Transparency: be conscious of WHAT'S IN THE BACKGROUND
|
data/homepage/Rakefile
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
desc "Rewrite index.html using index.erb and publisher_homepage.html"
|
2
|
-
task :index do
|
3
|
-
require 'erb'
|
4
|
-
@title = "Constructor - atomicobject.rb"
|
5
|
-
@plugin_install = "$ script/plugin install svn://rubyforge.org/var/svn/atomicobjectrb/tags/constructor"
|
6
|
-
@header_html = File.read("page_header.html")
|
7
|
-
html = ERB.new(File.read("index.erb")).result(binding)
|
8
|
-
fname = "index.html"
|
9
|
-
File.open(fname,"w") do |f|
|
10
|
-
f.print html
|
11
|
-
end
|
12
|
-
puts "Wrote #{fname}"
|
13
|
-
end
|
14
|
-
|
15
|
-
task :default => :index
|
data/homepage/index.erb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title><%= @title %></title>
|
4
|
-
</head>
|
5
|
-
<style>
|
6
|
-
#rails_plugin_installation {
|
7
|
-
padding: 5px;
|
8
|
-
margin-bottom: 10px;
|
9
|
-
font: bold 10pt "Courier New", courier, serif
|
10
|
-
}
|
11
|
-
</style>
|
12
|
-
|
13
|
-
<body>
|
14
|
-
|
15
|
-
<div align="center">
|
16
|
-
|
17
|
-
<%= @header_html %>
|
18
|
-
|
19
|
-
<div id="rails_plugin_installation"><%= @plugin_install %></div>
|
20
|
-
|
21
|
-
<a href="rdoc/index.html"><img border=0 src="sample_code.png"></a>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
</body>
|
27
|
-
</html>
|
data/homepage/index.html
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>Constructor - atomicobject.rb</title>
|
4
|
-
</head>
|
5
|
-
<style>
|
6
|
-
#rails_plugin_installation {
|
7
|
-
padding: 5px;
|
8
|
-
margin-bottom: 10px;
|
9
|
-
font: bold 10pt "Courier New", courier, serif
|
10
|
-
}
|
11
|
-
</style>
|
12
|
-
|
13
|
-
<body>
|
14
|
-
|
15
|
-
<div align="center">
|
16
|
-
|
17
|
-
<map name="GraffleExport">
|
18
|
-
<area shape=rect coords="486,91,635,108" href="http://atomicobjectrb.rubyforge.org/">
|
19
|
-
<area shape=rect coords="485,120,635,187" href="rdoc/index.html">
|
20
|
-
<area shape=rect coords="310,120,463,187" href="http://rubyforge.org/frs/?group_id=4897&release_id=16546">
|
21
|
-
<area shape=rect coords="14,91,168,108" href="http://atomicobject.com">
|
22
|
-
<area shape=rect coords="572,16,627,71" href="http://atomicobjectrb.rubyforge.org/">
|
23
|
-
<area shape=rect coords="21,13,83,75" href="http://atomicobject.com">
|
24
|
-
</map>
|
25
|
-
<img border=0 src="page_header.png" usemap="#GraffleExport">
|
26
|
-
|
27
|
-
|
28
|
-
<div id="rails_plugin_installation">$ script/plugin install svn://rubyforge.org/var/svn/atomicobjectrb/tags/constructor</div>
|
29
|
-
|
30
|
-
<a href="rdoc/index.html"><img border=0 src="sample_code.png"></a>
|
31
|
-
</div>
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
</body>
|
36
|
-
</html>
|
Binary file
|
data/homepage/page_header.html
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
<map name="GraffleExport">
|
2
|
-
<area shape=rect coords="486,91,635,108" href="http://atomicobjectrb.rubyforge.org/">
|
3
|
-
<area shape=rect coords="485,120,635,187" href="rdoc/index.html">
|
4
|
-
<area shape=rect coords="310,120,463,187" href="http://rubyforge.org/frs/?group_id=4897&release_id=16546">
|
5
|
-
<area shape=rect coords="14,91,168,108" href="http://atomicobject.com">
|
6
|
-
<area shape=rect coords="572,16,627,71" href="http://atomicobjectrb.rubyforge.org/">
|
7
|
-
<area shape=rect coords="21,13,83,75" href="http://atomicobject.com">
|
8
|
-
</map>
|
9
|
-
<img border=0 src="page_header.png" usemap="#GraffleExport">
|
data/homepage/page_header.png
DELETED
Binary file
|
data/homepage/sample_code.png
DELETED
Binary file
|
data/homepage/sample_code.rb
DELETED