shall 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/Rakefile +10 -0
- data/ext/shall/extconf.rb +13 -0
- data/ext/shall/shall.c +105 -0
- data/lib/shall.rb +5 -0
- data/shall.gemspec +20 -0
- metadata +65 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fde77d9beda6dc8225d9bb7973e572155070862f
|
4
|
+
data.tar.gz: be37dbe2ae0bc237afcb6d252427745d5e788c46
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1d936fda5cc8771e2af3c8e7ce45429b0e94f46d3a34fae17b26e7343cc55505089db9ea9e1b3802cea8bd4cd29393931b13953020ef75c05abc02d18a0d3814
|
7
|
+
data.tar.gz: c012a0aae9229bc37bb4b9d36d5ea551f499f45ba8f610a47738c7cb4d895df24a486fad34044fae9fc17bea54dbc92d1ef2b7ba1d2800efa35b3c6b35ad46c6
|
data/Gemfile
ADDED
data/Rakefile
ADDED
data/ext/shall/shall.c
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#include <ruby.h>
|
2
|
+
|
3
|
+
#include "shall.h"
|
4
|
+
|
5
|
+
static VALUE cLexer, cFormatter;
|
6
|
+
|
7
|
+
typedef struct {
|
8
|
+
Lexer *lexer;
|
9
|
+
} rb_lexer_object;
|
10
|
+
|
11
|
+
#define WRAP_LEXER(/*rb_lexer_object **/ input) \
|
12
|
+
Data_Wrap_Struct(cLexer, rb_lexer_mark, rb_lexer_free, input)
|
13
|
+
|
14
|
+
#define UNWRAP_LEXER(/*VALUE*/ input, /**/ output) \
|
15
|
+
Data_Get_Struct(input, rb_lexer_object, output)
|
16
|
+
|
17
|
+
static void rb_lexer_free(rb_lexer_object *o)
|
18
|
+
{
|
19
|
+
xfree(o);
|
20
|
+
}
|
21
|
+
|
22
|
+
static void rb_lexer_mark(rb_lexer_object *o)
|
23
|
+
{
|
24
|
+
// NOP (for now)
|
25
|
+
}
|
26
|
+
|
27
|
+
static VALUE rb_lexer_by_name(VALUE klass, VALUE name)
|
28
|
+
{
|
29
|
+
Lexer *lexer;
|
30
|
+
rb_lexer_object *o;
|
31
|
+
|
32
|
+
Check_Type(name, T_STRING);
|
33
|
+
if (NULL == (lexer = lexer_by_name(StringValueCStr(name)))) {
|
34
|
+
//raise?
|
35
|
+
return Qnil;
|
36
|
+
} else {
|
37
|
+
o = ALLOC(rb_lexer_object);
|
38
|
+
o->lexer = lexer;
|
39
|
+
|
40
|
+
return WRAP_LEXER(o);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
static VALUE rb_lexer_name(VALUE self)
|
45
|
+
{
|
46
|
+
rb_lexer_object *o;
|
47
|
+
|
48
|
+
UNWRAP_LEXER(self, o);
|
49
|
+
return rb_str_new_cstr(lexer_name(o->lexer));
|
50
|
+
}
|
51
|
+
|
52
|
+
static void ary_push_string_cb(const char *string, void *data)
|
53
|
+
{
|
54
|
+
rb_ary_push((VALUE) data, rb_str_new_cstr(string));
|
55
|
+
}
|
56
|
+
|
57
|
+
static VALUE rb_lexer_aliases(VALUE self)
|
58
|
+
{
|
59
|
+
VALUE ret;
|
60
|
+
rb_lexer_object *o;
|
61
|
+
|
62
|
+
UNWRAP_LEXER(self, o);
|
63
|
+
ret = rb_ary_new();
|
64
|
+
lexer_each_alias(o->lexer, ary_push_string_cb, (void *) ret);
|
65
|
+
|
66
|
+
return ret;
|
67
|
+
}
|
68
|
+
|
69
|
+
static VALUE rb_lexer_mimetypes(VALUE self)
|
70
|
+
{
|
71
|
+
VALUE ret;
|
72
|
+
rb_lexer_object *o;
|
73
|
+
|
74
|
+
UNWRAP_LEXER(self, o);
|
75
|
+
ret = rb_ary_new();
|
76
|
+
lexer_each_mimetype(o->lexer, ary_push_string_cb, (void *) ret);
|
77
|
+
|
78
|
+
return ret;
|
79
|
+
}
|
80
|
+
|
81
|
+
void Init_shall(void)
|
82
|
+
{
|
83
|
+
VALUE mShall;
|
84
|
+
|
85
|
+
mShall = rb_define_module("Shall");
|
86
|
+
|
87
|
+
{
|
88
|
+
VALUE lexers;
|
89
|
+
|
90
|
+
lexers = rb_ary_new();
|
91
|
+
lexer_each(ary_push_string_cb, (void *) lexers);
|
92
|
+
rb_define_const(mShall, "KNOWN_LEXERS", lexers);
|
93
|
+
}
|
94
|
+
|
95
|
+
// Lexer
|
96
|
+
cLexer = rb_define_class_under(mShall, "Lexer", rb_cObject);
|
97
|
+
// class methods
|
98
|
+
rb_define_singleton_method(cLexer, "lexer_by_name", rb_lexer_by_name, 1);
|
99
|
+
// instance methods
|
100
|
+
rb_define_method(cLexer, "name", rb_lexer_name, 0); // turn into IVAR? (@name)
|
101
|
+
rb_define_method(cLexer, "aliases", rb_lexer_aliases, 0);
|
102
|
+
rb_define_method(cLexer, "mimetypes", rb_lexer_mimetypes, 0);
|
103
|
+
|
104
|
+
// cFormatter = rb_define_class_under(mShall, "Formatter", rb_cObject);
|
105
|
+
}
|
data/lib/shall.rb
ADDED
data/shall.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'shall'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'shall'
|
8
|
+
s.version = Shall::VERSION
|
9
|
+
s.homepage = 'https://github.com/julp/shall'
|
10
|
+
s.summary = 'Ruby bindings for Shall, a syntax highlighter'
|
11
|
+
s.authors = ['julp']
|
12
|
+
s.platform = Gem::Platform::RUBY
|
13
|
+
s.bindir = 'bin'
|
14
|
+
s.extensions = %w[ext/shall/extconf.rb]
|
15
|
+
s.files = Dir.glob ['Rakefile', 'Gemfile', 'shall.gemspec', 'lib/**/*.rb', 'ext/**/*.[ch]']
|
16
|
+
s.required_ruby_version = '>= 2.0.0'
|
17
|
+
s.license = 'BSD'
|
18
|
+
# s.require_paths = %w[lib ext]
|
19
|
+
s.add_development_dependency 'rake-compiler'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shall
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- julp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake-compiler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
extensions:
|
31
|
+
- ext/shall/extconf.rb
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Rakefile
|
36
|
+
- ext/shall/extconf.rb
|
37
|
+
- ext/shall/shall.c
|
38
|
+
- lib/shall.rb
|
39
|
+
- shall.gemspec
|
40
|
+
homepage: https://github.com/julp/shall
|
41
|
+
licenses:
|
42
|
+
- BSD
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.0
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.4.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Ruby bindings for Shall, a syntax highlighter
|
64
|
+
test_files: []
|
65
|
+
has_rdoc:
|