rubyspark 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/rubyspark +21 -0
- data/lib/rubyspark/version.rb +3 -0
- data/lib/rubyspark.rb +29 -0
- data/rubyspark.gemspec +24 -0
- data/spec/rubyspark_spec.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ff04195c852abc0a56a942eb025ec5e57647d4a3
|
4
|
+
data.tar.gz: 16a89d705724d8e0a5fcbfc9f585ee573e8efac6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54306e02aad1da929005c7f26520fa5d23e087bbe1bb10fe20e37b8fcae173e85f85eca310fa81694c1ea07eb1dd902c3dfa50ca95eea98723403f504408999a
|
7
|
+
data.tar.gz: 36e9322191e79c837eeaeabbe66a8cf7b8d62196b05eb862addb57c44c68a9a0a8a69b0ef3a4f7d22867737bfe34e653c4f2b9643a823c014401768364986c07
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Anurag Mohanty
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Rubyspark
|
2
|
+
|
3
|
+
A ruby port of [Spark](http://zachholman.com/spark/)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rubyspark'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rubyspark
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
rubyspark 1 5 22 13 53
|
22
|
+
=> ▁▁▃▂▇
|
23
|
+
|
24
|
+
|
25
|
+
## Why not [Sparklines](https://github.com/topfunky/sparklines)?
|
26
|
+
|
27
|
+
Because this is an excercise in writing Ruby...
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/tevren/rubyspark/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/rubyspark
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'optparse'
|
4
|
+
require File.dirname(__FILE__) + '/../lib/rubyspark'
|
5
|
+
|
6
|
+
options_parser = OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{File.basename($0)} 1 5 22 13 53 \n => ▁▁▃▂▇"
|
8
|
+
|
9
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
10
|
+
puts opts
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
options_parser.parse!
|
15
|
+
|
16
|
+
if ARGV.length == 0
|
17
|
+
STDERR.puts options_parser
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
Rubyspark::Spark.new(ARGV)
|
data/lib/rubyspark.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "rubyspark/version"
|
2
|
+
module Rubyspark
|
3
|
+
class Spark
|
4
|
+
|
5
|
+
def initialize(data=[])
|
6
|
+
@data = []
|
7
|
+
data.cycle(1) {|x| @data.push(x.to_i)}
|
8
|
+
graphit
|
9
|
+
end
|
10
|
+
|
11
|
+
def graphit
|
12
|
+
ticks=%w[▁ ▂ ▃ ▄ ▅ ▆ ▇]
|
13
|
+
|
14
|
+
distance = @data.compact.max.to_f / ticks.size
|
15
|
+
|
16
|
+
graph = ''
|
17
|
+
@data.each do |x|
|
18
|
+
tick = (x/distance).round - 1
|
19
|
+
if tick <= 0
|
20
|
+
graph << ticks[0]
|
21
|
+
else
|
22
|
+
graph << ticks[tick]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
puts graph
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/rubyspark.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rubyspark/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rubyspark"
|
8
|
+
spec.version = Rubyspark::VERSION
|
9
|
+
spec.authors = ["Anurag Mohanty"]
|
10
|
+
spec.email = ["tevren@gmail.com"]
|
11
|
+
spec.summary = %q{A ruby port of spark}
|
12
|
+
spec.description = %q{A ruby port of (spark)[https://github.com/holman/spark]}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyspark
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anurag Mohanty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: A ruby port of (spark)[https://github.com/holman/spark]
|
56
|
+
email:
|
57
|
+
- tevren@gmail.com
|
58
|
+
executables:
|
59
|
+
- rubyspark
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/rubyspark
|
69
|
+
- lib/rubyspark.rb
|
70
|
+
- lib/rubyspark/version.rb
|
71
|
+
- rubyspark.gemspec
|
72
|
+
- spec/rubyspark_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
homepage: ''
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.2.2
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: A ruby port of spark
|
98
|
+
test_files:
|
99
|
+
- spec/rubyspark_spec.rb
|
100
|
+
- spec/spec_helper.rb
|