libisi 0.3.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/LICENSE +677 -0
- data/Manifest +89 -0
- data/Rakefile +34 -0
- data/lib/inifile.rb +119 -0
- data/lib/libisi.rb +948 -0
- data/lib/libisi/attribute.rb +32 -0
- data/lib/libisi/attribute/activerecord.rb +34 -0
- data/lib/libisi/attribute/base.rb +33 -0
- data/lib/libisi/base.rb +109 -0
- data/lib/libisi/bridge.rb +21 -0
- data/lib/libisi/bridge/base.rb +23 -0
- data/lib/libisi/bridge/java.rb +71 -0
- data/lib/libisi/bridge/python.rb +37 -0
- data/lib/libisi/cache.rb +21 -0
- data/lib/libisi/cache/base.rb +67 -0
- data/lib/libisi/cache/file_cache.rb +24 -0
- data/lib/libisi/chart.rb +21 -0
- data/lib/libisi/chart/base.rb +320 -0
- data/lib/libisi/chart/jfreechart.rb +682 -0
- data/lib/libisi/chart/jfreechart_generator.rb +206 -0
- data/lib/libisi/color.rb +21 -0
- data/lib/libisi/color/base.rb +66 -0
- data/lib/libisi/color/colortools.rb +92 -0
- data/lib/libisi/color/java.rb +44 -0
- data/lib/libisi/concept.rb +33 -0
- data/lib/libisi/concept/activerecord.rb +39 -0
- data/lib/libisi/concept/base.rb +58 -0
- data/lib/libisi/doc.rb +35 -0
- data/lib/libisi/doc/base.rb +414 -0
- data/lib/libisi/doc/html.rb +85 -0
- data/lib/libisi/doc/text.rb +98 -0
- data/lib/libisi/doc/wiki.rb +55 -0
- data/lib/libisi/environment.rb +21 -0
- data/lib/libisi/environment/base.rb +36 -0
- data/lib/libisi/environment/http.rb +105 -0
- data/lib/libisi/environment/rails.rb +27 -0
- data/lib/libisi/environment/root.rb +23 -0
- data/lib/libisi/fake_logger/logger.rb +61 -0
- data/lib/libisi/function/base.rb +30 -0
- data/lib/libisi/hal.rb +558 -0
- data/lib/libisi/instance.rb +27 -0
- data/lib/libisi/instance/activerecord.rb +21 -0
- data/lib/libisi/instance/base.rb +42 -0
- data/lib/libisi/log.rb +237 -0
- data/lib/libisi/mail/base.rb +32 -0
- data/lib/libisi/mail/tmail.rb +120 -0
- data/lib/libisi/parameter/base.rb +41 -0
- data/lib/libisi/property.rb +27 -0
- data/lib/libisi/property/base.rb +28 -0
- data/lib/libisi/reciever/base.rb +31 -0
- data/lib/libisi/reciever/socket.rb +31 -0
- data/lib/libisi/relation.rb +23 -0
- data/lib/libisi/request.rb +22 -0
- data/lib/libisi/request/base.rb +29 -0
- data/lib/libisi/request/http.rb +129 -0
- data/lib/libisi/response/base.rb +27 -0
- data/lib/libisi/task/base.rb +27 -0
- data/lib/libisi/task/http.rb +90 -0
- data/lib/libisi/tee.rb +296 -0
- data/lib/libisi/ui/base.rb +116 -0
- data/lib/libisi/ui/console.rb +238 -0
- data/lib/libisi/ui/kde.rb +94 -0
- data/lib/libisi/ui/nobody.rb +29 -0
- data/lib/libisi/ui/rails.rb +150 -0
- data/lib/libisi/ui/x11.rb +55 -0
- data/lib/libisi/uri.rb +42 -0
- data/lib/libisi/uri/activerecord.rb +152 -0
- data/lib/libisi/uri/base.rb +115 -0
- data/lib/libisi/uri/file.rb +43 -0
- data/lib/libisi/uri/ldap.rb +72 -0
- data/lib/libisi/uri/mysql.rb +98 -0
- data/lib/libisi/value.rb +31 -0
- data/lib/libisi/value/attribute_value.rb +19 -0
- data/lib/libisi/value/base.rb +55 -0
- data/lib/libisi/value/property_value.rb +19 -0
- data/lib/libisi/value/relation_value.rb +19 -0
- data/lib/ordered_hash.rb +228 -0
- data/libisi.gemspec +31 -0
- data/test/bridge_test.rb +77 -0
- data/test/cache_test.rb +65 -0
- data/test/chart_test.rb +179 -0
- data/test/color_test.rb +64 -0
- data/test/concept_test.rb +56 -0
- data/test/doc_test.rb +172 -0
- data/test/fixtures/test.db +0 -0
- data/test/ordered_hash_test.rb +39 -0
- data/test/profile_test.rb +36 -0
- data/test/request_test.rb +121 -0
- data/test/test +0 -0
- data/test/ui_test.rb +62 -0
- metadata +244 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Copyright (C) 2007-2010 Logintas AG Switzerland
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Libisi.
|
|
4
|
+
#
|
|
5
|
+
# Libisi is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# Libisi is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with Libisi. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
class RelationValue < BaseValue
|
|
19
|
+
end
|
data/lib/ordered_hash.rb
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# AUTHOR
|
|
2
|
+
# jan molic /mig/at/1984/dot/cz/
|
|
3
|
+
#
|
|
4
|
+
# DESCRIPTION
|
|
5
|
+
# Hash with preserved order and some array-like extensions
|
|
6
|
+
# Public domain.
|
|
7
|
+
#
|
|
8
|
+
# THANKS
|
|
9
|
+
# Andrew Johnson for his suggestions and fixes of Hash[],
|
|
10
|
+
# merge, to_a, inspect and shift
|
|
11
|
+
class OrderedHash < ::Hash
|
|
12
|
+
attr_accessor :order
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
def [] *args
|
|
16
|
+
hsh = OrderedHash.new
|
|
17
|
+
if Hash === args[0]
|
|
18
|
+
hsh.replace args[0]
|
|
19
|
+
elsif (args.size % 2) != 0
|
|
20
|
+
raise ArgumentError, "odd number of elements for Hash"
|
|
21
|
+
else
|
|
22
|
+
0.step(args.size - 1, 2) do |a|
|
|
23
|
+
b = a + 1
|
|
24
|
+
hsh[args[a]] = args[b]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
hsh
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
def initialize(*a, &b)
|
|
31
|
+
super
|
|
32
|
+
@order = []
|
|
33
|
+
end
|
|
34
|
+
def store_only a,b
|
|
35
|
+
store a,b
|
|
36
|
+
end
|
|
37
|
+
alias orig_store store
|
|
38
|
+
def store(a,b,key_lookup = true)
|
|
39
|
+
@order.push a if !key_lookup or !has_key?(a)
|
|
40
|
+
super a,b
|
|
41
|
+
end
|
|
42
|
+
alias []= store
|
|
43
|
+
def == hsh2
|
|
44
|
+
return false if @order != hsh2.order
|
|
45
|
+
super hsh2
|
|
46
|
+
end
|
|
47
|
+
def clear
|
|
48
|
+
@order = []
|
|
49
|
+
super
|
|
50
|
+
end
|
|
51
|
+
def delete key
|
|
52
|
+
@order.delete key
|
|
53
|
+
super
|
|
54
|
+
end
|
|
55
|
+
def each_key
|
|
56
|
+
@order.each { |k| yield k }
|
|
57
|
+
self
|
|
58
|
+
end
|
|
59
|
+
def each_value
|
|
60
|
+
@order.each { |k| yield self[k] }
|
|
61
|
+
self
|
|
62
|
+
end
|
|
63
|
+
def each
|
|
64
|
+
@order.each { |k| yield k,self[k] }
|
|
65
|
+
self
|
|
66
|
+
end
|
|
67
|
+
alias each_pair each
|
|
68
|
+
def delete_if
|
|
69
|
+
@order.clone.each { |k|
|
|
70
|
+
delete k if yield(k)
|
|
71
|
+
}
|
|
72
|
+
self
|
|
73
|
+
end
|
|
74
|
+
def values
|
|
75
|
+
ary = []
|
|
76
|
+
@order.each { |k| ary.push self[k] }
|
|
77
|
+
ary
|
|
78
|
+
end
|
|
79
|
+
def keys
|
|
80
|
+
@order
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def first
|
|
84
|
+
{@order.first => self[@order.first]}
|
|
85
|
+
end
|
|
86
|
+
def last
|
|
87
|
+
{@order.last => self[@order.last]}
|
|
88
|
+
end
|
|
89
|
+
def invert
|
|
90
|
+
hsh2 = Hash.new
|
|
91
|
+
@order.each { |k| hsh2[self[k]] = k }
|
|
92
|
+
hsh2
|
|
93
|
+
end
|
|
94
|
+
def reject &block
|
|
95
|
+
self.dup.delete_if &block
|
|
96
|
+
end
|
|
97
|
+
def reject! &block
|
|
98
|
+
hsh2 = reject &block
|
|
99
|
+
self == hsh2 ? nil : hsh2
|
|
100
|
+
end
|
|
101
|
+
def replace hsh2
|
|
102
|
+
@order = hsh2.keys
|
|
103
|
+
super hsh2
|
|
104
|
+
end
|
|
105
|
+
def shift
|
|
106
|
+
key = @order.first
|
|
107
|
+
key ? [key,delete(key)] : super
|
|
108
|
+
end
|
|
109
|
+
def unshift k,v
|
|
110
|
+
unless self.include? k
|
|
111
|
+
@order.unshift k
|
|
112
|
+
orig_store(k,v)
|
|
113
|
+
true
|
|
114
|
+
else
|
|
115
|
+
false
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
def push k,v
|
|
119
|
+
unless self.include? k
|
|
120
|
+
@order.push k
|
|
121
|
+
orig_store(k,v)
|
|
122
|
+
true
|
|
123
|
+
else
|
|
124
|
+
false
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
def pop
|
|
128
|
+
key = @order.last
|
|
129
|
+
key ? [key,delete(key)] : nil
|
|
130
|
+
end
|
|
131
|
+
def to_a
|
|
132
|
+
ary = []
|
|
133
|
+
each { |k,v| ary << [k,v] }
|
|
134
|
+
ary
|
|
135
|
+
end
|
|
136
|
+
def to_s
|
|
137
|
+
self.to_a.to_s
|
|
138
|
+
end
|
|
139
|
+
def inspect
|
|
140
|
+
ary = []
|
|
141
|
+
each {|k,v| ary << k.inspect + "=>" + v.inspect}
|
|
142
|
+
'{' + ary.join(", ") + '}'
|
|
143
|
+
end
|
|
144
|
+
def update hsh2
|
|
145
|
+
hsh2.each { |k,v| self[k] = v }
|
|
146
|
+
self
|
|
147
|
+
end
|
|
148
|
+
alias :merge! update
|
|
149
|
+
def merge hsh2
|
|
150
|
+
self.dup update(hsh2)
|
|
151
|
+
end
|
|
152
|
+
def select
|
|
153
|
+
ary = []
|
|
154
|
+
each { |k,v| ary << [k,v] if yield k,v }
|
|
155
|
+
ary
|
|
156
|
+
end
|
|
157
|
+
def class
|
|
158
|
+
Hash
|
|
159
|
+
end
|
|
160
|
+
def __class__
|
|
161
|
+
OrderedHash
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
attr_accessor "to_yaml_style"
|
|
165
|
+
def yaml_inline= bool
|
|
166
|
+
if respond_to?("to_yaml_style")
|
|
167
|
+
self.to_yaml_style = :inline
|
|
168
|
+
else
|
|
169
|
+
unless defined? @__yaml_inline_meth
|
|
170
|
+
@__yaml_inline_meth =
|
|
171
|
+
lambda {|opts|
|
|
172
|
+
YAML::quick_emit(object_id, opts) {|emitter|
|
|
173
|
+
emitter << '{ ' << map{|kv| kv.join ': '}.join(', ') << ' }'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
class << self
|
|
177
|
+
def to_yaml opts = {}
|
|
178
|
+
begin
|
|
179
|
+
@__yaml_inline ? @__yaml_inline_meth[ opts ] : super
|
|
180
|
+
rescue
|
|
181
|
+
@to_yaml_style = :inline
|
|
182
|
+
super
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
@__yaml_inline = bool
|
|
189
|
+
end
|
|
190
|
+
def yaml_inline!() self.yaml_inline = true end
|
|
191
|
+
|
|
192
|
+
def each_with_index
|
|
193
|
+
@order.each_with_index { |k, index| yield k, self[k], index }
|
|
194
|
+
self
|
|
195
|
+
end
|
|
196
|
+
end # class OrderedHash
|
|
197
|
+
|
|
198
|
+
def OrderedHash(*a, &b)
|
|
199
|
+
OrderedHash.new(*a, &b)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# array extension
|
|
203
|
+
class Array
|
|
204
|
+
|
|
205
|
+
def can_be_a_hash?
|
|
206
|
+
self.select {|e| e.class == Array and e.length == 2}.length == self.length
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def to_hash(depth = false)
|
|
210
|
+
# array must have the form [[key, value], [key, value]]
|
|
211
|
+
raise "Dont know how to convert array to hash (not all elements ar 2-dim arrays)" unless
|
|
212
|
+
can_be_a_hash?
|
|
213
|
+
|
|
214
|
+
new_hash = OrderedHash.new
|
|
215
|
+
order = []
|
|
216
|
+
self.each {|key,value|
|
|
217
|
+
order << key
|
|
218
|
+
if depth and value.class == Array and value.can_be_a_hash? then
|
|
219
|
+
new_hash.store(key, value.to_hash(true),false)
|
|
220
|
+
else
|
|
221
|
+
new_hash.store(key, value,false)
|
|
222
|
+
end
|
|
223
|
+
}
|
|
224
|
+
new_hash.order = order
|
|
225
|
+
new_hash
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
end
|
data/libisi.gemspec
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{libisi}
|
|
5
|
+
s.version = "0.3.0"
|
|
6
|
+
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["Pellanda Flavio, Copyright Logintas AG"]
|
|
9
|
+
s.date = %q{2010-10-27}
|
|
10
|
+
s.description = %q{Library for easy and fast shell script developing}
|
|
11
|
+
s.email = %q{flavio.pellanda@logintas.ch}
|
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "lib/inifile.rb", "lib/libisi.rb", "lib/libisi/attribute.rb", "lib/libisi/attribute/activerecord.rb", "lib/libisi/attribute/base.rb", "lib/libisi/base.rb", "lib/libisi/bridge.rb", "lib/libisi/bridge/base.rb", "lib/libisi/bridge/java.rb", "lib/libisi/bridge/python.rb", "lib/libisi/cache.rb", "lib/libisi/cache/base.rb", "lib/libisi/cache/file_cache.rb", "lib/libisi/chart.rb", "lib/libisi/chart/base.rb", "lib/libisi/chart/jfreechart.rb", "lib/libisi/chart/jfreechart_generator.rb", "lib/libisi/color.rb", "lib/libisi/color/base.rb", "lib/libisi/color/colortools.rb", "lib/libisi/color/java.rb", "lib/libisi/concept.rb", "lib/libisi/concept/activerecord.rb", "lib/libisi/concept/base.rb", "lib/libisi/doc.rb", "lib/libisi/doc/base.rb", "lib/libisi/doc/html.rb", "lib/libisi/doc/text.rb", "lib/libisi/doc/wiki.rb", "lib/libisi/environment.rb", "lib/libisi/environment/base.rb", "lib/libisi/environment/http.rb", "lib/libisi/environment/rails.rb", "lib/libisi/environment/root.rb", "lib/libisi/fake_logger/logger.rb", "lib/libisi/function/base.rb", "lib/libisi/hal.rb", "lib/libisi/instance.rb", "lib/libisi/instance/activerecord.rb", "lib/libisi/instance/base.rb", "lib/libisi/log.rb", "lib/libisi/mail/base.rb", "lib/libisi/mail/tmail.rb", "lib/libisi/parameter/base.rb", "lib/libisi/property.rb", "lib/libisi/property/base.rb", "lib/libisi/reciever/base.rb", "lib/libisi/reciever/socket.rb", "lib/libisi/relation.rb", "lib/libisi/request.rb", "lib/libisi/request/base.rb", "lib/libisi/request/http.rb", "lib/libisi/response/base.rb", "lib/libisi/task/base.rb", "lib/libisi/task/http.rb", "lib/libisi/tee.rb", "lib/libisi/ui/base.rb", "lib/libisi/ui/console.rb", "lib/libisi/ui/kde.rb", "lib/libisi/ui/nobody.rb", "lib/libisi/ui/rails.rb", "lib/libisi/ui/x11.rb", "lib/libisi/uri.rb", "lib/libisi/uri/activerecord.rb", "lib/libisi/uri/base.rb", "lib/libisi/uri/file.rb", "lib/libisi/uri/ldap.rb", "lib/libisi/uri/mysql.rb", "lib/libisi/value.rb", "lib/libisi/value/attribute_value.rb", "lib/libisi/value/base.rb", "lib/libisi/value/property_value.rb", "lib/libisi/value/relation_value.rb", "lib/ordered_hash.rb", "libisi.gemspec"]
|
|
13
|
+
s.files = ["LICENSE", "Rakefile", "lib/inifile.rb", "lib/libisi.rb", "lib/libisi/attribute.rb", "lib/libisi/attribute/activerecord.rb", "lib/libisi/attribute/base.rb", "lib/libisi/base.rb", "lib/libisi/bridge.rb", "lib/libisi/bridge/base.rb", "lib/libisi/bridge/java.rb", "lib/libisi/bridge/python.rb", "lib/libisi/cache.rb", "lib/libisi/cache/base.rb", "lib/libisi/cache/file_cache.rb", "lib/libisi/chart.rb", "lib/libisi/chart/base.rb", "lib/libisi/chart/jfreechart.rb", "lib/libisi/chart/jfreechart_generator.rb", "lib/libisi/color.rb", "lib/libisi/color/base.rb", "lib/libisi/color/colortools.rb", "lib/libisi/color/java.rb", "lib/libisi/concept.rb", "lib/libisi/concept/activerecord.rb", "lib/libisi/concept/base.rb", "lib/libisi/doc.rb", "lib/libisi/doc/base.rb", "lib/libisi/doc/html.rb", "lib/libisi/doc/text.rb", "lib/libisi/doc/wiki.rb", "lib/libisi/environment.rb", "lib/libisi/environment/base.rb", "lib/libisi/environment/http.rb", "lib/libisi/environment/rails.rb", "lib/libisi/environment/root.rb", "lib/libisi/fake_logger/logger.rb", "lib/libisi/function/base.rb", "lib/libisi/hal.rb", "lib/libisi/instance.rb", "lib/libisi/instance/activerecord.rb", "lib/libisi/instance/base.rb", "lib/libisi/log.rb", "lib/libisi/mail/base.rb", "lib/libisi/mail/tmail.rb", "lib/libisi/parameter/base.rb", "lib/libisi/property.rb", "lib/libisi/property/base.rb", "lib/libisi/reciever/base.rb", "lib/libisi/reciever/socket.rb", "lib/libisi/relation.rb", "lib/libisi/request.rb", "lib/libisi/request/base.rb", "lib/libisi/request/http.rb", "lib/libisi/response/base.rb", "lib/libisi/task/base.rb", "lib/libisi/task/http.rb", "lib/libisi/tee.rb", "lib/libisi/ui/base.rb", "lib/libisi/ui/console.rb", "lib/libisi/ui/kde.rb", "lib/libisi/ui/nobody.rb", "lib/libisi/ui/rails.rb", "lib/libisi/ui/x11.rb", "lib/libisi/uri.rb", "lib/libisi/uri/activerecord.rb", "lib/libisi/uri/base.rb", "lib/libisi/uri/file.rb", "lib/libisi/uri/ldap.rb", "lib/libisi/uri/mysql.rb", "lib/libisi/value.rb", "lib/libisi/value/attribute_value.rb", "lib/libisi/value/base.rb", "lib/libisi/value/property_value.rb", "lib/libisi/value/relation_value.rb", "lib/ordered_hash.rb", "test/bridge_test.rb", "test/cache_test.rb", "test/chart_test.rb", "test/color_test.rb", "test/concept_test.rb", "test/doc_test.rb", "test/fixtures/test.db", "test/ordered_hash_test.rb", "test/profile_test.rb", "test/request_test.rb", "test/test", "test/ui_test.rb", "Manifest", "libisi.gemspec"]
|
|
14
|
+
s.homepage = %q{http://rubyforge.org/projects/libisi/}
|
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Libisi"]
|
|
16
|
+
s.require_paths = ["lib"]
|
|
17
|
+
s.rubyforge_project = %q{libisi}
|
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
|
19
|
+
s.summary = %q{Library for easy and fast shell script developing}
|
|
20
|
+
s.test_files = ["test/color_test.rb", "test/cache_test.rb", "test/ordered_hash_test.rb", "test/bridge_test.rb", "test/concept_test.rb", "test/doc_test.rb", "test/profile_test.rb", "test/ui_test.rb", "test/request_test.rb", "test/chart_test.rb"]
|
|
21
|
+
|
|
22
|
+
if s.respond_to? :specification_version then
|
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
24
|
+
s.specification_version = 3
|
|
25
|
+
|
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
27
|
+
else
|
|
28
|
+
end
|
|
29
|
+
else
|
|
30
|
+
end
|
|
31
|
+
end
|
data/test/bridge_test.rb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Copyright (C) 2007-2010 Logintas AG Switzerland
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Libisi.
|
|
4
|
+
#
|
|
5
|
+
# Libisi is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# Libisi is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with Libisi. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
$LOAD_PATH.insert(0,File.dirname(__FILE__) + "/../lib/")
|
|
19
|
+
require 'test/unit'
|
|
20
|
+
require "libisi"
|
|
21
|
+
|
|
22
|
+
init_libisi
|
|
23
|
+
require "libisi/bridge"
|
|
24
|
+
|
|
25
|
+
class BridgeTest < Test::Unit::TestCase
|
|
26
|
+
class Req
|
|
27
|
+
def cfg; end
|
|
28
|
+
def str; end
|
|
29
|
+
end
|
|
30
|
+
def test_moin
|
|
31
|
+
Bridge.load("python")
|
|
32
|
+
kapozh_theme = PythonBridge.import "MoinMoin.theme.kapozh"
|
|
33
|
+
|
|
34
|
+
request_module = PythonBridge.import "MoinMoin.request"
|
|
35
|
+
request = request_module.RequestCLI
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
p(k = kapozh_theme.Theme(request))
|
|
40
|
+
p k.header(k,{:request => "K"})
|
|
41
|
+
return
|
|
42
|
+
user_module = PythonBridge.import "MoinMoin.user"
|
|
43
|
+
|
|
44
|
+
request = request_module.RequestBase()
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
# request.setup_args()
|
|
48
|
+
# request.args = request.setup_args()
|
|
49
|
+
# request.user = user_module.User(request)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
# r.normalizePagename("lkj")
|
|
53
|
+
# p request.Clock.value
|
|
54
|
+
# p request.RequestBase("")
|
|
55
|
+
|
|
56
|
+
kapozh_theme.execute(Req.new)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_java_bridge
|
|
60
|
+
Bridge.load("java")
|
|
61
|
+
df = JavaBridge.import("java.text.DateFormat")
|
|
62
|
+
|
|
63
|
+
format = df.getDateTimeInstance(df.MEDIUM, df.SHORT);
|
|
64
|
+
|
|
65
|
+
assert_equal "Tue Nov 04 20:14:00 CET 2003", format.parse("Nov 4, 2003 8:14 PM").toString
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_python_bridge
|
|
70
|
+
Bridge.load("python")
|
|
71
|
+
|
|
72
|
+
cPickle=RubyPython.import "cPickle"
|
|
73
|
+
assert_equal "S'RubyPython is awesome!'\n.", cPickle.dumps("RubyPython is awesome!")
|
|
74
|
+
assert_equal "(dp1\nS'a'\nS'b'\ns.", cPickle.dumps({"a" => "b"})
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
data/test/cache_test.rb
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Copyright (C) 2007-2010 Logintas AG Switzerland
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Libisi.
|
|
4
|
+
#
|
|
5
|
+
# Libisi is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# Libisi is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with Libisi. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
$LOAD_PATH.insert(0,File.dirname(__FILE__) + "/../lib/")
|
|
19
|
+
require 'test/unit'
|
|
20
|
+
require "libisi"
|
|
21
|
+
init_libisi
|
|
22
|
+
require "libisi/cache"
|
|
23
|
+
|
|
24
|
+
class CacheTest < Test::Unit::TestCase
|
|
25
|
+
|
|
26
|
+
def test_base_cache
|
|
27
|
+
cache = Cache.create(:base)
|
|
28
|
+
assert_equal 1000, cache.maxcount
|
|
29
|
+
|
|
30
|
+
block_visited = false
|
|
31
|
+
val = cache.fetch("key") {|key|
|
|
32
|
+
assert_equal "key", key
|
|
33
|
+
block_visited = true
|
|
34
|
+
"value"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
assert block_visited, "Block not called"
|
|
38
|
+
assert_equal "value", val
|
|
39
|
+
|
|
40
|
+
block_visited = false
|
|
41
|
+
|
|
42
|
+
val = cache.fetch("key") {|key|
|
|
43
|
+
assert false, "Block called but should be cached"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
assert_equal "value", val
|
|
47
|
+
assert cache.has_key?("key"), "Value is not stored in cache"
|
|
48
|
+
|
|
49
|
+
1000.times {|i| cache.set(i,i) }
|
|
50
|
+
# now our value should be disappeared
|
|
51
|
+
assert !cache.has_key?(val)
|
|
52
|
+
|
|
53
|
+
block_visited = false
|
|
54
|
+
val = cache.fetch("key") {|key|
|
|
55
|
+
assert_equal "key", key
|
|
56
|
+
block_visited = true
|
|
57
|
+
"value"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
assert block_visited, "Block not called"
|
|
61
|
+
assert_equal "value", val
|
|
62
|
+
assert !cache.has_key?(0)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
data/test/chart_test.rb
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Copyright (C) 2007-2010 Logintas AG Switzerland
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Libisi.
|
|
4
|
+
#
|
|
5
|
+
# Libisi is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# Libisi is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU General Public License
|
|
16
|
+
# along with Libisi. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
$LOAD_PATH.insert(0,File.dirname(__FILE__) + "/../lib/")
|
|
19
|
+
require 'test/unit'
|
|
20
|
+
require "libisi"
|
|
21
|
+
init_libisi
|
|
22
|
+
require "libisi/chart"
|
|
23
|
+
|
|
24
|
+
class ChartTest < Test::Unit::TestCase
|
|
25
|
+
TEMP_DIR = Pathname.new("/tmp/chart_test/")
|
|
26
|
+
|
|
27
|
+
def save_chart(chart, name)
|
|
28
|
+
TEMP_DIR.mkdir unless TEMP_DIR.exist?
|
|
29
|
+
chart.save(TEMP_DIR + "#{name}.png")
|
|
30
|
+
chart.save(TEMP_DIR + "#{name}.html", :image_file => TEMP_DIR + "#{name}_html.png")
|
|
31
|
+
chart.save(TEMP_DIR + "#{name}_inline.html")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_bar_chart
|
|
35
|
+
chart = Chart.create("jfreechart")
|
|
36
|
+
chart.type = :bar
|
|
37
|
+
|
|
38
|
+
chart.range("Range 1") {
|
|
39
|
+
chart.serie("Serie 1") {
|
|
40
|
+
chart.value("Value 1", 1)
|
|
41
|
+
chart.value("Value 2", 3)
|
|
42
|
+
chart.value("Value 3", 2)
|
|
43
|
+
chart.value("Value 4", 2)
|
|
44
|
+
}
|
|
45
|
+
chart.serie("Serie 2") {
|
|
46
|
+
chart.value("Value 1", 6)
|
|
47
|
+
chart.value("Value 2", 7)
|
|
48
|
+
chart.value("Value 3", 8)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
chart.range("Range 2") {
|
|
52
|
+
chart.serie("Serie 1") {
|
|
53
|
+
chart.value("Value 1", 7)
|
|
54
|
+
chart.value("Value 2", 4)
|
|
55
|
+
chart.value("Value 3", 1)
|
|
56
|
+
chart.value("Value 4", 1)
|
|
57
|
+
}
|
|
58
|
+
chart.serie("Serie 2") {
|
|
59
|
+
chart.value("Value 1", 1)
|
|
60
|
+
chart.value("Value 2", 7)
|
|
61
|
+
chart.value("Value 3", 2)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
chart.create_chart(nil, :combined_axis => :domain)
|
|
66
|
+
save_chart(chart,"bar1")
|
|
67
|
+
chart.create_chart(nil, :combined_axis => :range)
|
|
68
|
+
save_chart(chart,"bar2")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_line_chart
|
|
72
|
+
chart = Chart.create("jfreechart")
|
|
73
|
+
chart.type = :line
|
|
74
|
+
|
|
75
|
+
chart.serie("Serie 1") {
|
|
76
|
+
chart.value("1", 1)
|
|
77
|
+
chart.value("2", 3)
|
|
78
|
+
chart.value("3", 2)
|
|
79
|
+
chart.value("4", 2)
|
|
80
|
+
}
|
|
81
|
+
chart.serie("Serie 2") {
|
|
82
|
+
chart.value("1", 6)
|
|
83
|
+
chart.value("2", 7)
|
|
84
|
+
chart.value("3", 8)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
save_chart(chart,"line")
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_pie_chart
|
|
91
|
+
chart = Chart.create("jfreechart")
|
|
92
|
+
chart.type = :pie
|
|
93
|
+
|
|
94
|
+
chart.serie("Serie 1") {
|
|
95
|
+
chart.value("Value 1", 1)
|
|
96
|
+
chart.value("Value 2", 3)
|
|
97
|
+
chart.value("Value 3", 2)
|
|
98
|
+
chart.value("Value 4", 2)
|
|
99
|
+
}
|
|
100
|
+
chart.serie("Serie 2") {
|
|
101
|
+
chart.value("Value 1", 6)
|
|
102
|
+
chart.value("Value 2", 7)
|
|
103
|
+
chart.value("Value 3", 8)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
chart.create_chart(nil, :combined_axis => :domain)
|
|
107
|
+
save_chart(chart,"pie_domain")
|
|
108
|
+
chart.create_chart(nil, :combined_axis => :range)
|
|
109
|
+
save_chart(chart,"pie_range")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def test_gantt_chart
|
|
113
|
+
chart = Chart.create("jfreechart")
|
|
114
|
+
working_col = Color.create("colortools", "#f12f3f")
|
|
115
|
+
|
|
116
|
+
chart.mark("Burn","2009-08-01","2009-08-04", :color => :red, :layer => :foreground)
|
|
117
|
+
|
|
118
|
+
chart.range("Superproject 1", :color => working_col.html) {
|
|
119
|
+
working_col.brightness("20%")
|
|
120
|
+
chart.mark("Summer","2009-07-01","2009-09-31", :color => working_col.html)
|
|
121
|
+
|
|
122
|
+
chart.serie("Project 1") {
|
|
123
|
+
chart.mark("Birthday","2009-08-25", :color => :green)
|
|
124
|
+
chart.time_span("Task1","2009-01-01","2009-01-31")
|
|
125
|
+
chart.time_span("Task2","2009-01-01","2009-02-27", :percentage => 0.9)
|
|
126
|
+
chart.time_span("LongTask3","2009-01-15","2009-06-26")
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
chart.serie("Project 2") {
|
|
130
|
+
chart.time_span("Task1","2009-05-01","2009-09-30")
|
|
131
|
+
chart.time_span("Task2","2009-08-01","2009-09-30", :percentage => 0.4) {
|
|
132
|
+
chart.time_span("Sub Task2.1","2009-08-07","2009-09-30", :percentage => 0.4)
|
|
133
|
+
}
|
|
134
|
+
chart.time_span("Task4","2009-07-15","2009-12-26", :percentage => 0.7) {
|
|
135
|
+
chart.time_span("Sub Task4.1","2009-07-15","2009-11-26", :percentage => 1.0)
|
|
136
|
+
chart.time_span("Sub Task4.2","2009-12-01","2009-12-20", :percentage => 0.3)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
chart.range("Superproject 2", :color => "yellow") {
|
|
142
|
+
working_col.hue("-20%")
|
|
143
|
+
chart.mark("Summer","2009-07-01","2009-09-31", :color => working_col.html)
|
|
144
|
+
chart.mark("Now",DateTime.now)
|
|
145
|
+
|
|
146
|
+
chart.serie("Project 1") {
|
|
147
|
+
chart.time_span("Task1","2009-04-01","2009-04-30")
|
|
148
|
+
chart.time_span("Task2","2009-04-01","2009-05-31", :percentage => 0.9)
|
|
149
|
+
chart.time_span("Task3","2009-04-15","2009-09-26")
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
chart.serie("Project 2") {
|
|
153
|
+
chart.mark(:color => "blue") {
|
|
154
|
+
chart.time_span("Task1","2009-05-01","2009-10-31")
|
|
155
|
+
chart.time_span("Task2","2009-08-01","2009-11-30", :percentage => 0.4) {
|
|
156
|
+
chart.time_span("Sub Task2.1","2009-08-07","2009-10-12", :percentage => 0.4)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
chart.time_span("Task4","2009-07-15","2009-12-26", :percentage => 0.7) {
|
|
160
|
+
chart.time_span("Sub Task4.1","2009-07-15","2009-11-26", :percentage => 1.0)
|
|
161
|
+
chart.time_span("Sub Task4.2","2009-12-01","2009-12-20", :percentage => 0.3)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
chart.range("Superproject 3", :color => "yellow") {
|
|
166
|
+
working_col.brightness("20%")
|
|
167
|
+
chart.mark("Summer","2009-07-01","2009-09-31", :color => working_col.html)
|
|
168
|
+
chart.serie("Project 1") {
|
|
169
|
+
chart.time_span("Task3","2009-04-15","2009-09-26")
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
chart.create_chart(nil, :combined_axis => :range)
|
|
174
|
+
save_chart(chart,"gantt1_range")
|
|
175
|
+
chart.create_chart(nil, :combined_axis => :domain)
|
|
176
|
+
save_chart(chart,"gantt1_domain")
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
end
|