Skip to content

Commit

Permalink
Expose MRuby source as a gem
Browse files Browse the repository at this point in the history
  • Loading branch information
sagmor committed Sep 1, 2015
1 parent 64d7dec commit 63d2d19
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -20,4 +20,4 @@ cscope.out
/src/y.tab.c
/bin
/build
/lib
/mruby-source-*.gem
2 changes: 2 additions & 0 deletions lib/mruby/source.rb
@@ -0,0 +1,2 @@
require "mruby/source/path"
require "mruby/source/version"
9 changes: 9 additions & 0 deletions lib/mruby/source/path.rb
@@ -0,0 +1,9 @@
require "pathname"

module MRuby
module Source
def self.path
Pathname.new(File.expand_path('../../../../',__FILE__))
end
end
end
13 changes: 13 additions & 0 deletions lib/mruby/source/version.rb
@@ -0,0 +1,13 @@
require "mruby/source/path"

module MRuby
module Source
# Reads a constant defined at version.h
MRUBY_READ_VERSION_CONSTANT = -> (name) { Source.path.join('include','mruby','version.h').read.match(/^#define #{name} "?(\w+)"?$/)[1] }

MRUBY_RELEASE_MAJOR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_MAJOR'])
MRUBY_RELEASE_MINOR = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_MINOR'])
MRUBY_RELEASE_TEENY = Integer(MRUBY_READ_VERSION_CONSTANT['MRUBY_RELEASE_TEENY'])
MRUBY_VERSION = [MRUBY_RELEASE_MAJOR,MRUBY_RELEASE_MINOR,MRUBY_RELEASE_TEENY].join('.')
end
end
18 changes: 18 additions & 0 deletions mruby-source.gemspec
@@ -0,0 +1,18 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'mruby/source/version'

Gem::Specification.new do |spec|
spec.name = "mruby-source"
spec.version = MRuby::Source::MRUBY_VERSION
spec.authors = ["mruby developers"]

spec.summary = %q{MRuby source code wrapper.}
spec.description = %q{MRuby source code wrapper for use with Ruby libs.}
spec.homepage = "http://www.mruby.org/"
spec.license = "MIT"

spec.files = `git ls-files -z`.split("\x0")
spec.require_paths = ["lib"]
end

0 comments on commit 63d2d19

Please sign in to comment.