say_it_with_graphs 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +9 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +50 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +31 -0
  9. data/Rakefile +16 -0
  10. data/bin/say-it-with-graphs +11 -0
  11. data/lib/say_it_with_graphs/brush.rb +34 -0
  12. data/lib/say_it_with_graphs/characters/a.rb +26 -0
  13. data/lib/say_it_with_graphs/characters/bang.rb +41 -0
  14. data/lib/say_it_with_graphs/characters/e.rb +36 -0
  15. data/lib/say_it_with_graphs/characters/g.rb +33 -0
  16. data/lib/say_it_with_graphs/characters/h.rb +34 -0
  17. data/lib/say_it_with_graphs/characters/i.rb +20 -0
  18. data/lib/say_it_with_graphs/characters/l.rb +25 -0
  19. data/lib/say_it_with_graphs/characters/lt.rb +28 -0
  20. data/lib/say_it_with_graphs/characters/m.rb +30 -0
  21. data/lib/say_it_with_graphs/characters/o.rb +34 -0
  22. data/lib/say_it_with_graphs/characters/p.rb +32 -0
  23. data/lib/say_it_with_graphs/characters/r.rb +40 -0
  24. data/lib/say_it_with_graphs/characters/s.rb +33 -0
  25. data/lib/say_it_with_graphs/characters/space.rb +17 -0
  26. data/lib/say_it_with_graphs/characters/three.rb +37 -0
  27. data/lib/say_it_with_graphs/characters/v.rb +18 -0
  28. data/lib/say_it_with_graphs/client.rb +22 -0
  29. data/lib/say_it_with_graphs/frame.rb +18 -0
  30. data/lib/say_it_with_graphs/framer.rb +40 -0
  31. data/lib/say_it_with_graphs/graph_controls.rb +17 -0
  32. data/lib/say_it_with_graphs/line.rb +18 -0
  33. data/lib/say_it_with_graphs/version.rb +3 -0
  34. data/lib/say_it_with_graphs.rb +12 -0
  35. data/say_it_with_graphs.gemspec +28 -0
  36. data/spec/lib/say_it_with_graphs/brush_spec.rb +27 -0
  37. data/spec/lib/say_it_with_graphs/client_spec.rb +46 -0
  38. data/spec/lib/say_it_with_graphs/frame_spec.rb +36 -0
  39. data/spec/lib/say_it_with_graphs/framer_spec.rb +44 -0
  40. data/spec/lib/say_it_with_graphs/graph_controls_spec.rb +31 -0
  41. data/spec/lib/say_it_with_graphs/line_spec.rb +29 -0
  42. data/spec/spec_helper.rb +90 -0
  43. metadata +178 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22ec0d37012cf44ccb9bb21eb0ec4a7ff0c15fef
