Skip to content

Commit

Permalink
Merge pull request #309 from scarpe-team/add_lacci_gem
Browse files Browse the repository at this point in the history
Add lacci gem
  • Loading branch information
noahgibbs authored Jul 14, 2023
2 parents 45738cb + 9af1702 commit fd3d10a
Show file tree
Hide file tree
Showing 66 changed files with 478 additions and 297 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
id: pages
uses: actions/configure-pages@v3
- name: Build with yardoc
run: bundle exec yardoc -o docs
run: rm -r .yardoc doc && bundle exec yardoc -o doc
env:
FAKE_ENV: example
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v1
with:
path: ./docs
path: ./doc

# Deployment job
deploy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ scarpe_results.txt
logger/*.log
/docs/yard/template/default/doc
/docs/yard/template/default/.yardoc
**/lacci-*.gem
4 changes: 3 additions & 1 deletion .yardopts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
--template-path docs/yard/template
--tag incompatibility:"Incompatibilities with Shoes"
--exclude lib/scarpe/libui
-
--exclude lib/scarpe/glibui
lib/**/*.rb
lacci/lib/**/*.rb
-
docs/yard/*.md
docs/static/manual.md

2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source "https://rubygems.org"
# Specify your gem's dependencies in scarpe.gemspec
gemspec

gem "lacci", path: "lacci"

gem "bloops", "~> 0.5" #path: "../bloopsaphone" #git: "https://github.com/scarpe-team/bloopsaphone"
gem "rake", "~> 13.0"

Expand Down
8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Rake::TestTask.new(:test) do |t|
t.test_files = FileList["test/**/test_*.rb"]
end

Rake::TestTask.new(:lacci_test) do |t|
t.libs << "lacci/test"
t.libs << "lacci/lib"
t.test_files = FileList["lacci/test/**/test_*.rb"]
end

RuboCop::RakeTask.new

task default: [:test, :rubocop]
task default: [:test, :lacci_test, :rubocop]
2 changes: 1 addition & 1 deletion exe/scarpe
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def print_env
puts <<~SCARPE_ENV
Scarpe environment:
#{env_or_default("SCARPE_DISPLAY_SERVICE", "(default)wv_local")}
#{env_or_default("SCARPE_LOG_CONFIG", "(default)#{Scarpe::Log::DEFAULT_LOG_CONFIG.inspect}")}
#{env_or_default("SCARPE_LOG_CONFIG", "(default)#{Shoes::Log::DEFAULT_LOG_CONFIG.inspect}")}
#{env_or_none("SCARPE_APP_TEST")}
Scarpe::WV environment:
#{env_or_none("SCARPE_TEST_CONTROL")}
Expand Down
22 changes: 22 additions & 0 deletions lacci/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

source "https://rubygems.org"

gemspec

gem "rake", "~> 13.0"

group :test do
gem "minitest", "~> 5.0"
gem "minitest-reporters"
end

group :development do
gem "yard"
gem "redcarpet"
gem "debug"
gem "rubocop", "~> 1.21"
gem "rubocop-shopify"
#gem "commonmarker"
#gem "github-markup"
end
72 changes: 72 additions & 0 deletions lacci/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
PATH
remote: .
specs:
lacci (0.2.1)

