1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
From 1720f06c024e2e642f9d1b19e0924befc21eb551 Mon Sep 17 00:00:00 2001
From: Lars Kanis <lars.kanis@sincnovation.com>
Date: Wed, 12 Feb 2025 14:56:58 +0100
Subject: [PATCH 03/10] Fix loading of VERSION in gemspec and make it autoload
Fixes:
LoadError: cannot load such file -- C:/ruby-serialport/(eval at C:/ruby-serialport/lib/serialport/version (LoadError)
---
lib/serialport.rb | 5 +++--
lib/serialport/version.rb | 2 +-
serialport.gemspec | 3 ++-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/serialport.rb b/lib/serialport.rb
index 8062770..4b83349 100644
--- a/lib/serialport.rb
+++ b/lib/serialport.rb
@@ -1,5 +1,4 @@
require 'serialport.so'
-require 'serialport/version'
# This class is used for communication over a serial port.
@@ -7,7 +6,9 @@ require 'serialport/version'
#
# @see http://rubydoc.info/stdlib/core/IO Ruby IO class
# @see http://www.cmrr.umn.edu/~strupp/serial.html "Serial Programming Guide for POSIX Operating Systems"
-class SerialPort
+class SerialPort < IO
+ autoload :VERSION, 'serialport/version'
+
private_class_method(:create)
# Creates a serial port object.
diff --git a/lib/serialport/version.rb b/lib/serialport/version.rb
index 718c16c..1919056 100644
--- a/lib/serialport/version.rb
+++ b/lib/serialport/version.rb
@@ -1,3 +1,3 @@
-class SerialPort
+class SerialPort < IO
VERSION = "1.3.2"
end
diff --git a/serialport.gemspec b/serialport.gemspec
index dc574a9..85cd7ec 100644
--- a/serialport.gemspec
+++ b/serialport.gemspec
@@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
-require File.expand_path('../lib/serialport/version', __FILE__)
+$: << "lib"
+require "serialport/version"
Gem::Specification.new do |s|
s.name = "serialport"
--
2.39.5
|