source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/movie.rb | Ruby | mit | 98 | master | 4,425 | module Tmdb
class Movie < Struct
def self.detail(id, filters={})
result = Resource.new("/movie/#{id}", filters).get
create_new_instance_with_normalized_data(result)
end
def self.alternative_titles(id, filters={})
result = Resource.new("/movie/#{id}/alternative_titles", filters).get
... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/job.rb | Ruby | mit | 98 | master | 204 | module Tmdb
class Job < Struct
def self.list(filters={})
result = Resource.new('/job/list', filters).get
result['jobs'].map do |job|
self.new(job)
end
end
end
end |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/tv/episode.rb | Ruby | mit | 98 | master | 2,683 | module Tmdb
module Tv
class Episode < Struct
def self.detail(id, season_number, episode_number, filters={})
result = Resource.new("/tv/#{id}/season/#{season_number}/episode/#{episode_number}", filters).get
create_new_instance_with_normalized_data(result)
end
def self.changes(i... |
github | 18Months/themoviedb-api | https://github.com/18Months/themoviedb-api | lib/tmdb/tv/season.rb | Ruby | mit | 98 | master | 2,389 | module Tmdb
module Tv
class Season < Struct
def self.detail(id, season_number, filters={})
result = Resource.new("/tv/#{id}/season/#{season_number}", filters).get
create_new_instance_with_normalized_data(result)
end
def self.changes(id, filters={})
result = Resource.ne... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | mcp_on_ruby.gemspec | Ruby | mit | 98 | main | 1,606 | # frozen_string_literal: true
require_relative 'lib/mcp_on_ruby/version'
Gem::Specification.new do |spec|
spec.name = 'mcp_on_ruby'
spec.version = McpOnRuby::VERSION
spec.authors = ['Nagendra Dhanakeerthi']
spec.email = ['nagendra.dhanakeerthi@gmail.com']
spec.summary = 'Production-ready MCP server for Rai... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby.rb | Ruby | mit | 98 | main | 4,359 | # frozen_string_literal: true
require 'logger'
require 'json'
require 'json-schema'
require 'rack'
require 'webrick'
require_relative 'mcp_on_ruby/version'
require_relative 'mcp_on_ruby/errors'
require_relative 'mcp_on_ruby/configuration'
require_relative 'mcp_on_ruby/server'
require_relative 'mcp_on_ruby/tool'
requi... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/tool.rb | Ruby | mit | 98 | main | 4,313 | # frozen_string_literal: true
module McpOnRuby
# Base class for MCP tools - functions that AI can execute
class Tool
attr_reader :name, :description, :input_schema, :metadata, :tags
# Create a new tool
# @param name [String] The tool name
# @param description [String] The tool description
# @p... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/transport.rb | Ruby | mit | 98 | main | 9,675 | # frozen_string_literal: true
module McpOnRuby
module Transport
# Rack middleware for handling MCP requests
class RackMiddleware
def initialize(app, server:, **options)
@app = app
@server = server
@path = options[:path] || @server.configuration.path
@logger = McpOnRuby.l... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/railtie.rb | Ruby | mit | 98 | main | 4,010 | # frozen_string_literal: true
if defined?(Rails)
module McpOnRuby
# Rails integration via Railtie
class Railtie < Rails::Railtie
# Add MCP-specific directories to Rails autoload paths
initializer "mcp_on_ruby.setup_autoload_paths" do |app|
# Add app/tools and app/resources to autoload pat... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/server.rb | Ruby | mit | 98 | main | 11,752 | # frozen_string_literal: true
module McpOnRuby
# Main MCP server class that handles JSON-RPC protocol and manages tools/resources
class Server
attr_reader :tools, :resources, :configuration, :logger
# Initialize a new MCP server
# @param options [Hash] Server configuration options
# @yield [Server... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/resource.rb | Ruby | mit | 98 | main | 5,106 | # frozen_string_literal: true
module McpOnRuby
# Base class for MCP resources - data sources that AI can read
class Resource
attr_reader :uri, :name, :description, :mime_type, :metadata, :tags
# Create a new resource
# @param uri [String] The resource URI (supports templates with {param})
# @param... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/configuration.rb | Ruby | mit | 98 | main | 2,048 | # frozen_string_literal: true
require 'logger'
module McpOnRuby
# Configuration class for MCP server
class Configuration
attr_accessor :log_level,
:path,
:authentication_required,
:authentication_token,
:allowed_origins,
... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/errors.rb | Ruby | mit | 98 | main | 2,115 | # frozen_string_literal: true
module McpOnRuby
# Base error class for MCP-related errors
class Error < StandardError
attr_reader :code, :data
def initialize(message, code: nil, data: nil)
super(message)
@code = code
@data = data
end
# Convert error to JSON-RPC error format
d... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/tool_generator.rb | Ruby | mit | 98 | main | 1,421 | # frozen_string_literal: true
require 'rails/generators'
module McpOnRuby
module Generators
# Generator for creating MCP tools
class ToolGenerator < Rails::Generators::NamedBase
source_root File.expand_path('templates', __dir__)
desc "Generate an MCP tool class"
argument :name, type: :st... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/install_generator.rb | Ruby | mit | 98 | main | 1,309 | # frozen_string_literal: true
require 'rails/generators'
module McpOnRuby
module Generators
# Generator for installing MCP server in Rails application
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
desc "Install MCP server in Rails applicatio... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/resource_generator.rb | Ruby | mit | 98 | main | 1,775 | # frozen_string_literal: true
require 'rails/generators'
module McpOnRuby
module Generators
# Generator for creating MCP resources
class ResourceGenerator < Rails::Generators::NamedBase
source_root File.expand_path('templates', __dir__)
desc "Generate an MCP resource class"
argument :nam... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/application_resource.rb | Ruby | mit | 98 | main | 599 | # frozen_string_literal: true
# Base class for all MCP resources in this application
class ApplicationResource < McpOnRuby::Resource
# Common functionality for all resources can be added here
# Example: Add common authorization logic
# def authorize(context)
# # Check if user is authenticated
# contex... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/resource_spec.rb | Ruby | mit | 98 | main | 1,744 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe <%= resource_class_name %>, type: :model do
subject(:resource) { described_class.new }
describe '#read' do
<% if is_template? -%>
let(:params) { { <%= template_params.map { |p| "'#{p}' => 'test_#{p}'" }.join(', ') %> } }
<% else -%>
... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/sample_tool.rb | Ruby | mit | 98 | main | 1,368 | # frozen_string_literal: true
# Sample tool demonstrating MCP tool creation
class SampleTool < ApplicationTool
def initialize
super(
name: 'sample_tool',
description: 'A sample tool that demonstrates basic functionality',
input_schema: {
type: 'object',
properties: {
m... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/tool_spec.rb | Ruby | mit | 98 | main | 1,458 | # frozen_string_literal: true
require 'rails_helper'
RSpec.describe <%= tool_class_name %>, type: :model do
subject(:tool) { described_class.new }
describe '#execute' do
let(:arguments) { {} }
let(:context) { { remote_ip: '127.0.0.1' } }
it 'executes successfully' do
result = tool.call(argumen... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/application_tool.rb | Ruby | mit | 98 | main | 530 | # frozen_string_literal: true
# Base class for all MCP tools in this application
class ApplicationTool < McpOnRuby::Tool
# Common functionality for all tools can be added here
# Example: Add common authorization logic
# def authorize(context)
# # Check if user is authenticated
# context[:authenticated... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/tool.rb | Ruby | mit | 98 | main | 902 | # frozen_string_literal: true
# <%= tool_description %>
class <%= tool_class_name %> < ApplicationTool
def initialize
super(
name: '<%= tool_name %>',
description: '<%= tool_description %>',
<%= input_schema_code %>,
metadata: {
category: 'custom',
version: '1.0.0'
}... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/resource.rb | Ruby | mit | 98 | main | 1,279 | # frozen_string_literal: true
# <%= resource_description %>
class <%= resource_class_name %> < ApplicationResource
def initialize
super(
uri: '<%= resource_uri %>',
name: '<%= name.humanize %>',
description: '<%= resource_description %>',
mime_type: '<%= resource_mime_type %>',
meta... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/sample_resource.rb | Ruby | mit | 98 | main | 1,387 | # frozen_string_literal: true
# Sample resource demonstrating MCP resource creation
class SampleResource < ApplicationResource
def initialize
super(
uri: 'sample_data',
name: 'Sample Data',
description: 'A sample resource that provides application statistics',
mime_type: 'application/json... |
github | rubyonai/mcp_on_ruby | https://github.com/rubyonai/mcp_on_ruby | lib/mcp_on_ruby/generators/templates/initializer.rb | Ruby | mit | 98 | main | 1,172 | # MCP on Ruby configuration
McpOnRuby.configure do |config|
# Logging level
config.log_level = Rails.logger.level
# MCP endpoint path
config.path = '/mcp'
# Authentication (set to true for production)
config.authentication_required = false
config.authentication_token = ENV['MCP_AUTH_TOKEN']
# S... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | laser-cutter.gemspec | Ruby | mit | 98 | master | 1,419 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'laser-cutter/version'
Gem::Specification.new do |spec|
spec.name = "laser-cutter"
spec.version = Laser::Cutter::VERSION
spec.authors = ['Konstantin Gredeskoul']
spec.... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/spec_helper.rb | Ruby | mit | 98 | master | 1,068 | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
ENV['... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/dimensions_spec.rb | Ruby | mit | 98 | master | 680 | require 'spec_helper'
module Laser
module Cutter
module Geometry
describe Dimensions do
let(:dim1) { Dimensions.new(20, 10, 50) }
context 'creation' do
context 'from string' do
let(:dim2) { Dimensions.new "20x10x50" }
it 'should instantiate correctly from ... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/rect_spec.rb | Ruby | mit | 98 | master | 1,923 | require 'spec_helper'
module Laser
module Cutter
module Geometry
describe Rect do
let(:p1) { Point[ 1.0, 3.0] }
let(:p2) { Point[11.0, 23.0] }
let(:rect1) { Rect.new(p1, p2) }
context 'creating' do
it 'creates from a class method' do
expect(Rect[p1, ... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/line_spec.rb | Ruby | mit | 98 | master | 3,639 | require 'spec_helper'
module Laser
module Cutter
module Geometry
describe Line do
let(:p1) { Point.new(1, 1) }
let(:p2) { Point.new(7, 11) }
let(:center) { Point.new((7 + 1) / 2, (11 + 1) / 2) }
let(:line) { Line.new(p1, p2) }
context '#center' do
it 'shou... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/renderer_spec.rb | Ruby | mit | 98 | master | 2,376 | require 'spec_helper'
module Laser
module Cutter
module Renderer
describe LayoutRenderer do
context '#render' do
let(:renderer) { LayoutRenderer.new(config) }
let(:file) { File.expand_path("../../laser-cutter-pdf-test.#{$$}.pdf", __FILE__) }
def render_file filename
... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/path_generator_spec.rb | Ruby | mit | 98 | master | 2,952 | require 'spec_helper'
module Laser
module Cutter
module Notching
describe PathGenerator do
let(:notch) { 2 }
let(:thickness) { 1 }
let(:center_out) { true }
let(:corners) { true }
let(:options) { {notch_width: notch,
thickness: thickness,
... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/edge_spec.rb | Ruby | mit | 98 | master | 1,602 | require 'spec_helper'
module Laser
module Cutter
describe "Notching::Edge" do
context 'left vertical side' do
let(:notch_width) { 2 }
let(:inside) { Geometry::Line.new(Geometry::Point[1, 1], Geometry::Point[1, 9])}
let(:outside) { Geometry::Line.new(Geometry::Point[0, 0], Geometry... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/aggregator_spec.rb | Ruby | mit | 98 | master | 2,044 | require 'spec_helper'
module Laser
module Cutter
describe Aggregator do
let(:p1) { Geometry::Point[0, 0] }
let(:p2) { Geometry::Point[2, 0] }
let(:p3) { Geometry::Point[5, 0] }
let(:p4) { Geometry::Point[10, 0] }
let(:p5) { Geometry::Point[0, 12] }
let(:l1) { Geometry::Lin... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/point_spec.rb | Ruby | mit | 98 | master | 2,127 | require 'spec_helper'
module Laser
module Cutter
module Geometry
describe Point do
let(:p1) { Point.new(1, 2) }
context 'creation' do
context 'from string' do
it 'should instantiate correctly' do
expect(Point.new "1,2").to eql(p1)
end
... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/page_manager_spec.rb | Ruby | mit | 98 | master | 1,522 | require 'spec_helper'
module Laser
module Cutter
describe PageManager do
let(:pm) { Laser::Cutter::PageManager.new(units) }
context 'a single value' do
context 'to inches' do
let(:units) { 'in' }
it 'should be correct' do
expect(pm.value_from_units(150)).to be... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/configuration_spec.rb | Ruby | mit | 98 | master | 2,984 | require 'spec_helper'
module Laser
module Cutter
describe Configuration do
let(:config) { Laser::Cutter::Configuration.new(opts) }
context 'option parsing' do
let(:opts) { { 'box' => '2x3x2/0.125/0.5' } }
it 'should be able to parse size options' do
expect(config.width).to ... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | spec/lib/box_spec.rb | Ruby | mit | 98 | master | 1,218 | require 'spec_helper'
module Laser
module Cutter
describe Box do
let(:config) { {'width' => 50, 'height' => 60, 'depth' => 70, 'margin' => 5, 'padding' => 3, 'units' => 'mm'} }
let(:box1) { Box.new(config.merge('thickness' => 6, 'notch' => 10)) }
let(:box2) { Box.new(config.merge('thickness' =>... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter.rb | Ruby | mit | 98 | master | 356 | require 'laser-cutter/version'
require 'laser-cutter/configuration'
require 'laser-cutter/geometry'
require 'laser-cutter/box'
require 'laser-cutter/renderer'
require 'laser-cutter/page_manager'
require 'laser-cutter/notching'
require 'laser-cutter/aggregator'
require 'prawn'
require 'prawn/measurement_extensions'
mod... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/page_manager.rb | Ruby | mit | 98 | master | 1,184 | require 'hashie/mash'
require 'prawn/measurement_extensions'
require 'pdf/core/page_geometry'
class Laser::Cutter::PageManager < Struct.new(:units)
SIZES = PDF::Core::PageGeometry::SIZES.clone.freeze
def all_page_sizes
output = ""
page_size_values.each do |k|
output << sprintf("\t%10s:\t%6.1f x %6.1... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer.rb | Ruby | mit | 98 | master | 337 | module Laser
module Cutter
module Renderer
end
end
end
require 'laser-cutter/renderer/base'
require 'laser-cutter/renderer/line_renderer'
require 'laser-cutter/renderer/rect_renderer'
require 'laser-cutter/renderer/box_renderer'
require 'laser-cutter/renderer/meta_renderer'
require 'laser-cutter/renderer/... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry.rb | Ruby | mit | 98 | master | 225 | module Laser
module Cutter
module Geometry
end
end
end
require 'laser-cutter/geometry/tuple'
require 'laser-cutter/geometry/dimensions'
require 'laser-cutter/geometry/point'
require 'laser-cutter/geometry/shape' |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/box.rb | Ruby | mit | 98 | master | 6,487 | module Laser
module Cutter
# Note: this class badly needs refactoring and tests. Both are coming.
class Box
# Everything is in millimeters
attr_accessor :dim, :thickness, :notch_width, :kerf
attr_accessor :padding, :units, :inside_box
attr_accessor :front, :back, :top, :bottom, :le... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/configuration.rb | Ruby | mit | 98 | master | 3,075 | require 'hashie/mash'
require 'hashie/extensions/symbolize_keys'
require 'hashie/extensions/mash/symbolize_keys'
require 'prawn/measurement_extensions'
require 'pdf/core/page_geometry'
module Laser
module Cutter
class MissingOption < RuntimeError; end
class ZeroValueNotAllowed < MissingOption; end
clas... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/aggregator.rb | Ruby | mit | 98 | master | 1,420 | module Laser
module Cutter
class Aggregator
attr_accessor :lines
def initialize(array_of_lines = [])
self.lines = array_of_lines.sort
end
# This method finds lines that are identical (same p1/p2)
def dedup!
lines_to_delete = []
count = lines.size
for... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry/tuple.rb | Ruby | mit | 98 | master | 2,929 | module Laser
module Cutter
module Geometry
class Tuple
attr_accessor :coords
PRECISION = 0.000001
def initialize(*args)
x = args.first
coordinates = if x.is_a?(String)
parse_string(x)
elsif x.is_a?(Hash)
parse_hash(x)
e... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry/shape.rb | Ruby | mit | 98 | master | 733 | module Laser
module Cutter
module Geometry
class Shape
attr_accessor :position, :name
def position
@position ||= Point.new(0, 0)
end
def x= value
position.x = value
end
def x
position.x
end
def y= value
... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry/dimensions.rb | Ruby | mit | 98 | master | 367 | module Laser
module Cutter
module Geometry
class Dimensions < Tuple
def w
coords.[](0)
end
def h
coords.[](1)
end
def d
coords.[](2)
end
def separator
'x'
end
def hash_keys
[:w, :h,... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry/shape/rect.rb | Ruby | mit | 98 | master | 1,193 | module Laser
module Cutter
module Geometry
class Rect < Line
attr_accessor :sides, :vertices
def self.[] p1, p2
Rect.new(p1, p2)
end
def self.create(point, w, h, name = nil)
r = Rect.new(point, Point[point.x + w, point.y + h])
r.name = name
... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/geometry/shape/line.rb | Ruby | mit | 98 | master | 2,706 | module Laser
module Cutter
module Geometry
class Line < Shape
def self.[] *array
self.new *array
end
attr_accessor :p1, :p2
def initialize(point1, point2 = nil)
if point1.is_a?(Hash)
options = point1
self.p1 = Point.new(options[:... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/rect_renderer.rb | Ruby | mit | 98 | master | 286 | module Laser
module Cutter
module Renderer
class RectRenderer < Base
alias_method :rect, :subject
def render pdf
rect.sides.each do |side|
LineRenderer.new(config, side).render(pdf)
end
end
end
end
end
end |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/box_renderer.rb | Ruby | mit | 98 | master | 949 | # encoding: utf-8
require 'json'
module Laser
module Cutter
module Renderer
class BoxRenderer < Base
alias_method :box, :subject
def initialize(config)
super(config)
self.subject = Laser::Cutter::Box.new(config)
end
def ensure_space_for(rect)
c... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/layout_renderer.rb | Ruby | mit | 98 | master | 1,786 | # encoding: utf-8
require 'json'
module Laser
module Cutter
module Renderer
class LayoutRenderer < Base
def initialize(config)
self.config = config
super(config)
end
def render
renderer = self
renderers = []
box_renderer = BoxRender... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/meta_renderer.rb | Ruby | mit | 98 | master | 2,563 | # encoding: utf-8
class Laser::Cutter::Renderer::MetaRenderer < Laser::Cutter::Renderer::Base
META_KEYS = %i(units width height depth thickness notch kerf stroke padding margin page_size page_layout)
def initialize(config = {})
self.config = config
self.enclosure = Laser::Cutter::Geometry::Rect.create(Las... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/base.rb | Ruby | mit | 98 | master | 720 | module Laser
module Cutter
module Renderer
# subject is what we are rendering
# enclosure is the rectangle enclosing our subject's rendered image
# page_manager contains access to units and page sizes
class Base
BLACK = "000000"
BLUE = "0070E0"
attr_accessor :confi... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/renderer/line_renderer.rb | Ruby | mit | 98 | master | 404 | module Laser
module Cutter
module Renderer
class LineRenderer < Base
alias_method :line, :subject
def render pdf = nil
pdf.stroke { pdf.line [line.p1.x, line.p1.y].map{ |p| p.send(units) },
[line.p2.x, line.p2.y].map{ |p| p.send(units) }}
end... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/notching/edge.rb | Ruby | mit | 98 | master | 2,750 | module Laser
module Cutter
module Notching
MINIMUM_NOTCHES_PER_SIDE = 3
# This class represents a single edge of one side: both inside
# and outside edge of the material. It's also responsible
# for calculating the "perfect" notch width.
class Edge
attr_accessor :outside, :... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/notching/path_generator.rb | Ruby | mit | 98 | master | 8,515 | require 'forwardable'
module Laser
module Cutter
module Notching
class Shift < Struct.new(:delta, :direction, :dim_index)
def next_point_after point
p = point.clone
shift = []
shift[dim_index] = delta * direction
shift[(dim_index + 1) % 2] = 0
p.plus... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/cli/opt_parser.rb | Ruby | mit | 98 | master | 6,156 | require 'optparse'
require 'colored2'
require 'json'
require 'hashie/mash'
require 'laser-cutter'
require_relative 'serializer'
module Laser
module Cutter
module CLI
class OptParser
def self.puts_error(e)
STDERR.puts "Whoops, #{e}".red
STDERR.puts 'Try --help or --examples for m... |
github | kigster/laser-cutter | https://github.com/kigster/laser-cutter | lib/laser-cutter/cli/serializer.rb | Ruby | mit | 98 | master | 1,433 | require 'json'
require 'laser-cutter'
module Laser
module Cutter
module CLI
class Serializer
attr_accessor :options
def initialize(options = {})
self.options = options
end
def deserialize
string = if options.read_file.eql?('-')
$stdi... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | heapinfo.gemspec | Ruby | mit | 98 | master | 1,510 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'date'
require 'heapinfo/version'
Gem::Specification.new do |s|
s.name = 'heapinfo'
s.version = ::HeapInfo::VERSION
s.date = Date.today.to_s
s.summary = 'HeapInfo - interactive heap ex... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | Rakefile | Ruby | mit | 98 | master | 375 | require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'
task default: %i[rubocop spec]
RuboCop::RakeTask.new(:rubocop) do |task|
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
end
RSpec::Core::RakeTask.new(:spec)
YARD::Rake::YardocTask.new(:doc) do |t|
t.files = ['... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/chunk_spec.rb | Ruby | mit | 98 | master | 1,618 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/chunk'
describe HeapInfo::Chunk do
describe '32bit' do
before(:all) do
@fast = [0, 0x47, 0x1337].pack('L*').to_chunk(bits: 32)
@small = [0, 0x48, 0xabcdef].pack('L*').to_chunk(bits: 32)
end
it 'basic' do
expect(@fas... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/nil_spec.rb | Ruby | mit | 98 | master | 496 | # frozen_string_literal: true
require 'heapinfo/nil'
describe HeapInfo::Nil do
before(:all) do
@nil = HeapInfo::Nil.instance
end
it 'nil?' do
expect(@nil.nil?).to be true
end
it 'nil chain' do
expect(@nil.xdd.oao.no_method).to be @nil
end
it 'puts' do
expect(puts(@nil)).to be nil
end
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/cache_spec.rb | Ruby | mit | 98 | master | 1,457 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/cache'
describe HeapInfo::Cache do
before(:all) do
@prefix = 'testcx1dd/'
end
after(:each) do
FileUtils.rm_rf File.join(HeapInfo::Cache::CACHE_DIR, @prefix)
end
it 'handle unwritable' do
org = HeapInfo::Cache::CACHE_DIR
H... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/spec_helper.rb | Ruby | mit | 98 | master | 2,011 | # frozen_string_literal: true
require 'English'
require 'simplecov'
require 'timeout'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[SimpleCov::Formatter::HTMLFormatter]
)
SimpleCov.start do
add_filter '/spec/'
end
require 'heapinfo/helper'
RSpec.configure do |config|
module Victims
@vi... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/chunks_spec.rb | Ruby | mit | 98 | master | 624 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/chunks'
describe HeapInfo::Chunks do
before(:each) do
@chunks = HeapInfo::Chunks.new
3.times { |i| @chunks << i }
end
it '<<' do
expect(@chunks.size).to be 3
@chunks << ("\x00" * 16).to_chunk
expect(@chunks.size).to be 4
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/process_spec.rb | Ruby | mit | 98 | master | 6,496 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'open3'
require 'heapinfo'
require 'heapinfo/helper'
require 'heapinfo/process'
describe HeapInfo::Process do
describe 'self' do
before(:all) do
@prog = File.readlink('/proc/self/exe')
@h = described_class.new(@prog)
@h.instance_var... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/helper_spec.rb | Ruby | mit | 98 | master | 4,857 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/helper'
describe HeapInfo::Helper do
describe 'unpack' do
it '32bit' do
expect(HeapInfo::Helper.unpack(4, "\x15\xCD\x5b\x07")).to eq 123_456_789
end
it '64bit' do
expect(HeapInfo::Helper.unpack(8, "\xEF\xCD\xAB\xEF\xBE\xA... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/dumper_spec.rb | Ruby | mit | 98 | master | 3,381 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/dumper'
describe HeapInfo::Dumper do
before(:all) do
@get_block = lambda do |base|
methods = {
elf: HeapInfo::Segment.new(base, 'elf'),
bits: 64
}
methods[:segments] = { elf: methods[:elf] }
->(sym) { ... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/string_spec.rb | Ruby | mit | 98 | master | 569 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/ext/string'
describe String do
it 'to_chunk' do
chunk = "\x00\x00\x00\x00\x00\x00\x00\x00g\x00\x00\x00\x00\x00\x00\x00".to_chunk
expect(chunk.class).to be HeapInfo::Chunk
expect(chunk.size).to be 0x60
expect(chunk.flags).to eq %i... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/full_test/tcache_spec.rb | Ruby | mit | 98 | master | 1,975 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo'
describe 'tcache libraries' do
describe '64bit' do
before(:all) do
HeapInfo::Cache.clear_all # force cache miss, to ensure coverage
@hs = @tcache_libs_heapinfo.call(64)
end
it 'main_arena' do
@hs.each do |h|
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | spec/full_test/bin_operation_spec.rb | Ruby | mit | 98 | master | 4,730 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo'
describe "Bin's operation" do
describe 'common' do
before(:all) do
HeapInfo::Cache.clear_all # force cache miss, to ensure coverage
@hs = @old_libs_heapinfo.call(64) + @old_libs_heapinfo.call(32)
end
it 'main_arena' do
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo.rb | Ruby | mit | 98 | master | 2,191 | # frozen_string_literal: true
# Basic requirements from standard library
require 'fileutils'
require 'heapinfo/ext/string.rb'
require 'heapinfo/process'
# HeapInfo - an interactive debugger for heap exploitation
#
# HeapInfo makes pwning life easier with ruby style memory dumper.
# Easy to show bin(s) layouts, or du... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/chunk.rb | Ruby | mit | 98 | master | 3,956 | # frozen_string_literal: true
require 'heapinfo/helper'
module HeapInfo
# The object of a heap chunk
class Chunk
# @return [Integer] 4 or 8 according to 32bit or 64bit, respectively.
attr_reader :size_t
# @return [Integer] previous chunk size
attr_reader :prev_size
# @return [String] chunk dat... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/tcache.rb | Ruby | mit | 98 | master | 1,348 | # frozen_string_literal: true
require 'heapinfo/arena'
module HeapInfo
# Fetch tcache structure and show its content.
class Tcache
# #define TCACHE_MAX_BINS 64
MAX_BINS = 64
# Instantiate a {HeapInfo::Tcache} object.
#
# @param [Integer] base Base address of +tcache+.
# @param [Integer] si... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/segment.rb | Ruby | mit | 98 | master | 1,915 | # frozen_string_literal: true
require 'heapinfo/helper'
require 'heapinfo/nil'
module HeapInfo
# Record the base address and name in maps
class Segment
# Base address of segment
attr_reader :base
# Name of segment
attr_reader :name
# Instantiate a {HeapInfo::Segment} object
# @param [Integ... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/process_info.rb | Ruby | mit | 98 | master | 3,573 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'stringio'
require 'heapinfo/segment'
require 'heapinfo/libc'
require 'heapinfo/helper'
module HeapInfo
# For {Process} to record basic process information.
#
# {Process} has a +process_info+ object iff the process exists (pid not +nil+).
# Mainly ... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/helper.rb | Ruby | mit | 98 | master | 6,388 | # frozen_string_literal: true
require 'dentaku'
require 'shellwords'
require 'time'
require 'tmpdir'
module HeapInfo
# Some helper functions.
module Helper
module_function
# @!macro proc_content_doc
# @param [Integer] pid The process id.
# @return [String] The file content.
# @!method aux... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/libc.rb | Ruby | mit | 98 | master | 3,072 | # frozen_string_literal: true
require 'fileutils'
require 'json'
require 'heapinfo/arena'
require 'heapinfo/cache'
require 'heapinfo/glibc/glibc'
require 'heapinfo/helper'
require 'heapinfo/segment'
require 'heapinfo/tcache'
module HeapInfo
# Record libc's base, name, and offsets.
class Libc < Segment
includ... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/chunks.rb | Ruby | mit | 98 | master | 568 | # frozen_string_literal: true
module HeapInfo
# Self-defined array for collecting chunk(s).
class Chunks
include Enumerable
# Instantiate a {HeapInfo::Chunks} object.
def initialize
@chunks = []
end
# @return [void]
def <<(val)
@chunks << val
end
# @return [Integer]
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/nil.rb | Ruby | mit | 98 | master | 1,109 | # frozen_string_literal: true
require 'singleton'
module HeapInfo
# Self define a +nil+ like class.
#
# Can be the return value of {HeapInfo::Process#dump} and {HeapInfo::Process#dump_chunks},
# to prevent use the return value for calculating accidentally while exploiting remote.
class Nil
include Singl... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/process.rb | Ruby | mit | 98 | master | 12,729 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/dumper'
require 'heapinfo/helper'
require 'heapinfo/nil'
require 'heapinfo/process_info'
module HeapInfo
# Main class of heapinfo.
class Process
# The default options of libraries,
# use for matching glibc segments in +/proc/[pid]/maps... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/cache.rb | Ruby | mit | 98 | master | 2,330 | # frozen_string_literal: true
require 'digest'
require 'fileutils'
module HeapInfo
# Self implment file-base cache manager.
#
# Values are recorded in files based on +Marshal+.
module Cache
# Directory for caching files.
# e.g. HeapInfo will record main_arena_offset for glibc(s).
CACHE_DIR = File.... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/dumper.rb | Ruby | mit | 98 | master | 7,599 | # encoding: ascii-8bit
# frozen_string_literal: true
require 'heapinfo/helper'
require 'heapinfo/nil'
module HeapInfo
# @api private
#
# Class for memory dump relation works
class Dumper
# Default dump length
DUMP_BYTES = 8
# Instantiate a {HeapInfo::Dumper} object
#
# @param [String] mem... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/arena.rb | Ruby | mit | 98 | master | 7,632 | # frozen_string_literal: true
require 'heapinfo/chunk'
require 'heapinfo/helper'
module HeapInfo
# Records status of an arena, including bin(s) and top chunk.
class Arena
# @return [Array<HeapInfo::Fastbin>] Fastbins in an array.
attr_reader :fastbin
# @return [HeapInfo::Chunk] Current top chunk.
... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/glibc/glibc.rb | Ruby | mit | 98 | master | 215 | # frozen_string_literal: true
module HeapInfo
# To define heap-related functions in glibc.
module Glibc
attr_accessor :size_t
private
attr_accessor :main_arena
attr_accessor :dumper
end
end |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | lib/heapinfo/ext/string.rb | Ruby | mit | 98 | master | 1,432 | # frozen_string_literal: true
require 'heapinfo/chunk'
require 'heapinfo/chunks'
module HeapInfo
# Define extensions of naive objects.
module Ext
# Extension of +String+ class.
module String
# Methods to be mixed into String
module InstanceMethods
# Convert string to a {HeapInfo::Chunk... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | examples/uaf/uaf.rb | Ruby | mit | 98 | master | 804 | #!/usr/bin/env ruby
# encoding: ascii-8bit
require 'heapinfo'
require 'socket'
$HOST = ''
$PORT = 12_345
$local = false
($HOST = '0'; $local = true) if ARGV.empty?
z = TCPSocket.new $HOST, $PORT
h = heapinfo('uaf')
# ==================== Exploit Start ==================== #
z.puts 1 # new Benz
h.debug do
puts forma... |
github | david942j/heapinfo | https://github.com/david942j/heapinfo | examples/fastbin/fastbin.rb | Ruby | mit | 98 | master | 1,383 | #!/usr/bin/env ruby
# encoding: ascii-8bit
require 'pry'
require 'socket'
require 'heapinfo'
def p64(a)
[a].pack('Q*')
end
def u64(a)
a.ljust(8, "\x00").unpack('Q*')[0]
end
# *- end of default code
$HOST = ''
$PORT = 12_345
$local = false
($HOST = '0'; $local = true) if ARGV.empty?
$z = z = TCPSocket.new $HOST, ... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | material_design_lite-sass.gemspec | Ruby | mit | 98 | master | 1,303 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'material_design_lite/sass/version'
Gem::Specification.new do |spec|
spec.name = 'material_design_lite-sass'
spec.version = MaterialDesignLite::Sass::VERSION
spec.authors ... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | spec/spec_helper.rb | Ruby | mit | 98 | master | 495 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../support/dummy_rails_app/config/environment.rb', __FILE__)
require 'material_design_lite-sass'
RSpec.configure do |config|
config.before(:suite) do
gem_path = File.expand_path('..', File.dirname(__... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | spec/material_design_lite/rails_app_spec.rb | Ruby | mit | 98 | master | 1,088 | require 'spec_helper'
describe 'Rails app', rails: true do
it 'adds stylesheet files' do
expect(Rails.application.assets.find_asset('custom'))
.to be_instance_of(Sprockets::Asset)
end
it 'adds javascript file' do
expect(Rails.application.assets.find_asset('material'))
.to be_instance_of(Spro... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | spec/material_design_lite/sass_compilation_spec.rb | Ruby | mit | 98 | master | 523 | require 'spec_helper'
RSpec.describe 'Sass compilation' do
it 'compiles scss to css' do
path = 'vendor/assets/stylesheets'
file = '_material'
sass_engine = Sass::Engine.for_file(
"#{path}/#{file}.scss",
cache_location: 'tmp/.sass-cache',
load_pa... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | spec/support/dummy_rails_app/config/application.rb | Ruby | mit | 98 | master | 266 | require File.expand_path('../boot', __FILE__)
require 'rails'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'
require 'material_design_lite-sass'
module DummyRailsApp
class Application < Rails::Application
end
end |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | spec/support/dummy_rails_app/config/environments/test.rb | Ruby | mit | 98 | master | 1,792 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | lib/material_design_lite-sass.rb | Ruby | mit | 98 | master | 1,124 | module MaterialDesignLite
module Sass
class << self
def load!
if defined?(::Rails)
register_rails_engine
elsif defined?(::Sprockets)
register_sprockets
end
configure_sass
end
def gem_path
@gem_path ||= File.expand_path('..', File.dirn... |
github | rubysamurai/material_design_lite-sass | https://github.com/rubysamurai/material_design_lite-sass | lib/material_design_lite/sass/engine.rb | Ruby | mit | 98 | master | 705 | module MaterialDesignLite
module Sass
module Rails
class Engine < ::Rails::Engine
initializer 'material_design_lite-sass.assets.precompile' do |app|
%w(stylesheets javascripts fonts images).each do |sub|
app.config.assets.paths << root.join('vendor/assets', sub).to_s
... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | readme.rb | Ruby | mit | 98 | master | 2,093 | # README code is extracted from this file (pagination code excepted).
require 'rubygems'
require 'lib/relaxdb'
RelaxDB.configure :host => "localhost", :port => 5984, :design_doc => "app" #, :logger => Logger.new(STDOUT)
RelaxDB.delete_db "relaxdb_scratch" rescue :ok
RelaxDB.use_db "relaxdb_scratch"
RelaxDB.enable_vie... |
github | paulcarey/relaxdb | https://github.com/paulcarey/relaxdb | Rakefile | Ruby | mit | 98 | master | 1,426 | require 'rubygems'
require 'rake/gempackagetask'
require 'spec/rake/spectask'
PLUGIN = "relaxdb"
NAME = "relaxdb"
GEM_VERSION = "0.5.3"
AUTHOR = "Paul Carey"
EMAIL = "paul.p.carey@gmail.com"
HOMEPAGE = "http://github.com/paulcarey/relaxdb/"
SUMMARY = "RelaxDB provides a simple interface to CouchDB"
spec = Gem::Specif... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.