GEM
remote: https://rubygems.org/
specs:
ansi (1.5.0)
ast (2.4.2)
builder (3.2.4)
debug (1.8.0)
irb (>= 1.5.0)
reline (>= 0.3.1)
io-console (0.6.0)
irb (1.7.2)
reline (>= 0.3.6)
json (2.6.3)
language_server-protocol (3.17.0.3)
minitest (5.18.1)
minitest-reporters (1.6.0)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
racc (1.7.1)
rainbow (3.1.1)
rake (13.0.6)
redcarpet (3.6.0)
regexp_parser (2.8.1)
reline (0.3.6)
io-console (~> 0.5)
rexml (3.2.5)
rubocop (1.54.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-shopify (2.14.0)
rubocop (~> 1.51)
ruby-progressbar (1.13.0)
unicode-display_width (2.4.2)
yard (0.9.34)

PLATFORMS
x86_64-darwin-22

DEPENDENCIES
debug
lacci!
minitest (~> 5.0)
minitest-reporters
rake (~> 13.0)
redcarpet
rubocop (~> 1.21)
rubocop-shopify
yard

BUNDLED WITH
2.4.10
12 changes: 12 additions & 0 deletions lacci/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end

task default: [:test]
37 changes: 37 additions & 0 deletions lacci/lacci.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

require_relative "../lib/scarpe/version"

Gem::Specification.new do |spec|
spec.name = "lacci"
spec.version = Scarpe::VERSION
spec.authors = ["Marco Concetto Rudilosso", "Noah Gibbs"]
spec.email = ["marcoc.r@outlook.com", "the.codefolio.guy@gmail.com"]

spec.summary = "Lacci - a portable Shoes DSL with switchable display backends, part of Scarpe"
spec.homepage = "https://github.com/scarpe-team/scarpe"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.2.0"

# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/scarpe-team/scarpe"
spec.metadata["changelog_uri"] = "https://github.com/scarpe-team/scarpe/blob/main/CHANGELOG.md"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject do |f|
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
end
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

#spec.add_dependency ""

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
end
29 changes: 21 additions & 8 deletions lib/shoes.rb → lacci/lib/shoes.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
# frozen_string_literal: true

# We're separating Shoes from Scarpe, a little at a time. This should eventually be requirable
# We're separating Shoes from Scarpe, a little at a time. This should be requirable
# without using Scarpe at all.
#
# This Shoes gem will, if all goes well, be a lot like the old Shoes-core from Shoes4: a way
# The Lacci gem is like the old Shoes-core from Shoes4: a way
# to handle the DSL and command-line parts of Shoes without knowing anything about how the
# display side works at all.

# This will never be triggered -- we use the (...) feature below, which means this
# file won't even parse in old Rubies.
if RUBY_VERSION[0..2] < "3.2"
Scarpe::Logger.logger("Scarpe").error("Scarpe requires Ruby 3.2 or higher!")
Shoes::Log.logger("Shoes").error("Lacci (Scarpe, Shoes) requires Ruby 3.2 or higher!")
exit(-1)
end

module Shoes; end
class Shoes::Error < StandardError; end

require_relative "shoes/constants"
module Kernel
include Shoes::Constants
end

class Shoes::Error < StandardError; end
require_relative "shoes/log"
require_relative "shoes/display_service"
require_relative "shoes/colors"

require_relative "shoes/background"
require_relative "shoes/border"
require_relative "shoes/spacing"

require_relative "shoes/widget"
require_relative "shoes/app"
require_relative "shoes/widgets"

require_relative "shoes/download"

# The module containing Shoes in all its glory.
# Shoes is a platform-independent GUI library, designed to create
Expand All @@ -37,7 +50,7 @@ class << self
# @incompatibility In Shoes3 the parameters were a hash of options, not keyword arguments.
#
# @example Simple one-button app
# Scarpe.app(title: "Button!", width: 200, height: 200) do
# Shoes.app(title: "Button!", width: 200, height: 200) do
# @p = para "Press it NOW!"
# button("clicky") { @p.replace("You pressed it! CELEBRATION!") }
# end
Expand All @@ -49,7 +62,7 @@ class << self
# @return [void]
# @see Shoes::App#new
def app(
title: "Scarpe!",
title: "Shoes!",
width: 480,
height: 420,
resizable: true,
Expand Down
10 changes: 5 additions & 5 deletions lib/shoes/app.rb → lacci/lib/shoes/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Shoes
class App < Shoes::Widget
include Scarpe::Log
include Shoes::Log

class << self
attr_accessor :instance
Expand All @@ -13,7 +13,7 @@ class << self
display_properties :title, :width, :height, :resizable, :debug

def initialize(
title: "Scarpe!",
title: "Shoes!",
width: 480,
height: 420,
resizable: true,
Expand All @@ -34,7 +34,7 @@ def initialize(
super

# This creates the DocumentRoot, including its corresponding display widget
@document_root = Scarpe::DocumentRoot.new
@document_root = Shoes::DocumentRoot.new

@slots = []

Expand All @@ -61,7 +61,7 @@ def initialize(

Signal.trap("INT") do
@log.warning("App interrupted by signal, stopping...")
puts "\nStopping Scarpe app..."
puts "\nStopping Shoes app..."
destroy
end
end
Expand All @@ -74,7 +74,7 @@ def init
end

# "Container" widgets like flows, stacks, masks and the document root
# are considered "slots" in Scarpe parlance. When a new slot is created,
# are considered "slots" in Shoes parlance. When a new slot is created,
# we push it here in order to track what widgets are found in that slot.
def push_slot(slot)
@slots.push(slot)
Expand Down
2 changes: 1 addition & 1 deletion lib/scarpe/background.rb → lacci/lib/shoes/background.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Scarpe
module Shoes
module Background
def self.included(includer)
includer.display_property(:background_color)
Expand Down
2 changes: 1 addition & 1 deletion lib/scarpe/border.rb → lacci/lib/shoes/border.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Scarpe
module Shoes
module Border
def self.included(includer)
includer.display_properties :border_color, :options
Expand Down
2 changes: 1 addition & 1 deletion lib/scarpe/colors.rb → lacci/lib/shoes/colors.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Scarpe
module Shoes
module Colors
COLORS = {
aliceblue: [240, 248, 255],
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

# Scarpe Shoes apps operate in multiple layers. A Shoes widget tree exists as fairly
# Lacci Shoes apps operate in multiple layers. A Shoes widget tree exists as fairly
# plain, simple Ruby objects. And then a display-service widget tree integrates with
# the display technology, initially Webview. This lets us use Ruby as our API while
# not tying it too closely to the limitations of Webview.
# the display technology. This lets us use Ruby as our API while
# not tying it too closely to the limitations of Webview, WASM, LibUI, etc.
#
# ## Choosing Display Services
#
# Before running a Scarpe app, you can set SCARPE_DISPLAY_SERVICE. If you
# Before running a Lacci app, you can set SCARPE_DISPLAY_SERVICE. If you
# set it to "whatever_service", Scarpe will require "scarpe/whatever_service",
# which can be supplied by the Scarpe gem or another Scarpe-based gem.
# Currently leaving the environment variable empty is equivalent to requesting
Expand All @@ -17,7 +17,7 @@
#
# Events are a lot of what tie the Shoes widgets and the display service together.
#
# Scarpe widgets *expect* to operate in a fairly "hands off" mode where they record
# Shoes widgets *expect* to operate in a fairly "hands off" mode where they record
# to an event queue to send to the display service, and the display service records
# events to send back.
#
Expand All @@ -30,7 +30,7 @@ module Shoes
class DisplayService
class << self
# This is in the eigenclass/metaclass, *not* instances of DisplayService
include Scarpe::Log
include Shoes::Log

attr_accessor :json_debug_serialize

Expand Down
2 changes: 1 addition & 1 deletion lib/scarpe/download.rb → lacci/lib/shoes/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def download(url, method: "GET", save: nil, styles: {}, &block)
@block = block

Thread.new do
logger = Scarpe::Logger.logger("Shoes::App#download")
logger = Shoes::Log.logger("Shoes::App#download")
begin
uri = URI(url)
response = perform_request(uri, method, styles)
Expand Down
2 changes: 1 addition & 1 deletion lib/scarpe/fill.rb → lacci/lib/shoes/fill.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class Scarpe
module Shoes
class Fill < Shoes::Widget
display_properties :color

Expand Down
Loading

0 comments on commit fd3d10a

Please sign in to comment.