whirled_peas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,29 @@
1
+ module WhirledPeas
2
+ module UI
3
+ class Stroke
4
+ EMPTY = Stroke.new
5
+
6
+ attr_reader :left, :top, :chars
7
+
8
+ def initialize(left, top, chars)
9
+ @left = left
10
+ @top = top
11
+ @chars = chars
12
+ end
13
+
14
+ def hash
15
+ [left, top, chars].hash
16
+ end
17
+
18
+ def ==(other)
19
+ other.is_a?(self.class) && self.hash == other.hash
20
+ end
21
+
22
+ def inspect
23
+ "Stroke(left=#{left}, top=#{top}, chars=#{chars})"
24
+ end
25
+
26
+ alias_method :eql?, :==
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module WhirledPeas
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'sandbox'
2
+
3
+ WhirledPeas.sandbox do |t|
4
+ t.add_box do |outer, s|
5
+ s.full_border
6
+ s.bg_color = :green
7
+ s.width = 100
8
+ outer.add_box do |inner, s|
9
+ s.auto_margin = true
10
+ "MIDDLE"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'sandbox'
2
+
3
+ WhirledPeas.sandbox do |t|
4
+ t.add_box do |outer, outer_s|
5
+ outer_s.full_border
6
+ outer_s.bg_color = :green
7
+ outer_s.set_padding(left: 3, right: 3, top: 1, bottom: 1)
8
+ outer.add_box do |inner1, i1_s|
9
+ i1_s.flow = :t2b
10
+ inner1.add_box { "TOP LEFT" }
11
+ inner1.add_box { "BOTTOM LEFT" }
12
+ end
13
+ outer.add_box do |inner2, i2_s|
14
+ i2_s.flow = :t2b
15
+ inner2.add_box { "TOP RIGHT "}
16
+ inner2.add_box { "BOTTOM RIGHT "}
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'sandbox'
2
+
3
+ WhirledPeas.sandbox do |t|
4
+ t.add_grid do |grid, settings|
5
+ settings.num_cols = 3
6
+ settings.bg_color = :yellow
7
+ settings.color = :blue
8
+ settings.set_margin(top: 3, left: 10)
9
+ settings.set_padding(top: 1, bottom: 1, left: 3, right: 3)
10
+ settings.full_border(color: :green)
11
+ 6.times.map { |i| (i + 1).to_s }
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'bundler/setup'
2
+ require 'whirled_peas'
3
+ require 'whirled_peas/ui'
4
+
5
+ module WhirledPeas
6
+ def self.sandbox(&block)
7
+ template = WhirledPeas.template(&block)
8
+ if ARGV.last == '--debug'
9
+ puts template.inspect
10
+ screen = UI::Screen.new(false)
11
+ else
12
+ screen = UI::Screen.new
13
+ end
14
+ screen.paint(template)
15
+ screen.finalize
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'sandbox'
2
+
3
+ WhirledPeas.sandbox do |t|
4
+ t.add_text do |_, settings|
5
+ settings.bg_color = :green
6
+ settings.align = :right
7
+ settings.width = 30
8
+ "HELLO"
9
+ end
10
+ t.add_text do |_, settings|
11
+ settings.bg_color = :red
12
+ settings.align = :center
13
+ settings.width = 30
14
+ "WORLD"
15
+ end
16
+ t.add_text do |_, settings|
17
+ settings.bg_color = :green
18
+ settings.width = 4
19
+ "1234567890"
20
+ end
21
+ t.add_text do |_, settings|
22
+ settings.bg_color = :red
23
+ settings.align = :center
24
+ settings.width = 4
25
+ "1234567890"
26
+ end
27
+ t.add_text do |_, settings|
28
+ settings.bg_color = :green
29
+ settings.align = :right
30
+ settings.width = 4
31
+ "1234567890"
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'lib/whirled_peas/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'whirled_peas'
5
+ spec.version = WhirledPeas::VERSION
6
+ spec.authors = ['Tom Collier']
7
+ spec.email = ['tcollier@gmail.com']
8
+
9
+ spec.summary = %q{Visualizer for Advent of Code solutions}
10
+ spec.homepage = 'https://github.com/tcollier/whirled_peas'
11
+ spec.license = 'MIT'
12
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
13
+
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = 'https://github.com/tcollier/whirled_peas/blob/main/CHANGELOG.md'
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_runtime_dependency 'highline', '~> 2.0'
26
+ spec.add_runtime_dependency 'json', '~> 2.5'
27
+ spec.add_runtime_dependency 'tty-cursor', '~> 0.7'
28
+ end
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: whirled_peas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Collier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-cursor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.7'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.7'
55
+ description:
56
+ email:
57
+ - tcollier@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/console
72
+ - bin/setup
73
+ - lib/whirled_peas.rb
74
+ - lib/whirled_peas/frame.rb
75
+ - lib/whirled_peas/frame/consumer.rb
76
+ - lib/whirled_peas/frame/loop.rb
77
+ - lib/whirled_peas/frame/producer.rb
78
+ - lib/whirled_peas/null_logger.rb
79
+ - lib/whirled_peas/ui.rb
80
+ - lib/whirled_peas/ui/ansi.rb
81
+ - lib/whirled_peas/ui/canvas.rb
82
+ - lib/whirled_peas/ui/element.rb
83
+ - lib/whirled_peas/ui/painter.rb
84
+ - lib/whirled_peas/ui/screen.rb
85
+ - lib/whirled_peas/ui/settings.rb
86
+ - lib/whirled_peas/ui/stroke.rb
87
+ - lib/whirled_peas/version.rb
88
+ - sandbox/auto.rb
89
+ - sandbox/box.rb
90
+ - sandbox/grid.rb
91
+ - sandbox/sandbox.rb
92
+ - sandbox/text.rb
93
+ - whirled_peas.gemspec
94
+ homepage: https://github.com/tcollier/whirled_peas
95
+ licenses:
96
+ - MIT
97
+ metadata:
98
+ homepage_uri: https://github.com/tcollier/whirled_peas
99
+ source_code_uri: https://github.com/tcollier/whirled_peas
100
+ changelog_uri: https://github.com/tcollier/whirled_peas/blob/main/CHANGELOG.md
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 2.3.0
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubygems_version: 3.0.3
117
+ signing_key:
118
+ specification_version: 4
119
+ summary: Visualizer for Advent of Code solutions
120
+ test_files: []