Compare commits
	
		
			1 Commits
		
	
	
		
			go
			...
			6dd3e4c7d6
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 6dd3e4c7d6 | 
							
								
								
									
										64
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										64
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,8 +1,60 @@
 | 
			
		||||
# ---> Composer
 | 
			
		||||
composer.phar
 | 
			
		||||
/vendor/
 | 
			
		||||
# ---> Ruby
 | 
			
		||||
*.gem
 | 
			
		||||
*.rbc
 | 
			
		||||
/.config
 | 
			
		||||
/coverage/
 | 
			
		||||
/InstalledFiles
 | 
			
		||||
/pkg/
 | 
			
		||||
/spec/reports/
 | 
			
		||||
/spec/examples.txt
 | 
			
		||||
/test/tmp/
 | 
			
		||||
/test/version_tmp/
 | 
			
		||||
/tmp/
 | 
			
		||||
 | 
			
		||||
# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
 | 
			
		||||
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
 | 
			
		||||
# composer.lock
 | 
			
		||||
# Used by dotenv library to load environment variables.
 | 
			
		||||
# .env
 | 
			
		||||
 | 
			
		||||
# Ignore Byebug command history file.
 | 
			
		||||
.byebug_history
 | 
			
		||||
 | 
			
		||||
## Specific to RubyMotion:
 | 
			
		||||
.dat*
 | 
			
		||||
.repl_history
 | 
			
		||||
build/
 | 
			
		||||
*.bridgesupport
 | 
			
		||||
build-iPhoneOS/
 | 
			
		||||
build-iPhoneSimulator/
 | 
			
		||||
 | 
			
		||||
## Specific to RubyMotion (use of CocoaPods):
 | 
			
		||||
#
 | 
			
		||||
# We recommend against adding the Pods directory to your .gitignore. However
 | 
			
		||||
# you should judge for yourself, the pros and cons are mentioned at:
 | 
			
		||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
 | 
			
		||||
#
 | 
			
		||||
# vendor/Pods/
 | 
			
		||||
 | 
			
		||||
## Documentation cache and generated files:
 | 
			
		||||
/.yardoc/
 | 
			
		||||
/_yardoc/
 | 
			
		||||
/doc/
 | 
			
		||||
/rdoc/
 | 
			
		||||
 | 
			
		||||
## Environment normalization:
 | 
			
		||||
/.bundle/
 | 
			
		||||
/vendor/bundle
 | 
			
		||||
/lib/bundler/man/
 | 
			
		||||
 | 
			
		||||
# for a library or gem, you might want to ignore these files since the code is
 | 
			
		||||
# intended to run in multiple environments; otherwise, check them in:
 | 
			
		||||
# Gemfile.lock
 | 
			
		||||
# .ruby-version
 | 
			
		||||
# .ruby-gemset
 | 
			
		||||
 | 
			
		||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
 | 
			
		||||
.rvmrc
 | 
			
		||||
 | 
			
		||||
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
 | 
			
		||||
# .rubocop-https?--*
 | 
			
		||||
 | 
			
		||||
# Local database storage
 | 
			
		||||
data/raven.db
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								Gemfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Gemfile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
source 'https://rubygems.org'
 | 
			
		||||
 | 
			
		||||
gem 'sinatra', '~> 3.0'
 | 
			
		||||
gem 'puma', '~> 6.0'
 | 
			
		||||
 | 
			
		||||
gem 'sequel', '~> 5.63'
 | 
			
		||||
gem 'sqlite3', '~> 1.5'
 | 
			
		||||
							
								
								
									
										32
									
								
								Gemfile.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								Gemfile.lock
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
GEM
 | 
			
		||||
  remote: https://rubygems.org/
 | 
			
		||||
  specs:
 | 
			
		||||
    mustermann (3.0.0)
 | 
			
		||||
      ruby2_keywords (~> 0.0.1)
 | 
			
		||||
    nio4r (2.5.8)
 | 
			
		||||
    puma (6.0.0)
 | 
			
		||||
      nio4r (~> 2.0)
 | 
			
		||||
    rack (2.2.4)
 | 
			
		||||
    rack-protection (3.0.4)
 | 
			
		||||
      rack
 | 
			
		||||
    ruby2_keywords (0.0.5)
 | 
			
		||||
    sequel (5.63.0)
 | 
			
		||||
    sinatra (3.0.4)
 | 
			
		||||
      mustermann (~> 3.0)
 | 
			
		||||
      rack (~> 2.2, >= 2.2.4)
 | 
			
		||||
      rack-protection (= 3.0.4)
 | 
			
		||||
      tilt (~> 2.0)
 | 
			
		||||
    sqlite3 (1.5.4-x64-mingw-ucrt)
 | 
			
		||||
    tilt (2.0.11)
 | 
			
		||||
 | 
			
		||||
PLATFORMS
 | 
			
		||||
  x64-mingw-ucrt
 | 
			
		||||
 | 
			
		||||
