Last active
December 26, 2015 07:09
-
-
Save gam0022/7112650 to your computer and use it in GitHub Desktop.
BundlerでC拡張を含んだgemを公開する ref: http://qiita.com/gam0022/items/2ee82e84e5c9f608eb85
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "mkmf" | |
create_makefile("immutable_list/immutable_list") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle gem immutable_list | |
create immutable_list/Gemfile | |
create immutable_list/Rakefile | |
create immutable_list/LICENSE.txt | |
create immutable_list/README.md | |
create immutable_list/.gitignore | |
create immutable_list/immutable_list.gemspec | |
create immutable_list/lib/immutable_list.rb | |
create immutable_list/lib/immutable_list/version.rb | |
Initializating git repo in /Users/gam0022/git/gem/t/immutable_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ext | |
└── immutable_list | |
├── extconf.rb | |
└── immutable_list.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lib | |
├── immutable_list | |
│ └── version.rb | |
└── immutable_list.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
# Specify your gem's dependencies in immutable_list.gemspec | |
gemspec | |
+gem "rake-compiler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ruby.h> | |
#define true 1 | |
#define false 0 | |
VALUE cImmutableList; | |
struct immutable_list { | |
VALUE value; | |
VALUE next; | |
}; | |
static void | |
immutable_list_mark(struct immutable_list *ptr) | |
{ | |
rb_gc_mark(ptr->value); | |
rb_gc_mark(ptr->next); | |
} | |
// 長すぎるので以下略。気になる人は以下を参照 | |
// https://github.com/gam0022/immutable_list/blob/master/ext/immutable_list/immutable_list.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
lib = File.expand_path('../lib', __FILE__) | |
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | |
require 'immutable_list/version' | |
Gem::Specification.new do |spec| | |
spec.name = "immutable_list" | |
spec.version = ImmutableList::VERSION | |
spec.authors = ["gam0022"] | |
spec.email = ["[email protected]"] | |
- spec.description = %q{TODO: Write a gem description} | |
- spec.summary = %q{TODO: Write a gem summary} | |
+ spec.description = %q{Immutable Linked List implemented in C-Extensions} | |
+ spec.summary = %q{Immutable Linked List implemented in C-Extensions} | |
spec.homepage = "" | |
spec.license = "MIT" | |
+ spec.extensions = %w[ext/immutable_list/extconf.rb] | |
spec.files = `git ls-files`.split($/) | |
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | |
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | |
spec.require_paths = ["lib"] | |
spec.add_development_dependency "bundler", "~> 1.3" | |
spec.add_development_dependency "rake" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "immutable_list/version" | |
+require "immutable_list/immutable_list" | |
-module ImmutableList | |
+class ImmutableList | |
# Your code goes here... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "bundler/gem_tasks" | |
+require "rake/extensiontask" | |
+ | |
+Rake::ExtensionTask.new "immutable_list" do |ext| | |
+ ext.lib_dir = "lib/immutable_list" | |
+end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module ImmutableList | |
+class ImmutableList | |
VERSION = "0.0.1" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment