This commit is contained in:
Fernando Favini
2024-07-29 21:22:39 +00:00
committed by GitHub
21 changed files with 560 additions and 2 deletions

View File

@@ -1,3 +1,6 @@
## THIS IS A FORK
please visit the original project and support it
# ESP8266 Deauther
<img src='https://deauther.com/img/logo.png' alt='Deauther Logo' width='200' />
@@ -35,4 +38,4 @@ Neither the ESP8266, nor its SDK was meant or built for such purposes. **Bugs ca
**Use it only against your own networks and devices!**
Please check the legal regulations in your country before using it.
We don't take any responsibility for what you do with this program.
We don't take any responsibility for what you do with this program.

View File

@@ -443,6 +443,11 @@ void DisplayUI::setup() {
// CLOCK MENU
createMenu(&clockMenu, &mainMenu, [this]() {
addMenuNode(&clockMenu, D_CRYPTIC_CLOCK, [this]() { // CRYPTIC CLOCK
mode = DISPLAY_MODE::CRYPTIC_CLOCK;
display.setFont(Cryptic_Plain_24);
display.setTextAlignment(TEXT_ALIGN_CENTER);
});
addMenuNode(&clockMenu, D_CLOCK_DISPLAY, [this]() { // CLOCK
mode = DISPLAY_MODE::CLOCK_DISPLAY;
display.setFont(ArialMT_Plain_24);
@@ -611,6 +616,7 @@ void DisplayUI::setupButtons() {
case DISPLAY_MODE::CLOCK:
case DISPLAY_MODE::CLOCK_DISPLAY:
case DISPLAY_MODE::CRYPTIC_CLOCK:
mode = DISPLAY_MODE::MENU;
display.setFont(DejaVu_Sans_Mono_12);
display.setTextAlignment(TEXT_ALIGN_LEFT);
@@ -704,7 +710,9 @@ void DisplayUI::draw(bool force) {
case DISPLAY_MODE::INTRO:
if (!scan.isScanning() && (currentTime - startTime >= screenIntroTime)) {
mode = DISPLAY_MODE::MENU;
mode = DISPLAY_MODE::CRYPTIC_CLOCK;
display.setFont(Cryptic_Plain_24);
display.setTextAlignment(TEXT_ALIGN_CENTER);
}
drawIntro();
break;
@@ -712,6 +720,9 @@ void DisplayUI::draw(bool force) {
case DISPLAY_MODE::CLOCK_DISPLAY:
drawClock();
break;
case DISPLAY_MODE::CRYPTIC_CLOCK:
drawCrypticClock();
break;
case DISPLAY_MODE::RESETTING:
drawResetting();
break;
@@ -827,6 +838,16 @@ void DisplayUI::drawClock() {
display.drawString(64, 20, clockTime);
}
void DisplayUI::drawCrypticClock() {
String clockTime = "0123456"; // String(clockHour);
clockTime += ':';
if (clockMinute < 10) clockTime += '0';
clockTime += String(clockMinute);
display.drawString(64, 20, clockTime);
}
void DisplayUI::drawResetting() {
drawString(2, center(str(D_RESETTING), maxLen));
}

View File

@@ -78,6 +78,7 @@ enum class DISPLAY_MODE { OFF,
INTRO,
CLOCK,
CLOCK_DISPLAY,
CRYPTIC_CLOCK,
RESETTING };
class DisplayUI {
@@ -196,6 +197,7 @@ class DisplayUI {
// fake clock
void drawClock();
void drawCrypticClock();
void setTime(int h, int m, int s);
int clockHour = 6;

View File

@@ -366,6 +366,7 @@ const char D_ATTACK[] PROGMEM = "ATTACK";
const char D_PACKET_MONITOR[] PROGMEM = "PACKET MONITOR";
const char D_CLOCK[] PROGMEM = "CLOCK";
const char D_CLOCK_DISPLAY[] PROGMEM = "CLOCK DISPLAY";
const char D_CRYPTIC_CLOCK[] PROGMEM = "CRYPTIC CLOCK";
const char D_CLOCK_SET[] PROGMEM = "SET CLOCK";
// SCAN MENU

View File

@@ -1275,4 +1275,70 @@ const uint8_t ArialMT_Plain_24[] PROGMEM = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0xFF,0x07,0xE0,0xFF,0xFF,0x07,0x00,0x1C,0x18,0x00,0x00,0x06,0x30,0x00,0x00,0x06,0x30,0x00,0x00,0x06,0x30,0x00,0x00,0x0E,0x38,0x00,0x00,0x1C,0x1C,0x00,0x00,0xF8,0x0F,0x00,0x00,0xF0,0x03, // 254
0x00,0x00,0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x7E,0x00,0x06,0xC0,0xF0,0x01,0x06,0xC0,0x80,0x0F,0x07,0x00,0x00,0xFE,0x03,0x00,0x00,0xFC,0x00,0xC0,0xC0,0x1F,0x00,0xC0,0xF8,0x03,0x00,0x00,0x3E,0x00,0x00,0x00,0x06 // 255
};
const uint8_t Cryptic_Plain_24[] PROGMEM = {
0x18, // Width: 24
0x1C, // Height: 28
0x20, // First Char: 32
0x1B, // Numbers of Chars: 27
// Jump Table:
// start point (1), start point (2), data size, block width
0xFF, 0xFF, 0x00, 0x07, // 32:65535
0x00, 0x00, 0x13, 0x07, // 33:0
0x00, 0x13, 0x1A, 0x09, // 34:19
0x00, 0x2D, 0x33, 0x0D, // 35:45
0x00, 0x60, 0x2F, 0x0D, // 36:96
0x00, 0x8F, 0x4F, 0x15, // 37:143
0x00, 0xDE, 0x3B, 0x10, // 38:222
0x01, 0x19, 0x0A, 0x05, // 39:281
0x01, 0x23, 0x1C, 0x08, // 40:291
0x01, 0x3F, 0x1B, 0x08, // 41:319
0x01, 0x5A, 0x21, 0x09, // 42:346
0x01, 0x7B, 0x32, 0x0E, // 43:379
0x01, 0xAD, 0x10, 0x07, // 44:429
0x01, 0xBD, 0x1B, 0x08, // 45:445
0x01, 0xD8, 0x0F, 0x07, // 46:472
0x01, 0xE7, 0x19, 0x07, // 47:487
// 0x02, 0x00, 0x2F, 0x0D, // 48:512 '0'
0x02, 0x00, 0x2F, 0x0D, // 48:512 '0'
0x02, 0x2F, 0x23, 0x0D, // 49:559 '1'
0x02, 0x52, 0x2F, 0x0D, // 50:594 '2'
0x02, 0x81, 0x2F, 0x0D, // 51:641 '3'
0x02, 0xB0, 0x2F, 0x0D, // 52:688 '4'
0x02, 0xDF, 0x2F, 0x0D, // 53:735 '5'
0x03, 0x0E, 0x2F, 0x0D, // 54:782 '6'
0x03, 0x3D, 0x2D, 0x0D, // 55:829 '7'
0x03, 0x6A, 0x2F, 0x0D, // 56:874 '8'
0x03, 0x99, 0x2F, 0x0D, // 57:921 '9'
0x03, 0xC8, 0x0F, 0x07, // 58:968 ':'
// Font Data:
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xFF,0x33,0x00,0xE0,0xFF,0x33, // 33
0x00,0x00,0x00,0x00,0xE0,0x07,0x00,0x00,0xE0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x07,0x00,0x00,0xE0,0x07, // 34
0x00,0x0C,0x03,0x00,0x00,0x0C,0x33,0x00,0x00,0x0C,0x3F,0x00,0x00,0xFC,0x0F,0x00,0x80,0xFF,0x03,0x00,0xE0,0x0F,0x03,0x00,0x60,0x0C,0x33,0x00,0x00,0x0C,0x3F,0x00,0x00,0xFC,0x0F,0x00,0x80,0xFF,0x03,0x00,0xE0,0x0F,0x03,0x00,0x60,0x0C,0x03,0x00,0x00,0x0C,0x03, // 35
0x00,0x00,0x00,0x00,0x80,0x07,0x06,0x00,0xC0,0x0F,0x1E,0x00,0xC0,0x18,0x1C,0x00,0x60,0x18,0x38,0x00,0x60,0x30,0x30,0x00,0xF0,0xFF,0xFF,0x00,0x60,0x30,0x30,0x00,0x60,0x60,0x38,0x00,0xC0,0x60,0x18,0x00,0xC0,0xC1,0x1F,0x00,0x00,0x81,0x07, // 36
0x00,0x00,0x00,0x00,0x80,0x0F,0x00,0x00,0xC0,0x1F,0x00,0x00,0x60,0x30,0x00,0x00,0x20,0x20,0x00,0x00,0x20,0x20,0x20,0x00,0x60,0x30,0x38,0x00,0xC0,0x1F,0x1E,0x00,0x80,0x8F,0x0F,0x00,0x00,0xC0,0x03,0x00,0x00,0xF0,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x8F,0x0F,0x00,0xC0,0xC3,0x1F,0x00,0xE0,0x60,0x30,0x00,0x20,0x20,0x20,0x00,0x00,0x20,0x20,0x00,0x00,0x60,0x30,0x00,0x00,0xC0,0x1F,0x00,0x00,0x80,0x0F, // 37
0x00,0x00,0x00,0x00,0x00,0x80,0x07,0x00,0x00,0xC0,0x0F,0x00,0x80,0xE3,0x1C,0x00,0xC0,0x77,0x38,0x00,0xE0,0x3C,0x30,0x00,0x60,0x38,0x30,0x00,0x60,0x78,0x30,0x00,0xE0,0xEC,0x38,0x00,0xC0,0x8F,0x1B,0x00,0x80,0x03,0x1F,0x00,0x00,0x00,0x0F,0x00,0x00,0xC0,0x1F,0x00,0x00,0xC0,0x38,0x00,0x00,0x00,0x10, // 38
0x00,0x00,0x00,0x00,0xE0,0x07,0x00,0x00,0xE0,0x07, // 39
0x00,0x00,0x00,0x00,0x00,0xF0,0x0F,0x00,0x00,0xFE,0x7F,0x00,0x80,0x0F,0xF0,0x01,0xC0,0x01,0x80,0x03,0x60,0x00,0x00,0x06,0x20,0x00,0x00,0x04, // 40
0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x04,0x60,0x00,0x00,0x06,0xC0,0x01,0x80,0x03,0x80,0x0F,0xF0,0x01,0x00,0xFE,0x7F,0x00,0x00,0xF0,0x0F, // 41
0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x80,0x04,0x00,0x00,0x80,0x0F,0x00,0x00,0xE0,0x03,0x00,0x00,0xE0,0x03,0x00,0x00,0x80,0x0F,0x00,0x00,0x80,0x04,0x00,0x00,0x80, // 42
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xFF,0x0F,0x00,0x00,0xFF,0x0F,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60, // 43
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x03,0x00,0x00,0xF0,0x01, // 44
0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01,0x00,0x00,0x80,0x01, // 45
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30, // 46
0x00,0x00,0x30,0x00,0x00,0x00,0x3E,0x00,0x00,0xE0,0x0F,0x00,0x00,0xFC,0x01,0x00,0x80,0x3F,0x00,0x00,0xE0,0x03,0x00,0x00,0x60, // 47
0x00,0x00,0x00,0x00,0x00,0xFE,0x03,0x00,0x80,0xFF,0x0F,0x00,0xC0,0x01,0x1C,0x00,0xE0,0x00,0x38,0x00,0x60,0x00,0x30,0x00,0x60,0x00,0x30,0x00,0x60,0x00,0x30,0x00,0xE0,0x00,0x38,0x00,0xC0,0x01,0x1C,0x00,0x80,0xFF,0x0F,0x00,0x00,0xFE,0x03, // 48
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x03,0x00,0x00,0x80,0x01,0x00,0x00,0xE0,0xFF,0x3F,0x00,0xE0,0xFF,0x3F, // 49
0x00,0x00,0x00,0x00,0x00,0x03,0x30,0x00,0xC0,0x03,0x38,0x00,0xC0,0x00,0x3C,0x00,0x60,0x00,0x36,0x00,0x60,0x00,0x33,0x00,0x60,0x80,0x31,0x00,0x60,0xC0,0x30,0x00,0x60,0x60,0x30,0x00,0xC0,0x30,0x30,0x00,0xC0,0x1F,0x30,0x00,0x00,0x0F,0x30, // 50
0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x00,0xC0,0x01,0x0E,0x00,0xC0,0x00,0x1C,0x00,0x60,0x00,0x30,0x00,0x60,0x30,0x30,0x00,0x60,0x30,0x30,0x00,0x60,0x30,0x30,0x00,0xC0,0x38,0x30,0x00,0xC0,0x6F,0x18,0x00,0x80,0xC7,0x0F,0x00,0x00,0x80,0x07, // 51
0x00,0x00,0x00,0x00,0x00,0x80,0x03,0x00,0x00,0xC0,0x03,0x00,0x00,0xF0,0x03,0x00,0x00,0x3C,0x03,0x00,0x00,0x0E,0x03,0x00,0x80,0x07,0x03,0x00,0xC0,0x01,0x03,0x00,0xE0,0xFF,0x3F,0x00,0xE0,0xFF,0x3F,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x03, // 52
0x00,0x00,0x00,0x00,0x00,0x30,0x06,0x00,0x80,0x3F,0x0E,0x00,0xE0,0x1F,0x18,0x00,0x60,0x08,0x30,0x00,0x60,0x0C,0x30,0x00,0x60,0x0C,0x30,0x00,0x60,0x0C,0x30,0x00,0x60,0x0C,0x30,0x00,0x60,0x18,0x1C,0x00,0x60,0xF0,0x0F,0x00,0x00,0xE0,0x03, // 53
0x00,0x00,0x00,0x00,0x00,0xFC,0x03,0x00,0x80,0xFF,0x0F,0x00,0xC0,0x63,0x1C,0x00,0xC0,0x30,0x38,0x00,0x60,0x18,0x30,0x00,0x60,0x18,0x30,0x00,0x60,0x18,0x30,0x00,0x60,0x18,0x30,0x00,0xE0,0x30,0x18,0x00,0xC0,0xF1,0x0F,0x00,0x80,0xC1,0x07, // 54
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x60,0x00,0x3C,0x00,0x60,0x80,0x3F,0x00,0x60,0xE0,0x03,0x00,0x60,0x78,0x00,0x00,0x60,0x0E,0x00,0x00,0x60,0x03,0x00,0x00,0xE0,0x01,0x00,0x00,0x60, // 55
0x00,0x00,0x00,0x00,0x00,0x80,0x07,0x00,0x80,0xC7,0x1F,0x00,0xC0,0x6F,0x18,0x00,0xE0,0x38,0x30,0x00,0x60,0x30,0x30,0x00,0x60,0x30,0x30,0x00,0x60,0x30,0x30,0x00,0xE0,0x38,0x30,0x00,0xC0,0x6F,0x18,0x00,0x80,0xC7,0x1F,0x00,0x00,0x80,0x07, // 56
0x00,0x00,0x00,0x00,0x00,0x1F,0x0C,0x00,0x80,0x7F,0x1C,0x00,0xC0,0x61,0x38,0x00,0x60,0xC0,0x30,0x00,0x60,0xC0,0x30,0x00,0x60,0xC0,0x30,0x00,0x60,0xC0,0x30,0x00,0x60,0x60,0x18,0x00,0xC0,0x31,0x1E,0x00,0x80,0xFF,0x0F,0x00,0x00,0xFE,0x01, // 57
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x30,0x00,0x00,0x06,0x30 // 58
};
#endif

2
utils/font_helper/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
coverage
**/.*.swp

View File

@@ -0,0 +1,10 @@
inherit_from: .rubocop_todo.yml
require: rubocop-rspec
AllCops:
TargetRubyVersion: 3.3
NewCops: enable
Style/Documentation:
Enabled: false

View File

@@ -0,0 +1,16 @@
FROM ruby:3.3.1 AS base
RUN useradd -u 1000 app; \
mkdir -p /home/app/app; \
chown app.app -R /home/app
WORKDIR /home/app/app
COPY --chown=app:app Gemfile* /home/app/app/
RUN gem update --system; \
gem install bundler:2.5.16 --default; \
bundle install ; \
chown app.app /usr/local/bundle -R
USER app

35
utils/font_helper/Gemfile Normal file
View File

@@ -0,0 +1,35 @@
# frozen_string_literal: true
source 'https://rubygems.org'
ruby '3.3.1'
gem 'bundler', '2.5.16'
gem 'darthjee-core_ext', '2.0.0'
gem 'rake', '13.1.0'
gem 'sinclair', '2.1.1'
group :development, :test do
gem 'factory_bot', '6.2.1'
gem 'pry', '0.14.2'
gem 'pry-nav', '1.0.0'
gem 'rubycritic', '4.9.1'
gem 'simplecov', '0.22.0'
gem 'yard', '0.9.36'
gem 'yardstick', '0.9.9'
end
group :development do
gem 'reek', '6.1.4'
gem 'rubocop', '1.59.0'
gem 'rubocop-rspec', '3.0.0'
end
group :test do
gem 'minitest', '5.18.0'
gem 'rspec', '3.12.0'
gem 'rspec-collection_matchers', '1.2.0'
gem 'rspec-core', '3.12.2'
gem 'rspec-expectations', '3.12.3'
gem 'rspec-mocks', '3.12.5'
gem 'rspec-support', '3.12.0'
end

View File

@@ -0,0 +1,171 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
childprocess (5.0.0)
coderay (1.1.3)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.3.3)
darthjee-core_ext (2.0.0)
activesupport (>= 5.2.x)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.5.1)
docile (1.4.1)
erubi (1.13.0)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
flay (2.13.3)
erubi (~> 1.10)
path_expander (~> 1.0)
ruby_parser (~> 3.0)
sexp_processor (~> 4.0)
flog (4.8.0)
path_expander (~> 1.0)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.8)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
json (2.7.2)
kwalify (0.7.2)
language_server-protocol (3.17.0.3)
launchy (3.0.1)
addressable (~> 2.8)
childprocess (~> 5.0)
method_source (1.1.0)
minitest (5.18.0)
parallel (1.25.1)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
path_expander (1.1.2)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-nav (1.0.0)
pry (>= 0.9.10, < 0.15)
public_suffix (6.0.1)
racc (1.8.0)
rainbow (3.1.1)
rake (13.1.0)
reek (6.1.4)
kwalify (~> 0.7.0)
parser (~> 3.2.0)
rainbow (>= 2.0, < 4.0)
regexp_parser (2.9.2)
rexml (3.3.2)
strscan
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-collection_matchers (1.2.0)
rspec-expectations (>= 2.99.0.beta1)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.5)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.59.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-rspec (3.0.0)
rubocop (~> 1.40)
ruby-progressbar (1.13.0)
ruby_parser (3.21.1)
racc (~> 1.5)
sexp_processor (~> 4.16)
rubycritic (4.9.1)
flay (~> 2.13)
flog (~> 4.7)
launchy (>= 2.5.2)
parser (>= 3.2.2.4)
rainbow (~> 3.1.1)
reek (~> 6.0, < 6.2)
rexml
ruby_parser (~> 3.21)
simplecov (>= 0.22.0)
tty-which (~> 0.5.0)
virtus (~> 2.0)
sexp_processor (4.17.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinclair (2.1.1)
activesupport (~> 7.0.4)
strscan (3.1.0)
thread_safe (0.3.6)
tty-which (0.5.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
virtus (2.0.0)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
yard (0.9.36)
yardstick (0.9.9)
yard (~> 0.8, >= 0.8.7.2)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
bundler (= 2.5.16)
darthjee-core_ext (= 2.0.0)
factory_bot (= 6.2.1)
minitest (= 5.18.0)
pry (= 0.14.2)
pry-nav (= 1.0.0)
rake (= 13.1.0)
reek (= 6.1.4)
rspec (= 3.12.0)
rspec-collection_matchers (= 1.2.0)
rspec-core (= 3.12.2)
rspec-expectations (= 3.12.3)
rspec-mocks (= 3.12.5)
rspec-support (= 3.12.0)
rubocop (= 1.59.0)
rubocop-rspec (= 3.0.0)
rubycritic (= 4.9.1)
simplecov (= 0.22.0)
sinclair (= 2.1.1)
yard (= 0.9.36)
yardstick (= 0.9.9)
RUBY VERSION
ruby 3.3.1p55
BUNDLED WITH
2.5.16

View File

@@ -0,0 +1,24 @@
version: "3.9"
services:
base: &base
container_name: font_helper
image: font_helper
build:
context: .
dockerfile: Dockerfile
command: /bin/bash
volumes:
- ./:/home/app/app
base_build:
<<: *base
command: echo done
font_helper:
<<: *base
depends_on: [base_build]
font_helper_tests:
<<: *base
depends_on: [base_build]
command: /bin/bash

View File

@@ -0,0 +1,21 @@
#!/bin/bash
COMMAND=$1
function help() {
echo "Helper to generate font arrays"
echo ""
echo "Usage: $0 read [filename]"
}
if [ ! $COMMAND ]; then
COMMAND="help"
fi
case $COMMAND in
"read")
docker-compose run font_helper /bin/bash -c "echo aaa"
;;
"help")
help
;;
esac

View File

@@ -0,0 +1,10 @@
# frozen_string_literal: true
require 'sinclair'
class FontHelper
autoload :Font, 'font_helper/font'
autoload :Character, 'font_helper/character'
autoload :FontParser, 'font_helper/font_parser'
end

View File

@@ -0,0 +1,19 @@
# frozen_string_literal: true
class FontHelper
class Character
include Sinclair::Comparable
attr_reader :code
comparable_by :code
def initialize(code:)
@code = code
end
def character
code.chr
end
end
end

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
class FontHelper
class Font
attr_reader :width, :height
delegate :<<, to: :characters
def initialize(width:, height:, characters: nil)
@width = width
@height = height
@characters = characters.to_h do |character|
[character.code, character]
end
end
def <<(character)
characters[character.code] = character
end
def characters
@characters ||= {}
end
def quantity
characters.size
end
def character(code)
characters[code]
end
end
end

View File

@@ -0,0 +1,17 @@
# frozen_string_literal: true
require 'spec_helper'
describe FontHelper::Character do
subject(:character) { described_class.new(code:) }
describe '#character' do
context 'when code is a valid character' do
let(:code) { 48 }
it 'returns the character from code' do
expect(character.character).to eq('0')
end
end
end
end

View File

@@ -0,0 +1,54 @@
# frozen_string_literal: true
require 'spec_helper'
describe FontHelper::Font do
subject(:font) { described_class.new(width:, height:, characters:) }
let(:height) { Random.rand(10..30) }
let(:width) { (height * 1.5).to_f }
let(:characters) { build_list(:character, 1) }
let(:character) { build(:character) }
describe '#<<' do
context 'when there are not characters' do
let(:characters) { [] }
it do
expect { font << character }
.to change(font, :quantity)
.from(0).to(1)
end
end
context 'when there is already a character' do
let(:character) { build(:character, code: 50) }
it do
expect { font << character }
.to change(font, :quantity)
.from(1).to(2)
end
it do
expect { font << character }
.to change(font, :quantity)
.from(1).to(2)
end
end
context 'when there is already the same character' do
let(:character) { build(:character) }
it do
expect { font << character }
.not_to change(font, :quantity)
end
it do
expect { font << character }
.to change { font.character(character.code) }
end
end
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
require 'spec_helper'
describe FontHelper do
xit 'does domething'
end

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
lib = File.expand_path('../source', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'simplecov'
SimpleCov.start 'rails'
require 'pry-nav'
require 'factory_bot'
require 'font_helper'
Dir[File.expand_path('spec/support/**/*.rb')].each { |f| require f }
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.shared_context_metadata_behavior = :apply_to_host_groups
config.filter_run_when_matching :focus
end
RSpec::Matchers.define_negated_matcher :not_raise_error, :raise_error
RSpec::Matchers.define_negated_matcher :not_change, :change

View File

@@ -0,0 +1,13 @@
# frozen_string_literal: true
FactoryBot.define do
factory :character, class: FontHelper::Character do
initialize_with do
FontHelper::Character.new(code:)
end
transient do
code { 48 }
end
end
end

View File

@@ -0,0 +1,7 @@
# frozen_string_literal: true
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
FactoryBot.find_definitions