From 8dfb642c843fd787d44fa9f3a18127d8dfc20ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateus=20Cez=C3=A1rio=20Barreto?= Date: Thu, 6 Nov 2025 14:29:33 -0300 Subject: [PATCH] [ Gemspec ] --- bin/{tauth.rb => tauth} | 0 bin/tonton-web | 35 +++++++++++++++++++++++++++++++++ tonton_web.rb => example/app.rb | 3 ++- example/config.ru | 4 ++-- lib/tonton_web.rb | 1 + tonton_web.gemspec | 12 +++++++++++ 6 files changed, 52 insertions(+), 3 deletions(-) rename bin/{tauth.rb => tauth} (100%) create mode 100644 bin/tonton-web rename tonton_web.rb => example/app.rb (84%) create mode 100644 lib/tonton_web.rb create mode 100644 tonton_web.gemspec diff --git a/bin/tauth.rb b/bin/tauth similarity index 100% rename from bin/tauth.rb rename to bin/tauth diff --git a/bin/tonton-web b/bin/tonton-web new file mode 100644 index 0000000..db43b4a --- /dev/null +++ b/bin/tonton-web @@ -0,0 +1,35 @@ +#! /usr/bin/ruby + +require 'sod' + +class New < Sod::Action + on "--new", argument: "NAME" + + def call(name) + destination_root = Pathname.new name + + destination_root.mkdir + + (destination_root+'modules').mkdir + + gem_root = Pathname.new(__FILE__).parent + '..' + + for source in gem_root.glob('{example/*,*.md}') + destination = destination_root + source.basename + + `cp #{source} #{destination}` + end + + (destination_root+'views').mkdir + + `cp -r #{gem_root+'views'} #{destination_root}` + end +end + +cli = Sod.new(banner: "TonTon Web 0.0.0: TonTon utilitary for web apps") do + on(New) + + on Sod::Prefabs::Actions::Help, self +end + +cli.call \ No newline at end of file diff --git a/tonton_web.rb b/example/app.rb similarity index 84% rename from tonton_web.rb rename to example/app.rb index 5c9dd63..e5c6f29 100644 --- a/tonton_web.rb +++ b/example/app.rb @@ -1,8 +1,9 @@ require 'gollum/app' require 'sinatra/flash' require "sqlite3" +require 'tonton_web' -class TonTonWeb < Sinatra::Base +class TonTonWeb::App < Sinatra::Base set :host_authorization, { permitted_hosts: ['localhost', 'mytonton.com.br'] } set :sessions, true diff --git a/example/config.ru b/example/config.ru index 71f8b90..a041fa3 100644 --- a/example/config.ru +++ b/example/config.ru @@ -1,11 +1,11 @@ -require_relative 'tonton_web' +require_relative 'app' # Require TonTon modules if you want use Rack::Session::Cookie, key: 'rack.session', secret: ENV.fetch('SESSION_SECRET') app = Rack::URLMap.new( - '/' => TonTonWeb.new + '/' => TonTonWeb::App.new # Add TonTon modules here ) diff --git a/lib/tonton_web.rb b/lib/tonton_web.rb new file mode 100644 index 0000000..2b4040b --- /dev/null +++ b/lib/tonton_web.rb @@ -0,0 +1 @@ +require_relative 'tonton_web/auth' \ No newline at end of file diff --git a/tonton_web.gemspec b/tonton_web.gemspec new file mode 100644 index 0000000..ebbcbe5 --- /dev/null +++ b/tonton_web.gemspec @@ -0,0 +1,12 @@ +Gem::Specification.new do |s| + s.name = 'tonton_web' + s.version = '0.0.0' + s.summary = 'TonTon Web app main parts' + s.description = 'TonTon Web app main parts' + s.authors = ['Mateus Cezário Barreto'] + s.email = 'mateus.cezario.barreto@gmail.com' + s.homepage = 'https://mytonton.com.br' + s.license = 'MIT' + s.files = Dir.glob('{bin/*,lib/**/*,example/*,*.md,views/*}') + s.files.each { |f| if f.include?('bin/') then s.executables << File.basename(f) end } +end \ No newline at end of file