arrayclass 0.1.0 → 0.1.1
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/Rakefile +21 -41
- data/lib/arrayclass.rb +4 -3
- metadata +8 -9
- data/specs/arrayclass_spec.rb +0 -165
- data/specs/light_class_shared.rb +0 -1
- data/specs/spec_helper.rb +0 -57
data/Rakefile
CHANGED
@@ -2,9 +2,8 @@ require 'rake'
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'rake/gempackagetask'
|
5
|
+
require 'rake/testtask'
|
5
6
|
require 'rake/clean'
|
6
|
-
require 'spec/rake/spectask'
|
7
|
-
require 'email_encrypt'
|
8
7
|
|
9
8
|
require 'fileutils'
|
10
9
|
|
@@ -61,7 +60,9 @@ task :html_docs do
|
|
61
60
|
|
62
61
|
# add contact info:
|
63
62
|
index.puts '<h2>Contact</h2>'
|
64
|
-
|
63
|
+
|
64
|
+
jtprince_gmail_email_encrypted = '<a href="mailto:%6a%74%70%72%69%6e%63%65%40%67%6d%61%69%6c%2e%63%6f%6d">jtprince@gmail.com</a>'
|
65
|
+
index.puts jtprince_gmail_email_encrypted
|
65
66
|
|
66
67
|
index.puts '</body></html>'
|
67
68
|
end
|
@@ -78,48 +79,28 @@ end
|
|
78
79
|
###############################################
|
79
80
|
|
80
81
|
|
81
|
-
|
82
|
-
|
83
|
-
if reply.include? NAME + " ("
|
84
|
-
puts "GOING to uninstall gem '#{NAME}' for testing"
|
85
|
-
if WIN32
|
86
|
-
%x( #{$gemcmd} uninstall -x #{NAME} )
|
87
|
-
else
|
88
|
-
%x( sudo #{$gemcmd} uninstall -x #{NAME} )
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
namespace :spec do
|
94
|
-
task :autotest do
|
95
|
-
require './specs/rspec_autotest'
|
96
|
-
RspecAutotest.run
|
97
|
-
end
|
98
|
-
end
|
82
|
+
desc 'Default: Run specs.'
|
83
|
+
task :default => :spec
|
99
84
|
|
100
|
-
desc
|
101
|
-
|
102
|
-
|
85
|
+
desc 'Run specs.'
|
86
|
+
Rake::TestTask.new(:spec) do |t|
|
87
|
+
# can specify SPEC=<file>_spec.rb or TEST=<file>_spec.rb
|
88
|
+
ENV['TEST'] = ENV['SPEC'] if ENV['SPEC']
|
103
89
|
t.libs = ['lib']
|
104
|
-
t.
|
90
|
+
t.test_files = Dir.glob( File.join('spec', ENV['pattern'] || '**/*_spec.rb') )
|
91
|
+
t.verbose = true
|
92
|
+
t.warning = true
|
105
93
|
end
|
106
94
|
|
107
|
-
desc "Run specs and output specdoc"
|
108
|
-
Spec::Rake::SpecTask.new('specl') do |t|
|
109
|
-
Rake::Task[:ensure_gem_is_uninstalled].invoke
|
110
|
-
t.spec_files = FileList['specs/**/*_spec.rb']
|
111
|
-
t.libs = ['lib']
|
112
|
-
t.spec_opts = ['--format', 'specdoc' ]
|
113
|
-
end
|
114
95
|
|
115
|
-
desc "Run all specs with RCov"
|
116
|
-
Spec::Rake::SpecTask.new('rcov') do |t|
|
117
|
-
Rake::Task[:ensure_gem_is_uninstalled].invoke
|
118
|
-
t.spec_files = FileList['specs/**/*_spec.rb']
|
119
|
-
t.rcov = true
|
120
|
-
t.libs = ['lib']
|
121
|
-
t.rcov_opts = ['--exclude', 'specs']
|
122
|
-
end
|
96
|
+
#desc "Run all specs with RCov"
|
97
|
+
#Spec::Rake::SpecTask.new('rcov') do |t|
|
98
|
+
# Rake::Task[:ensure_gem_is_uninstalled].invoke
|
99
|
+
# t.spec_files = FileList['specs/**/*_spec.rb']
|
100
|
+
# t.rcov = true
|
101
|
+
# t.libs = ['lib']
|
102
|
+
# t.rcov_opts = ['--exclude', 'specs']
|
103
|
+
#end
|
123
104
|
|
124
105
|
#task :spec do
|
125
106
|
# uninstall_gem
|
@@ -212,7 +193,6 @@ Rake::GemPackageTask.new(gemspec) do |pkg|
|
|
212
193
|
end
|
213
194
|
|
214
195
|
|
215
|
-
|
216
196
|
task :remove_pkg do
|
217
197
|
FileUtils.rm_rf "pkg"
|
218
198
|
end
|
data/lib/arrayclass.rb
CHANGED
@@ -65,9 +65,10 @@ module Arrayclass
|
|
65
65
|
|
66
66
|
|
67
67
|
# This list is derived from ImageList in ImageMagick (and I've added some
|
68
|
-
# applicable to this guy) (I've left
|
69
|
-
#
|
70
|
-
|
68
|
+
# applicable to this guy). (I've left join and zip in the
|
69
|
+
# list of attributes since they are both handy and
|
70
|
+
# wouldn't hurt.)
|
71
|
+
%w(flatten flatten! assoc rassoc push pop <<).each do |att|
|
71
72
|
nclass.class_eval("undef_method :#{att}")
|
72
73
|
end
|
73
74
|
nclass.class_eval("undef_method :transpose if Array.instance_methods(false).include?('transpose')")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arrayclass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Prince
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-05-18 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -26,11 +26,10 @@ files:
|
|
26
26
|
- README
|
27
27
|
- LICENSE
|
28
28
|
- Rakefile
|
29
|
-
- specs/spec_helper.rb
|
30
|
-
- specs/light_class_shared.rb
|
31
|
-
- specs/arrayclass_spec.rb
|
32
29
|
has_rdoc: true
|
33
30
|
homepage: http://arrayclass.rubyforge.org
|
31
|
+
licenses: []
|
32
|
+
|
34
33
|
post_install_message:
|
35
34
|
rdoc_options:
|
36
35
|
- --main
|
@@ -54,9 +53,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
53
|
requirements: []
|
55
54
|
|
56
55
|
rubyforge_project: arrayclass
|
57
|
-
rubygems_version: 1.2
|
56
|
+
rubygems_version: 1.3.2
|
58
57
|
signing_key:
|
59
|
-
specification_version:
|
58
|
+
specification_version: 3
|
60
59
|
summary: low memory class based on Array
|
61
|
-
test_files:
|
62
|
-
|
60
|
+
test_files: []
|
61
|
+
|
data/specs/arrayclass_spec.rb
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
require File.expand_path( File.dirname(__FILE__) + '/spec_helper' )
|
2
|
-
require File.dirname(__FILE__) + '/light_class_shared'
|
3
|
-
|
4
|
-
require 'arrayclass'
|
5
|
-
|
6
|
-
describe Arrayclass do
|
7
|
-
before(:each) do
|
8
|
-
@generator = Arrayclass
|
9
|
-
@attrs = %w(f0 f1 f2)
|
10
|
-
@attrs_as_symbols = @attrs.map {|v| v.to_sym }
|
11
|
-
@myclass = @generator.new(@attrs)
|
12
|
-
@init_array = [0,1,2]
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'can be initialized with an array' do
|
16
|
-
obj = @myclass.new(@init_array)
|
17
|
-
obj.f0.should == obj[0]
|
18
|
-
obj.f1.should == obj[1]
|
19
|
-
obj.f2.should == obj[2]
|
20
|
-
obj.f1 = 5
|
21
|
-
obj.f1.should == 5
|
22
|
-
obj.class.should == @myclass
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'can be queried and modified by method call' do
|
26
|
-
obj = @myclass.new(@init_array)
|
27
|
-
obj.f0.should == 0
|
28
|
-
obj.f1.should == 1
|
29
|
-
obj.f2.should == 2
|
30
|
-
|
31
|
-
obj.f0 = 5
|
32
|
-
obj.f1 = 6
|
33
|
-
obj.f2 = 7
|
34
|
-
|
35
|
-
obj.f0.should == 5
|
36
|
-
obj.f1.should == 6
|
37
|
-
obj.f2.should == 7
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'can be queried and modified by array index' do
|
41
|
-
obj = @myclass.new(@init_array)
|
42
|
-
obj[0].should == 0
|
43
|
-
obj[1].should == 1
|
44
|
-
obj[2].should == 2
|
45
|
-
|
46
|
-
obj[0] = 5
|
47
|
-
obj[1] = 6
|
48
|
-
obj[2] = 7
|
49
|
-
|
50
|
-
obj[0].should == 5
|
51
|
-
obj[1].should == 6
|
52
|
-
obj[2].should == 7
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'can have methods added' do
|
56
|
-
MyClass = @generator.new([:one])
|
57
|
-
class MyClass
|
58
|
-
def hello() 'hiya' end
|
59
|
-
end
|
60
|
-
obj = MyClass.new
|
61
|
-
obj.hello.should == 'hiya'
|
62
|
-
# OR -->
|
63
|
-
#@myclass.class_eval("def hello() 'hiya' end")
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'can be initialized with a hash' do
|
67
|
-
## Hash initialization:
|
68
|
-
obj = @myclass.new(:f0 => 0, :f1 => 1, :f2 => 2)
|
69
|
-
obj.f0.should == 0
|
70
|
-
obj.f1.should == 1
|
71
|
-
obj.f2.should == 2
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'can set and retrieve multiple members in a single slice' do
|
75
|
-
obj = @myclass.new
|
76
|
-
obj[0,3] = [4,5,6]
|
77
|
-
obj[0].should == 4
|
78
|
-
obj[1].should == 5
|
79
|
-
obj[2].should == 6
|
80
|
-
obj[0..-1] = [7,8,9]
|
81
|
-
obj[0].should == 7
|
82
|
-
obj[1].should == 8
|
83
|
-
obj[2].should == 9
|
84
|
-
|
85
|
-
obj[0,2].should == [7,8]
|
86
|
-
obj[0..1].should == [7,8]
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'has a member list (like Struct)' do
|
90
|
-
obj = @myclass.new
|
91
|
-
obj.members.should == @attrs_as_symbols
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'does not respond to calls that would potentially mess up your object' do
|
95
|
-
%w(flatten flatten! assoc join rassoc push pop <<).each do |cl|
|
96
|
-
obj = @myclass.new
|
97
|
-
obj.respond_to?(cl.to_sym).should == false
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'is resilient to flattening' do
|
102
|
-
## inside of arrays:
|
103
|
-
obj = @myclass.new([0,1,2])
|
104
|
-
y = @myclass.new([0,nil,1])
|
105
|
-
result = [[obj,[y]],nil].flatten
|
106
|
-
|
107
|
-
# [[0,1,2], [0,nil,1], nil]
|
108
|
-
# result.should == [[0,1,2], [0,nil,1], nil]
|
109
|
-
result[0][0].should == 0
|
110
|
-
result[0][1].should == 1
|
111
|
-
result[0][2].should == 2
|
112
|
-
|
113
|
-
result[1][0].should == 0
|
114
|
-
result[1][1].should == nil
|
115
|
-
result[1][2].should == 1
|
116
|
-
|
117
|
-
result[2].should == nil
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'is hashed like an object' do
|
121
|
-
# arrays are hashed by values so that identical arrays give same key:
|
122
|
-
hash = { [1,2,3] => 'dog'}
|
123
|
-
hash[[1,2,3]].should == hash[[1,2,3]]
|
124
|
-
|
125
|
-
# these are objects and so two different objects should hash different,
|
126
|
-
# even with the same values!
|
127
|
-
ar = [1,2,3]
|
128
|
-
one = @myclass.new(ar)
|
129
|
-
same_data_diff_object = @myclass.new(ar)
|
130
|
-
hash = { one => 'dog' }
|
131
|
-
hash[one].should == hash[one]
|
132
|
-
hash[one].should_not == hash[same_data_diff_object]
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'gives inspect (like Struct)' do
|
136
|
-
obj = @myclass.new
|
137
|
-
obj.f0 = 1
|
138
|
-
obj.f1 = 'string'
|
139
|
-
obj.inspect.should =~ /<.*f0=1, f1="string", f2="nil">/
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'can be inherited and add members' do
|
143
|
-
|
144
|
-
# the size should not change of original guy after inheritance
|
145
|
-
y = @myclass.new
|
146
|
-
y_size = y.size
|
147
|
-
class Inherited < @myclass
|
148
|
-
self.add_member(:f3)
|
149
|
-
self.add_member(:f4)
|
150
|
-
end
|
151
|
-
y_size.should == @myclass.new.size
|
152
|
-
|
153
|
-
obj = Inherited.new([0,-1,-2,1,2])
|
154
|
-
obj.f0.should == 0
|
155
|
-
obj[1].should == -1
|
156
|
-
obj.f3.should == 1
|
157
|
-
obj[4].should == 2
|
158
|
-
obj.is_a?(Inherited).should be_true
|
159
|
-
obj.is_a?(@myclass).should be_true
|
160
|
-
obj.is_a?(Array).should_not be_true
|
161
|
-
|
162
|
-
obj.size.should_not == y_size
|
163
|
-
end
|
164
|
-
|
165
|
-
end
|
data/specs/light_class_shared.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
|
data/specs/spec_helper.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
gem 'rspec'
|
3
|
-
|
4
|
-
|
5
|
-
def xdescribe(*args)
|
6
|
-
puts "#{args.join(' ')}"
|
7
|
-
puts "**SKIPPING**"
|
8
|
-
end
|
9
|
-
|
10
|
-
def Xdescribe(*args)
|
11
|
-
xdescribe(*args)
|
12
|
-
end
|
13
|
-
|
14
|
-
def xit(*args)
|
15
|
-
puts "- SKIPPING: #{args.join(' ')}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def silent(&block)
|
19
|
-
tmp = $VERBOSE ; $VERBOSE = nil
|
20
|
-
block.call
|
21
|
-
$VERBOSE = tmp
|
22
|
-
end
|
23
|
-
|
24
|
-
silent {
|
25
|
-
ROOT_DIR = File.dirname(__FILE__) + '/..'
|
26
|
-
SPEC_DIR = File.dirname(__FILE__)
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
class String
|
31
|
-
#alias_method :exist?, exist_as_a_file?
|
32
|
-
#alias_method exist_as_a_file?, exist?
|
33
|
-
def exist?
|
34
|
-
File.exist? self
|
35
|
-
end
|
36
|
-
def exist_as_a_file?
|
37
|
-
File.exist? self
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "a cmdline program", :shared => true do
|
42
|
-
before(:all) do
|
43
|
-
testdir = File.dirname(__FILE__)
|
44
|
-
libdir = testdir + '/../lib'
|
45
|
-
bindir = testdir + '/../bin'
|
46
|
-
progname = "fasta_shaker.rb"
|
47
|
-
@cmd = "ruby -I #{libdir} #{bindir}/#{@progname} "
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'gives usage when called with no args' do
|
51
|
-
reply = `#{@cmd}`
|
52
|
-
reply.should =~ /usage/i
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
|