Comments (8)
How about this?
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
index befa7aeff5..a3dc425245 100644
--- a/ext/fiddle/fiddle.gemspec
+++ b/ext/fiddle/fiddle.gemspec
@@ -1,18 +1,12 @@
# frozen_string_literal: true
-source_version = ["", "ext/fiddle/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}lib/fiddle/version.rb")) {|f|
- f.gets("\n VERSION = ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
+unless defined?(Fiddle::VERSION)
+ require_relative "lib/fiddle/version"
end
Gem::Specification.new do |spec|
spec.name = "fiddle"
- spec.version = source_version
+ spec.version = Fiddle::VERSION
spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
spec.email = ["[email protected]", "[email protected]"]
from fiddle.
I confirmed that this suppresses the warning reported by make test-all TESTS="../ruby/test/ruby/test_gc_compact.rb ../ruby/test/ruby/test_default_gems.rb"
. (../ruby
is the source directory.)
from fiddle.
Looks good!
from fiddle.
Ah. You should notice that it may use a wrong version if require "fiddle"
is done before loading gemspec. I guess that manual extraction of the version is dirty but more robust. I leave it up to you.
from fiddle.
I'm not sure that it's caused in real world...
How about this?
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
index befa7aeff5..cd9960f3ea 100644
--- a/ext/fiddle/fiddle.gemspec
+++ b/ext/fiddle/fiddle.gemspec
@@ -1,18 +1,13 @@
# frozen_string_literal: true
-source_version = ["", "ext/fiddle/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}lib/fiddle/version.rb")) {|f|
- f.gets("\n VERSION = ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
+if defined?(Fiddle::VERSION)
+ Fiddle.__send__(:remove_const, :VERSION)
end
+require_relative "lib/fiddle/version"
Gem::Specification.new do |spec|
spec.name = "fiddle"
- spec.version = source_version
+ spec.version = Fiddle::VERSION
spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
spec.email = ["[email protected]", "[email protected]"]
from fiddle.
Or:
diff --git a/ext/fiddle/fiddle.gemspec b/ext/fiddle/fiddle.gemspec
index befa7aeff5..a6c8c9be00 100644
--- a/ext/fiddle/fiddle.gemspec
+++ b/ext/fiddle/fiddle.gemspec
@@ -1,18 +1,13 @@
# frozen_string_literal: true
-source_version = ["", "ext/fiddle/"].find do |dir|
- begin
- break File.open(File.join(__dir__, "#{dir}lib/fiddle/version.rb")) {|f|
- f.gets("\n VERSION = ")
- f.gets[/\s*"(.+)"/, 1]
- }
- rescue Errno::ENOENT
- end
+version_module = Module.new do
+ version_rb = File.join(__dir__, "lib/fiddle/version.rb")
+ module_eval(File.read(version_rb), version_rb)
end
Gem::Specification.new do |spec|
spec.name = "fiddle"
- spec.version = source_version
+ spec.version = version_module::Fiddle::VERSION
spec.authors = ["Aaron Patterson", "SHIBATA Hiroshi"]
spec.email = ["[email protected]", "[email protected]"]
from fiddle.
I'm okay for any solution including your first one! I just let you be aware of the potential risk.
from fiddle.
OK. I'll use the last one.
from fiddle.
Related Issues (20)
- parse_ctype() fails for "int long len" HOT 1
- Ruby test suite failures with libffi-3.4.2 HOT 15
- Pseudoclasses via ruby-fiddle?
- JRuby support HOT 2
- Raspberry Pi Cannot Update to 1.1.0 HOT 2
- Can't open linker script files HOT 4
- How to pass struct as argument of function HOT 5
- Unreachable code path in Fiddle::ValueUtil#wrap_arg HOT 5
- Fiddle::CParser should expose module methods HOT 3
- If the nested structure is an array of structures HOT 2
- No bool type HOT 7
- Support for Bit Field HOT 4
- Segfault when exiting due to `Fiddle::MemoryView` HOT 3
- struct implement memoryview HOT 1
- Installation of fiddle failing on Ruby 2.7.3 HOT 4
- Debug support in fiddle? HOT 2
- Question: How to allocate an array of structs? HOT 4
- Question: When passing a char as a function argument, should I pass the number obtained by calling the string's ord method? HOT 4
- Segfault when calling `dlopen` on certain Qt frameworks HOT 4
- NetWkstaGetInfo() always fails with INVALID PARAMETER HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiddle.