sparklines 0.2.5 → 0.2.6
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/CHANGELOG +0 -0
- data/MIT-LICENSE +21 -0
- data/{README.txt → README} +0 -0
- data/lib/sparklines.rb +9 -7
- data/rakefile +196 -0
- data/test/{test.rb → all_test.rb} +0 -1
- metadata +28 -52
- data/samples/area-high.png +0 -0
- data/samples/area.png +0 -0
- data/samples/discrete.png +0 -0
- data/samples/pie-large.png +0 -0
- data/samples/pie.png +0 -0
- data/samples/pie0.png +0 -0
- data/samples/pie1.png +0 -0
- data/samples/pie100.png +0 -0
- data/samples/pie45.png +0 -0
- data/samples/pie95.png +0 -0
- data/samples/pie99.png +0 -0
- data/samples/smooth-colored.png +0 -0
- data/samples/smooth.png +0 -0
- data/test/output/area-high.png +0 -0
- data/test/output/area.png +0 -0
- data/test/output/bar-extreme-values.png +0 -0
- data/test/output/bar-string.png +0 -0
- data/test/output/bar-tall.png +0 -0
- data/test/output/bar-wide.png +0 -0
- data/test/output/bar.png +0 -0
- data/test/output/discrete-wide.png +0 -0
- data/test/output/discrete.png +0 -0
- data/test/output/pie-large.png +0 -0
- data/test/output/pie.png +0 -0
- data/test/output/pie0.png +0 -0
- data/test/output/pie1.png +0 -0
- data/test/output/pie100.png +0 -0
- data/test/output/pie45.png +0 -0
- data/test/output/pie95.png +0 -0
- data/test/output/pie99.png +0 -0
- data/test/output/smooth-colored.png +0 -0
- data/test/output/smooth.png +0 -0
data/CHANGELOG
ADDED
File without changes
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright (c) 2005 Geoffrey Grosenbach boss@topfunky.com
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
data/{README.txt → README}
RENAMED
File without changes
|
data/lib/sparklines.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
require 'RMagick'
|
2
3
|
require 'mathn'
|
3
4
|
|
@@ -91,7 +92,7 @@ Licensed under the MIT license.
|
|
91
92
|
=end
|
92
93
|
|
93
94
|
module Sparklines
|
94
|
-
|
95
|
+
VERSION = '0.2.6'
|
95
96
|
|
96
97
|
# Does the actually plotting of the graph. Calls the appropriate function based on the :type value passed. Defaults to 'smooth.'
|
97
98
|
def Sparklines.plot(results=[], options={})
|
@@ -115,19 +116,20 @@ module Sparklines
|
|
115
116
|
:has_max => false,
|
116
117
|
:has_last => false
|
117
118
|
}
|
118
|
-
|
119
|
-
|
120
|
-
|
119
|
+
|
120
|
+
# Have to do this to get around HashWithIndifferentAccess
|
121
|
+
options_sym = Hash.new
|
121
122
|
options.keys.reverse.each do |key|
|
122
|
-
|
123
|
+
options_sym[key.to_sym] = options[key]
|
123
124
|
end
|
124
|
-
|
125
|
+
|
126
|
+
options_sym = defaults.merge(options_sym)
|
125
127
|
|
126
128
|
# Minimal normalization
|
127
129
|
maximum_value = self.get_max_value(results).to_f
|
128
130
|
|
129
131
|
# Call the appropriate function for actual plotting
|
130
|
-
self.send(
|
132
|
+
self.send(options_sym[:type], results, options_sym, maximum_value)
|
131
133
|
end
|
132
134
|
|
133
135
|
# Writes a graph to disk with the specified filename, or "Sparklines.png"
|
data/rakefile
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/contrib/rubyforgepublisher'
|
8
|
+
|
9
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
10
|
+
require 'sparklines'
|
11
|
+
|
12
|
+
PKG_NAME = 'sparklines'
|
13
|
+
PKG_VERSION = Sparklines::VERSION
|
14
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
15
|
+
|
16
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
17
|
+
|
18
|
+
RUBY_FORGE_PROJECT = "sparklines"
|
19
|
+
RUBY_FORGE_USER = "topfunky"
|
20
|
+
|
21
|
+
desc "Default Task"
|
22
|
+
task :default => [ :clean, :test ]
|
23
|
+
|
24
|
+
desc "Clean images generated by tests"
|
25
|
+
task :clean do
|
26
|
+
rm FileList['test/output/*.png']
|
27
|
+
end
|
28
|
+
|
29
|
+
# Run the unit tests
|
30
|
+
Rake::TestTask.new { |t|
|
31
|
+
t.libs << "test"
|
32
|
+
t.pattern = 'test/*_test.rb'
|
33
|
+
t.verbose = true
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
# Genereate the RDoc documentation
|
38
|
+
Rake::RDocTask.new { |rdoc|
|
39
|
+
rdoc.rdoc_dir = 'doc'
|
40
|
+
rdoc.title = "Sparklines -- Tiny graphs"
|
41
|
+
rdoc.options << '--line-numbers --inline-source --main README --accessor adv_attr_accessor=M'
|
42
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
43
|
+
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
44
|
+
rdoc.rdoc_files.include('lib/sparklines.rb')
|
45
|
+
rdoc.rdoc_files.include('lib/sparklines/*.rb')
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
# Create compressed packages
|
50
|
+
spec = Gem::Specification.new do |s|
|
51
|
+
s.platform = Gem::Platform::RUBY
|
52
|
+
s.name = PKG_NAME
|
53
|
+
s.summary = "Tiny graphs for concise data."
|
54
|
+
s.description = %q{Make tiny graphs for use on websites or documents.}
|
55
|
+
s.version = PKG_VERSION
|
56
|
+
|
57
|
+
s.author = "Geoffrey Grosenbach"
|
58
|
+
s.email = "boss@topfunky.com"
|
59
|
+
s.rubyforge_project = RUBY_FORGE_PROJECT
|
60
|
+
s.homepage = "http://www.topfunky.com"
|
61
|
+
|
62
|
+
s.has_rdoc = true
|
63
|
+
s.requirements << 'none'
|
64
|
+
s.require_path = 'lib'
|
65
|
+
s.autorequire = 'gruff'
|
66
|
+
|
67
|
+
s.files = [ "rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
|
68
|
+
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
69
|
+
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) || item.include?("\.png") }
|
70
|
+
end
|
71
|
+
|
72
|
+
Rake::GemPackageTask.new(spec) do |p|
|
73
|
+
p.gem_spec = spec
|
74
|
+
p.need_tar = true
|
75
|
+
p.need_zip = true
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Publish the API documentation"
|
79
|
+
task :pgem => [:package] do
|
80
|
+
Rake::SshFilePublisher.new("boss@topfunky.com", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Publish the release files to RubyForge."
|
84
|
+
task :release => [:package] do
|
85
|
+
files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
86
|
+
|
87
|
+
if RUBY_FORGE_PROJECT then
|
88
|
+
require 'net/http'
|
89
|
+
require 'open-uri'
|
90
|
+
|
91
|
+
project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
|
92
|
+
project_data = open(project_uri) { |data| data.read }
|
93
|
+
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
94
|
+
raise "Couldn't get group id" unless group_id
|
95
|
+
|
96
|
+
# This echos password to shell which is a bit sucky
|
97
|
+
if ENV["RUBY_FORGE_PASSWORD"]
|
98
|
+
password = ENV["RUBY_FORGE_PASSWORD"]
|
99
|
+
else
|
100
|
+
print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
|
101
|
+
password = STDIN.gets.chomp
|
102
|
+
end
|
103
|
+
|
104
|
+
login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
105
|
+
data = [
|
106
|
+
"login=1",
|
107
|
+
"form_loginname=#{RUBY_FORGE_USER}",
|
108
|
+
"form_pw=#{password}"
|
109
|
+
].join("&")
|
110
|
+
http.post("/account/login.php", data)
|
111
|
+
end
|
112
|
+
|
113
|
+
cookie = login_response["set-cookie"]
|
114
|
+
raise "Login failed" unless cookie
|
115
|
+
headers = { "Cookie" => cookie }
|
116
|
+
|
117
|
+
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
118
|
+
release_data = open(release_uri, headers) { |data| data.read }
|
119
|
+
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
120
|
+
raise "Couldn't get package id" unless package_id
|
121
|
+
|
122
|
+
first_file = true
|
123
|
+
release_id = ""
|
124
|
+
|
125
|
+
files.each do |filename|
|
126
|
+
basename = File.basename(filename)
|
127
|
+
file_ext = File.extname(filename)
|
128
|
+
file_data = File.open(filename, "rb") { |file| file.read }
|
129
|
+
|
130
|
+
puts "Releasing #{basename}..."
|
131
|
+
|
132
|
+
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
133
|
+
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
134
|
+
type_map = {
|
135
|
+
".zip" => "3000",
|
136
|
+
".tgz" => "3110",
|
137
|
+
".gz" => "3110",
|
138
|
+
".gem" => "1400"
|
139
|
+
}; type_map.default = "9999"
|
140
|
+
type = type_map[file_ext]
|
141
|
+
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
142
|
+
|
143
|
+
query_hash = if first_file then
|
144
|
+
{
|
145
|
+
"group_id" => group_id,
|
146
|
+
"package_id" => package_id,
|
147
|
+
"release_name" => RELEASE_NAME,
|
148
|
+
"release_date" => release_date,
|
149
|
+
"type_id" => type,
|
150
|
+
"processor_id" => "8000", # Any
|
151
|
+
"release_notes" => "",
|
152
|
+
"release_changes" => "",
|
153
|
+
"preformatted" => "1",
|
154
|
+
"submit" => "1"
|
155
|
+
}
|
156
|
+
else
|
157
|
+
{
|
158
|
+
"group_id" => group_id,
|
159
|
+
"release_id" => release_id,
|
160
|
+
"package_id" => package_id,
|
161
|
+
"step2" => "1",
|
162
|
+
"type_id" => type,
|
163
|
+
"processor_id" => "8000", # Any
|
164
|
+
"submit" => "Add This File"
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
query = "?" + query_hash.map do |(name, value)|
|
169
|
+
[name, URI.encode(value)].join("=")
|
170
|
+
end.join("&")
|
171
|
+
|
172
|
+
data = [
|
173
|
+
"--" + boundary,
|
174
|
+
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
175
|
+
"Content-Type: application/octet-stream",
|
176
|
+
"Content-Transfer-Encoding: binary",
|
177
|
+
"", file_data, ""
|
178
|
+
].join("\x0D\x0A")
|
179
|
+
|
180
|
+
release_headers = headers.merge(
|
181
|
+
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
182
|
+
)
|
183
|
+
|
184
|
+
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
185
|
+
http.post(target + query, data, release_headers)
|
186
|
+
end
|
187
|
+
|
188
|
+
if first_file then
|
189
|
+
release_id = release_response.body[/release_id=(\d+)/, 1]
|
190
|
+
raise("Couldn't get release id") unless release_id
|
191
|
+
end
|
192
|
+
|
193
|
+
first_file = false
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
metadata
CHANGED
@@ -3,73 +3,49 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: sparklines
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date:
|
8
|
-
summary:
|
6
|
+
version: 0.2.6
|
7
|
+
date: 2006-01-04 00:00:00 -08:00
|
8
|
+
summary: Tiny graphs for concise data.
|
9
9
|
require_paths:
|
10
|
-
|
10
|
+
- lib
|
11
11
|
email: boss@topfunky.com
|
12
|
-
homepage: http://
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire:
|
12
|
+
homepage: http://www.topfunky.com
|
13
|
+
rubyforge_project: sparklines
|
14
|
+
description: Make tiny graphs for use on websites or documents.
|
15
|
+
autorequire: gruff
|
16
16
|
default_executable:
|
17
17
|
bindir: bin
|
18
18
|
has_rdoc: true
|
19
19
|
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
20
|
requirements:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
version: 0.0.0
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
25
24
|
version:
|
26
25
|
platform: ruby
|
27
26
|
signing_key:
|
28
27
|
cert_chain:
|
29
28
|
authors:
|
30
|
-
|
31
|
-
- Dan Nugent
|
29
|
+
- Geoffrey Grosenbach
|
32
30
|
files:
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
- samples/pie1.png
|
41
|
-
- samples/pie100.png
|
42
|
-
- samples/pie45.png
|
43
|
-
- samples/pie95.png
|
44
|
-
- samples/pie99.png
|
45
|
-
- samples/smooth-colored.png
|
46
|
-
- samples/smooth.png
|
47
|
-
- test/output
|
48
|
-
- test/test.rb
|
49
|
-
- test/output/area-high.png
|
50
|
-
- test/output/area.png
|
51
|
-
- test/output/bar-extreme-values.png
|
52
|
-
- test/output/bar-string.png
|
53
|
-
- test/output/bar-tall.png
|
54
|
-
- test/output/bar-wide.png
|
55
|
-
- test/output/bar.png
|
56
|
-
- test/output/discrete-wide.png
|
57
|
-
- test/output/discrete.png
|
58
|
-
- test/output/pie-large.png
|
59
|
-
- test/output/pie.png
|
60
|
-
- test/output/pie0.png
|
61
|
-
- test/output/pie1.png
|
62
|
-
- test/output/pie100.png
|
63
|
-
- test/output/pie45.png
|
64
|
-
- test/output/pie95.png
|
65
|
-
- test/output/pie99.png
|
66
|
-
- test/output/smooth-colored.png
|
67
|
-
- test/output/smooth.png
|
68
|
-
- README.txt
|
31
|
+
- rakefile
|
32
|
+
- README
|
33
|
+
- CHANGELOG
|
34
|
+
- MIT-LICENSE
|
35
|
+
- lib/sparklines.rb
|
36
|
+
- test/all_test.rb
|
37
|
+
- test/output
|
69
38
|
test_files: []
|
39
|
+
|
70
40
|
rdoc_options: []
|
41
|
+
|
71
42
|
extra_rdoc_files: []
|
43
|
+
|
72
44
|
executables: []
|
45
|
+
|
73
46
|
extensions: []
|
74
|
-
|
75
|
-
|
47
|
+
|
48
|
+
requirements:
|
49
|
+
- none
|
50
|
+
dependencies: []
|
51
|
+
|
data/samples/area-high.png
DELETED
Binary file
|
data/samples/area.png
DELETED
Binary file
|
data/samples/discrete.png
DELETED
Binary file
|
data/samples/pie-large.png
DELETED
Binary file
|
data/samples/pie.png
DELETED
Binary file
|
data/samples/pie0.png
DELETED
Binary file
|
data/samples/pie1.png
DELETED
Binary file
|
data/samples/pie100.png
DELETED
Binary file
|
data/samples/pie45.png
DELETED
Binary file
|
data/samples/pie95.png
DELETED
Binary file
|
data/samples/pie99.png
DELETED
Binary file
|
data/samples/smooth-colored.png
DELETED
Binary file
|
data/samples/smooth.png
DELETED
Binary file
|
data/test/output/area-high.png
DELETED
Binary file
|
data/test/output/area.png
DELETED
Binary file
|
Binary file
|
data/test/output/bar-string.png
DELETED
Binary file
|
data/test/output/bar-tall.png
DELETED
Binary file
|
data/test/output/bar-wide.png
DELETED
Binary file
|
data/test/output/bar.png
DELETED
Binary file
|
Binary file
|
data/test/output/discrete.png
DELETED
Binary file
|
data/test/output/pie-large.png
DELETED
Binary file
|
data/test/output/pie.png
DELETED
Binary file
|
data/test/output/pie0.png
DELETED
Binary file
|
data/test/output/pie1.png
DELETED
Binary file
|
data/test/output/pie100.png
DELETED
Binary file
|
data/test/output/pie45.png
DELETED
Binary file
|
data/test/output/pie95.png
DELETED
Binary file
|
data/test/output/pie99.png
DELETED
Binary file
|
Binary file
|
data/test/output/smooth.png
DELETED
Binary file
|