conquer-dzen 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/conquer-dzen.gemspec +26 -0
- data/lib/conquer/dzen.rb +13 -0
- data/lib/conquer/dzen/color.rb +23 -0
- data/lib/conquer/dzen/graphics.rb +42 -0
- data/lib/conquer/dzen/graphics/battery.rb +31 -0
- data/lib/conquer/dzen/graphics/circle.rb +18 -0
- data/lib/conquer/dzen/graphics/circle_outline.rb +14 -0
- data/lib/conquer/dzen/graphics/graphic.rb +32 -0
- data/lib/conquer/dzen/graphics/icon.rb +18 -0
- data/lib/conquer/dzen/graphics/progress_bar.rb +43 -0
- data/lib/conquer/dzen/graphics/rectangle.rb +19 -0
- data/lib/conquer/dzen/graphics/rectangle_outline.rb +14 -0
- data/lib/conquer/dzen/positioning.rb +29 -0
- data/lib/conquer/dzen/version.rb +5 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c8933fbe7d81968698b0cb03f96d6779097065e4
|
4
|
+
data.tar.gz: a8c7295a89adc78506ba843bd7ac475eea5608bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a44a9d97917ea92e17a7c70f14184b044b2c87fded2dc2cba533d337f617f809307bba3a67d917c9d2738d6d5d4eb3674e45e92d4c538389d22560286acca6c
|
7
|
+
data.tar.gz: 5460a13f78768047598162adecd396213517167958d9c2f7c1bfbe25473ef23a9dcc5ae31ca2eeb75598e409306b1bb54bbd18cb73a055f8dc1e687b2f1762ed
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Conquer::Dzen
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/conquer/dzen`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'conquer-dzen'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install conquer-dzen
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/conquer-dzen.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "conquer/dzen"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'conquer/dzen/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "conquer-dzen"
|
8
|
+
spec.version = Conquer::Dzen::VERSION
|
9
|
+
spec.authors = ["Joakim Reinert"]
|
10
|
+
spec.email = ["mail@jreinert.com"]
|
11
|
+
|
12
|
+
spec.summary = 'Dzen plugin for conquer'
|
13
|
+
spec.description = 'Adds dzen helpers to conquer'
|
14
|
+
spec.homepage = 'https://github.com/jreinert/conquer-dzen'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
|
25
|
+
spec.add_dependency 'conquer', '~> 0.1'
|
26
|
+
end
|
data/lib/conquer/dzen.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'conquer'
|
2
|
+
require 'conquer/dzen/version'
|
3
|
+
require 'conquer/dzen/color'
|
4
|
+
require 'conquer/dzen/graphics'
|
5
|
+
require 'conquer/dzen/positioning'
|
6
|
+
|
7
|
+
module Conquer
|
8
|
+
module Helpers
|
9
|
+
extend Dzen::Color
|
10
|
+
extend Dzen::Graphics
|
11
|
+
extend Dzen::Positioning
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Conquer
|
2
|
+
module Dzen
|
3
|
+
module Color
|
4
|
+
def fg(color, &block)
|
5
|
+
change_color(:fg, color, &block)
|
6
|
+
end
|
7
|
+
|
8
|
+
def bg(color, &block)
|
9
|
+
change_color(:bg, color, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def change_color(type, color)
|
15
|
+
if block_given?
|
16
|
+
"^#{type}(#{color})#{yield}^#{type}()"
|
17
|
+
else
|
18
|
+
"^#{type}(#{color})"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'conquer/dzen/positioning'
|
2
|
+
require 'conquer/dzen/graphics/icon'
|
3
|
+
require 'conquer/dzen/graphics/rectangle'
|
4
|
+
require 'conquer/dzen/graphics/rectangle_outline'
|
5
|
+
require 'conquer/dzen/graphics/circle'
|
6
|
+
require 'conquer/dzen/graphics/circle_outline'
|
7
|
+
require 'conquer/dzen/graphics/progress_bar'
|
8
|
+
require 'conquer/dzen/graphics/battery'
|
9
|
+
|
10
|
+
module Conquer
|
11
|
+
module Dzen
|
12
|
+
module Graphics
|
13
|
+
def icon(path)
|
14
|
+
Icon.new(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def rectangle(width, height)
|
18
|
+
Rectangle.new(width, height)
|
19
|
+
end
|
20
|
+
|
21
|
+
def rectangle_outline(width, height)
|
22
|
+
RectangleOutline.new(width, height)
|
23
|
+
end
|
24
|
+
|
25
|
+
def circle(radius)
|
26
|
+
Circle.new(radius)
|
27
|
+
end
|
28
|
+
|
29
|
+
def circle_outline(radius)
|
30
|
+
CircleOutline.new(radius)
|
31
|
+
end
|
32
|
+
|
33
|
+
def progress_bar(progress, width, height, orientation = :horizontal)
|
34
|
+
ProgressBar.new(progress, width, height, orientation)
|
35
|
+
end
|
36
|
+
|
37
|
+
def battery(percentage, width, height, orientation = :horizontal)
|
38
|
+
Battery.new(percentage, width, height, orientation)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'conquer/dzen/graphics/progress_bar'
|
2
|
+
require 'conquer/dzen/graphics/rectangle'
|
3
|
+
|
4
|
+
module Conquer
|
5
|
+
module Dzen
|
6
|
+
module Graphics
|
7
|
+
class Battery < ProgressBar
|
8
|
+
def initialize(percentage, width, height, orientation = :horizontal)
|
9
|
+
super
|
10
|
+
@template << '%s'
|
11
|
+
@template_args = [outline, fill, plus_pole]
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def plus_pole
|
17
|
+
orientation == :horizontal ? vertical_plus_pole : horizontal_plus_pole
|
18
|
+
end
|
19
|
+
|
20
|
+
def vertical_plus_pole
|
21
|
+
result = Rectangle.new(width / 2.0, height / 4.0)
|
22
|
+
result.move((width + result.width) / 2.0, -height)
|
23
|
+
end
|
24
|
+
|
25
|
+
def horizontal_plus_pole
|
26
|
+
Rectangle.new(height / 4.0, height / 2.0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'conquer/dzen/graphics/rectangle'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Graphics
|
6
|
+
class Circle < Graphic
|
7
|
+
attr_reader :radius
|
8
|
+
|
9
|
+
def initialize(radius)
|
10
|
+
super()
|
11
|
+
@radius = radius
|
12
|
+
@template = '^c(%d)'
|
13
|
+
@template_args = [radius]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'conquer/dzen/positioning'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Graphics
|
6
|
+
class Graphic
|
7
|
+
include Positioning
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@x_shift = 0
|
11
|
+
@y_shift = 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def move(x, y)
|
15
|
+
@x_shift += x
|
16
|
+
@y_shift += y
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
shift(@x_shift, @y_shift) { render }
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def render
|
27
|
+
format(@template, *@template_args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'conquer/dzen/graphics/graphic'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Graphics
|
6
|
+
class Icon < Graphic
|
7
|
+
attr_reader :path
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
super()
|
11
|
+
@path = path
|
12
|
+
@template = '^i(%s)'
|
13
|
+
@template_args = [path]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'conquer/dzen/graphics/graphic'
|
2
|
+
require 'conquer/dzen/graphics/rectangle'
|
3
|
+
|
4
|
+
module Conquer
|
5
|
+
module Dzen
|
6
|
+
module Graphics
|
7
|
+
class ProgressBar < Graphic
|
8
|
+
attr_reader :progress, :width, :height, :orientation
|
9
|
+
|
10
|
+
def initialize(progress, width, height, orientation = :horizontal)
|
11
|
+
super()
|
12
|
+
@progress = progress
|
13
|
+
@width = width
|
14
|
+
@height = height
|
15
|
+
@orientation = orientation
|
16
|
+
@template = '^ib(1)^p(_LOCK_X)%s%s^p(_UNLOCK_X)^ib(0)'
|
17
|
+
@template << shift(width, 0)
|
18
|
+
@template_args = [outline, fill]
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def horizontal_fill
|
24
|
+
Rectangle.new(width * progress / 100.0, height)
|
25
|
+
end
|
26
|
+
|
27
|
+
def vertical_fill
|
28
|
+
fill_height = height * progress / 100.0
|
29
|
+
y_shift = height - fill_height
|
30
|
+
Rectangle.new(width, fill_height).move(0, y_shift)
|
31
|
+
end
|
32
|
+
|
33
|
+
def fill
|
34
|
+
orientation == :horizontal ? horizontal_fill : vertical_fill
|
35
|
+
end
|
36
|
+
|
37
|
+
def outline
|
38
|
+
RectangleOutline.new(width, height)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'conquer/dzen/graphics/graphic'
|
2
|
+
|
3
|
+
module Conquer
|
4
|
+
module Dzen
|
5
|
+
module Graphics
|
6
|
+
class Rectangle < Graphic
|
7
|
+
attr_reader :width, :height
|
8
|
+
|
9
|
+
def initialize(width, height)
|
10
|
+
super()
|
11
|
+
@width = width
|
12
|
+
@height = height
|
13
|
+
@template = '^r(%dx%d)'
|
14
|
+
@template_args = [width, height]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Conquer
|
2
|
+
module Dzen
|
3
|
+
module Positioning
|
4
|
+
def lock_x(options = {})
|
5
|
+
if block_given?
|
6
|
+
"#{'^ib(1)' if options[:ignore_bg]}" \
|
7
|
+
"#{lock_x}#{yield}#{unlock_x}" \
|
8
|
+
"#{'^ib(0)' if options[:ignore_bg]}"
|
9
|
+
else
|
10
|
+
"#{'^ib(1)' if options[:ignore_bg]}^p(_LOCK_X)"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def unlock_x
|
15
|
+
'^p(_UNLOCK_X)'
|
16
|
+
end
|
17
|
+
|
18
|
+
def shift(x, y)
|
19
|
+
return "#{shift(x, y)}#{yield}#{shift(-x, -y)}" if block_given?
|
20
|
+
x = x.round
|
21
|
+
y = y.round
|
22
|
+
x = nil if x == 0
|
23
|
+
y = nil if y == 0
|
24
|
+
return unless x || y
|
25
|
+
"^p(#{x};#{y})"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conquer-dzen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joakim Reinert
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.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: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: conquer
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.1'
|
69
|
+
description: Adds dzen helpers to conquer
|
70
|
+
email:
|
71
|
+
- mail@jreinert.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- conquer-dzen.gemspec
|
85
|
+
- lib/conquer/dzen.rb
|
86
|
+
- lib/conquer/dzen/color.rb
|
87
|
+
- lib/conquer/dzen/graphics.rb
|
88
|
+
- lib/conquer/dzen/graphics/battery.rb
|
89
|
+
- lib/conquer/dzen/graphics/circle.rb
|
90
|
+
- lib/conquer/dzen/graphics/circle_outline.rb
|
91
|
+
- lib/conquer/dzen/graphics/graphic.rb
|
92
|
+
- lib/conquer/dzen/graphics/icon.rb
|
93
|
+
- lib/conquer/dzen/graphics/progress_bar.rb
|
94
|
+
- lib/conquer/dzen/graphics/rectangle.rb
|
95
|
+
- lib/conquer/dzen/graphics/rectangle_outline.rb
|
96
|
+
- lib/conquer/dzen/positioning.rb
|
97
|
+
- lib/conquer/dzen/version.rb
|
98
|
+
homepage: https://github.com/jreinert/conquer-dzen
|
99
|
+
licenses: []
|
100
|
+
metadata: {}
|
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: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.5.1
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: Dzen plugin for conquer
|
121
|
+
test_files: []
|