DEPENDENCIES
 | 
			
		||||
  puma (~> 6.0)
 | 
			
		||||
  sequel (~> 5.63)
 | 
			
		||||
  sinatra (~> 3.0)
 | 
			
		||||
  sqlite3 (~> 1.5)
 | 
			
		||||
 | 
			
		||||
BUNDLED WITH
 | 
			
		||||
   2.3.7
 | 
			
		||||
							
								
								
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
Copyright (c) <year> <owner> 
 | 
			
		||||
Copyright (c) 2022 Metaunix.net
 | 
			
		||||
 | 
			
		||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								data/defaults.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								data/defaults.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
database:
 | 
			
		||||
  adapter: 'sqlite'
 | 
			
		||||
  database: 'data/raven.db'
 | 
			
		||||
							
								
								
									
										22
									
								
								db/migrations/0001_add_items_table.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								db/migrations/0001_add_items_table.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
Sequel.migration do
 | 
			
		||||
 | 
			
		||||
  up do
 | 
			
		||||
    create_table(:items) do
 | 
			
		||||
      primary_key :id
 | 
			
		||||
      String :name, null: false
 | 
			
		||||
      String :manufacturer
 | 
			
		||||
      String :serial_number
 | 
			
		||||
      String :sku_number
 | 
			
		||||
      String :type
 | 
			
		||||
      String :purchased_from
 | 
			
		||||
      DateTime :purchased_at
 | 
			
		||||
      DateTime :created_at
 | 
			
		||||
      DateTime :updated_at
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  down do
 | 
			
		||||
    drop_table(:items)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										20
									
								
								lib/config.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								lib/config.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
require 'yaml'
 | 
			
		||||
 | 
			
		||||
class Config
 | 
			
		||||
 | 
			
		||||
  def initialize(config_path)
 | 
			
		||||
    @data = YAML::load_file(config_path)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def get(key, depth = 0)
 | 
			
		||||
    bits = key.split('.')
 | 
			
		||||
    value = @data
 | 
			
		||||
 | 
			
		||||
    bits.each do |bit|
 | 
			
		||||
      value = value[bit]
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    return value
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										5
									
								
								lib/models/item.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								lib/models/item.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
class Item < Sequel::Model
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										7
									
								
								lib/routes.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/routes.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
get '/' do
 | 
			
		||||
  items = Item.all
 | 
			
		||||
  erb :index, :locals => {
 | 
			
		||||
    :title => 'Dashboard',
 | 
			
		||||
    :items => items
 | 
			
		||||
  }
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										27
									
								
								raven.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								raven.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
require 'logger'
 | 
			
		||||
require 'sequel'
 | 
			
		||||
require 'sqlite3'
 | 
			
		||||
require 'sinatra'
 | 
			
		||||
 | 
			
		||||
require_relative 'lib/config.rb'
 | 
			
		||||
 | 
			
		||||
set :public_folder, __dir__ + '/public'
 | 
			
		||||
 | 
			
		||||
set :views, settings.root + '/views'
 | 
			
		||||
 | 
			
		||||
# Load configuration file
 | 
			
		||||
conf = Config.new(File.join(__dir__, 'data/defaults.yaml'))
 | 
			
		||||
 | 
			
		||||
# Initialize logging
 | 
			
		||||
logger = Logger.new(STDOUT)
 | 
			
		||||
logger.level = Logger::INFO
 | 
			
		||||
 | 
			
		||||
# Load the Sequel timestamps plugin
 | 
			
		||||
Sequel::Model.plugin :timestamps
 | 
			
		||||
# Initialize Sequel gem for database actions
 | 
			
		||||
DB = Sequel.connect(adapter: conf.get('database.adapter'), database: conf.get('database.database'))
 | 
			
		||||
# Load models
 | 
			
		||||
require_relative 'lib/models/item.rb'
 | 
			
		||||
 | 
			
		||||
# Register route handlers
 | 
			
		||||
require_relative 'lib/routes.rb'
 | 
			
		||||
							
								
								
									
										11
									
								
								views/index.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								views/index.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<p>This is a test.</p>
 | 
			
		||||
 | 
			
		||||
<% if items.length > 0 %>
 | 
			
		||||
  <ul>
 | 
			
		||||
  <% items.each do |item| %>
 | 
			
		||||
    <li><%= item.name %></li>
 | 
			
		||||
  <% end %>
 | 
			
		||||
  </ul>
 | 
			
		||||
<% else %>
 | 
			
		||||
  <p>There are no items to display.</p>
 | 
			
		||||
<% end %>
 | 
			
		||||
							
								
								
									
										13
									
								
								views/layout.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								views/layout.erb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
<head>
 | 
			
		||||
  <meta charset="UTF-8">
 | 
			
		||||
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
 | 
			
		||||
  <title><%= title %> | Raven</title>
 | 
			
		||||
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css">
 | 
			
		||||
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
  <%= yield %>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
		Reference in New Issue
	
	Block a user