4
+ data.tar.gz: 228761e63191d0923427a3dcd32ed10ae5405ab9
5
+ SHA512:
6
+ metadata.gz: b104f125fac78b4e2dfb6d7686c9154bf75bda780092dd56ad143f98a02acb34a133d69eb24205809b2a44f0c3423ce54e3347661ac13526be6e9d9d09adafbe
7
+ data.tar.gz: 5b0a6f283985266caaa7955d818649365afd5228ca96e9c7e3459792349b365311881e11f1d4ac5c0e7355ce886cb5ed4a5f46afdd64d23f944f04f0f3e0580c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache:
4
+ - bundler
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1
9
+ - 2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in say_it_with_graphs.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,50 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ole Michaelis
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,31 @@
1
+ # SayItWithGraphs [![Build Status](https://travis-ci.org/nesQuick/say-it-with-graphs.svg?branch=master)](https://travis-ci.org/nesQuick/say-it-with-graphs)
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'say_it_with_graphs'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install say_it_with_graphs
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/say_it_with_graphs/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require './lib/say_it_with_graphs.rb'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
8
+
9
+ namespace :'say-it-with-graphs' do
10
+ desc "Draws 'something' onto a graph"
11
+ task 'say', [:something] do |t, args|
12
+ something = args[:something]
13
+ p "making '#{something}' with <3 and graphs"
14
+ SayItWithGraphs::Brush.new.paint! SayItWithGraphs::Framer.new.frames(something)
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'say_it_with_graphs'
4
+
5
+ something = ARGV[0] || ''
6
+
7
+ # poormans validation :D
8
+ fail 'gimme something to say' if something == ''
9
+
10
+ p "making '#{something}' with <3 and graphs"
11
+ SayItWithGraphs::Brush.new.paint! SayItWithGraphs::Framer.new.frames(something)
@@ -0,0 +1,34 @@
1
+ module SayItWithGraphs
2
+ class Brush
3
+ def paint!(frames)
4
+ frames.flatten!
5
+ target = "say-it-with-graphs-#{rand(100)}"
6
+ p "Painting to #{target} ... ETA: #{frames.length} minutes"
7
+ p "=> https://metrics.librato.com/metrics/#{target}"
8
+ frames.each_with_index do |frame, i|
9
+ p "Frame #{i} of #{frames.length}" if debug?
10
+ frame.complete.each do |line|
11
+ p "Line[#{line.line_number}] pos: #{line.position}" if debug?
12
+ Client.submit value: line.position, source: "source-no-#{line.line_number}", name: target
13
+ sleep 0.5
14
+ # Thread.new { Client.submit value: line.position, source: "source-no-#{line.line_number}" }
15
+ end
16
+ countdown 60
17
+ end
18
+ end
19
+
20
+ def countdown(sec)
21
+ sec.times do |i|
22
+ print "\r#{i} / #{sec}"
23
+ sleep 1
24
+ end
25
+ print "\r"
26
+ end
27
+
28
+ private
29
+
30
+ def debug?
31
+ true
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class A
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'a'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ frame do |f|
14
+ f.line[a].at 0
15
+ f.line[b].at 50
16
+ f.line[a].at 100
17
+ end
18
+ frame do |f|
19
+ f.line[a].at 100
20
+ f.line[b].at 50
21
+ f.line[a].at 0
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class Bang
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ '!'
8
+ end
9
+
10
+ def draw
11
+ up_a = rnd_line
12
+ up_b = rnd_line
13
+
14
+ down_a = rnd_line
15
+ down_b = rnd_line
16
+
17
+ frame do |f|
18
+ f.line[up_a].at 100
19
+ f.line[up_b].at 100
20
+
21
+ f.line[down_a].at 0
22
+ f.line[down_b].at 0
23
+ end
24
+ frame do |f|
25
+ f.line[up_a].at 100
26
+ f.line[up_b].at 25
27
+
28
+ f.line[down_a].at 0
29
+ f.line[down_b].at 15
30
+ end
31
+ frame do |f|
32
+ f.line[up_a].at 100
33
+ f.line[up_b].at 100
34
+
35
+ f.line[down_a].at 0
36
+ f.line[down_b].at 0
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,36 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class E
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'e'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ c = rnd_line
14
+ frame do |f|
15
+ f.line[c].at 0
16
+
17
+ f.line[a].at 0
18
+ f.line[a].at 100
19
+
20
+ f.line[b].at 0
21
+ f.line[b].at 50
22
+ end
23
+ frame do |f|
24
+ f.line[c].at 0
25
+ f.line[a].at 100
26
+ f.line[b].at 50
27
+ end
28
+ frame do |f|
29
+ f.line[c].at 0
30
+ f.line[a].at 100
31
+ f.line[b].at 50
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class G
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'g'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ c = rnd_line
14
+ frame do |f|
15
+ f.line[a].at 33
16
+ f.line[a].at 66
17
+ f.line[b].at 33
18
+ end
19
+ frame do |f|
20
+ f.line[a].at 100
21
+ f.line[c].at 50
22
+ f.line[b].at 0
23
+ end
24
+ frame do |f|
25
+ f.line[c].at 50
26
+ f.line[c].at 0
27
+ f.line[a].at 100
28
+ f.line[b].at 0
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class H
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'h'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ c = rnd_line
14
+ frame do |f|
15
+ f.lines[a].at 0
16
+ f.lines[b].at 0
17
+ f.lines[a].at 100
18
+ f.lines[b].at 50
19
+ f.lines[a].at 0
20
+ end
21
+ frame do |f|
22
+ f.lines[b].at 50
23
+ end
24
+ frame do |f|
25
+ f.lines[c].at 0
26
+ f.lines[b].at 50
27
+ f.lines[c].at 100
28
+ f.lines[b].at 0
29
+ f.lines[c].at 0
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class I
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'i'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ frame do |f|
13
+ f.line[a].at 0
14
+ f.line[a].at 100
15
+ f.line[a].at 0
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class L
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'l'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ frame do |f|
13
+ f.line[a].at 100
14
+ f.line[a].at 0
15
+ end
16
+ frame do |f|
17
+ f.line[a].at 0
18
+ end
19
+ frame do |f|
20
+ f.line[a].at 0
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class Lt
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ '<'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ frame do |f|
14
+ f.line[a].at 50
15
+ f.line[b].at 50
16
+ end
17
+ frame do |f|
18
+ f.line[a].at 75
19
+ f.line[b].at 25
20
+ end
21
+ frame do |f|
22
+ f.line[a].at 100
23
+ f.line[b].at 0
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class M
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'm'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ frame do |f|
13
+ f.line[a].at 0
14
+ end
15
+ frame do |f|
16
+ f.line[a].at 100
17
+ end
18
+ frame do |f|
19
+ f.line[a].at 0
20
+ end
21
+ frame do |f|
22
+ f.line[a].at 100
23
+ end
24
+ frame do |f|
25
+ f.line[a].at 0
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,34 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class O
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'o'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ frame do |f|
14
+ f.line[a].at 33
15
+ f.line[a].at 66
16
+ f.line[b].at 33
17
+ end
18
+ frame do |f|
19
+ f.line[a].at 100
20
+ f.line[b].at 0
21
+ end
22
+ frame do |f|
23
+ f.line[a].at 100
24
+ f.line[b].at 0
25
+ end
26
+ frame do |f|
27
+ f.line[a].at 66
28
+ f.line[a].at 33
29
+ f.line[b].at 33
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class P
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 'p'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ c = rnd_line
14
+ frame do |f|
15
+ f.line[a].at 0
16
+ f.line[a].at 100
17
+ f.line[b].at 100
18
+ f.line[c].at 50
19
+ end
20
+ frame do |f|
21
+ f.line[b].at 100
22
+ f.line[c].at 50
23
+ end
24
+ frame do |f|
25
+ f.line[b].at 84
26
+ f.line[c].at 67
27
+ f.line[b].at 67
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,40 @@
1
+ require 'securerandom'
2
+
3
+ module SayItWithGraphs
4
+ module Characters
5
+ class R
6
+ include SayItWithGraphs::GraphControls
7
+
8
+ def define
9
+ 'r'
10
+ end
11
+
12
+ def draw
13
+ a = rnd_line
14
+ b = rnd_line
15
+ c = rnd_line
16
+ d = rnd_line
17
+ frame do |f|
18
+ f.line[a].at 0
19
+ f.line[a].at 100
20
+
21
+ f.line[b].at 0
22
+ f.line[b].at 50
23
+
24
+ f.line[c].at 0
25
+ f.line[c].at 50
26
+ end
27
+ frame do |f|
28
+ f.line[a].at 88
29
+ f.line[b].at 65
30
+ f.line[c].at 65
31
+ end
32
+ frame do |f|
33
+ f.line[a].at 75
34
+ f.line[b].at 75
35
+ f.line[c].at 0
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,33 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class S
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ 's'
8
+ end
9
+
10
+ def draw
11
+ a = rnd_line
12
+ b = rnd_line
13
+ c = rnd_line
14
+ frame do |f|
15
+ f.line[a].at 60
16
+ f.line[a].at 80
17
+ f.line[b].at 60
18
+ f.line[c].at 0
19
+ end
20
+ frame do |f|
21
+ f.line[a].at 100
22
+ f.line[c].at 0
23
+ end
24
+ frame do |f|
25
+ f.line[a].at 100
26
+ f.line[b].at 40
27
+ f.line[b].at 20
28
+ f.line[c].at 20
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+ module SayItWithGraphs
2
+ module Characters
3
+ class Space
4
+ include SayItWithGraphs::GraphControls
5
+
6
+ def define
7
+ ' '
8
+ end
9
+
10
+ def draw
11
+ frame do |f|
12
+ # nothing becaise its just a space
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end