ruby-uriparser 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3680a4b234ef77f02e5369d22a23279c068cc20d
4
+ data.tar.gz: bb7396a7b8e6722707ab1e1b2eaca53cf3792e62
5
+ SHA512:
6
+ metadata.gz: dbaa748e0db6df1c3d0c17c8dd7c1324ddee2b597731103dad64ee437d3d43d36da727e0341443267e46174e5bbfa04dbe9e7157db137e672aa610ef2671fb2a
7
+ data.tar.gz: 4d49444f58aa5da71b1c3ab80c38504bc0aae7eb62a946c6ca0c7a77638faa6cbfa050f3e7c1f2b67d79fc1bb311c7335d2bac1bee7cb38fa812d2dc6db94623
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Thiago Lewin - http://github.com/tlewin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # ruby-uriparser
2
+
3
+ Ruby-uriparser is a wrapper for [uriparser](http://uriparser.sourceforge.net/) C library which is fast (linear input length time complexity), approximatelly 7.5x faster than the standard ruby URI library with a low memory consumption.
4
+
5
+ It is a fairly reasonable hypothesis to consider that __all__ Ruby Rack applications will call, at least once, the `URI.parse` method for each http request, so this simple optimization can bring a significant impact on a high load environment. (See Benchmark)
6
+
7
+ ## Usage
8
+
9
+ require 'uriparser'
10
+
11
+ UriParser.parse('https://localhost:9000/path/?a=1#x') # return UriParser::URI object
12
+
13
+ If you want to override the URI class just include the following line in your code:
14
+
15
+ # Will override URI#parse and Kernel#URI methods
16
+ require 'uriparser/uri_gem'
17
+
18
+ ## Benchmark
19
+
20
+ The following numbers were computed for 10,000 `URI.parse` calls using the ruby benchmark library in a Mac OS X (10.8.5)/ 2.9Ghz Intel Core I5/ 8GB 1600 MHz DDR3 machine:
21
+
22
+ Rehearsal ----------------------------------------------
23
+ URI 0.080000 0.000000 0.080000 ( 0.075157)
24
+ UriParser 0.010000 0.000000 0.010000 ( 0.009013)
25
+ ------------------------------------- total: 0.090000sec
26
+
27
+ user system total real
28
+ URI 0.070000 0.000000 0.070000 ( 0.073731)
29
+ UriParser 0.000000 0.000000 0.000000 ( 0.006310)
30
+
31
+ ## Installation
32
+
33
+ gem install ruby-uriparser
34
+
35
+ ## External dependencies
36
+
37
+ The ruby-uriparser gems needs the library [uriparser](http://uriparser.sourceforge.net/) installed to compile.
38
+
39
+ See the availables ports list: [http://uriparser.sourceforge.net/#ports]().
40
+
41
+ If you are on Mac OS X just run `brew install uriparser`.
42
+
43
+ ## License
44
+
45
+ This project is released under the MIT license (See LICENSE file).
46
+
47
+ Copyright (c) 2014 Thiago Lewin - http://github.com/tlewin
48
+
49
+ ## Third party libraries
50
+
51
+ This project includes code from the New BSD licensed:
52
+ * Copyright (C) 2007, Weijia Song <songweijia@gmail.com>
53
+ * Copyright (C) 2007, Sebastian Pipping <webmaster@hartwork.org>
54
+
55
+ All rights reserved.
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rake/extensiontask'
2
+
3
+ Rake::ExtensionTask.new('uriparser_ext')
@@ -0,0 +1,23 @@
1
+ require 'benchmark'
2
+ require 'uri'
3
+
4
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+
6
+ require 'uriparser'
7
+
8
+
9
+ n = ARGV[0] ? ARGV[0].to_i : 10_000
10
+
11
+ Benchmark.bmbm(10) do |x|
12
+ puts 'Complex URLs'
13
+ x.report('URI') {n.times {URI.parse('https://www.ruby-lang.org/en/?a=1#test')}}
14
+ x.report('UriParser') {n.times {UriParser.parse('https://www.ruby-lang.org/en/?a=1#test')}}
15
+ end
16
+
17
+ puts '#' * 20
18
+
19
+ Benchmark.bmbm(10) do |x|
20
+ puts 'Simple URLs'
21
+ x.report('URI') {n.times {URI('https://www.ruby-lang.org/en/')}}
22
+ x.report('UriParser') {n.times {UriParser.parse('https://www.ruby-lang.org/en/')}}
23
+ end
@@ -0,0 +1,9 @@
1
+ require 'mkmf'
2
+ require 'rbconfig'
3
+
4
+ unless have_library('uriparser')
5
+ error 'You need to install uriparser lib'
6
+ exit
7
+ end
8
+
9
+ create_makefile 'uriparser_ext'
@@ -0,0 +1,214 @@
1
+ #include <stdio.h>
2
+ #include <ruby.h>
3
+ #include <uriparser/Uri.h>
4
+
5
+ #define URI_TEXT_RANGE(uri_ptr, uri_field) ((uri_ptr->uri_field.afterLast == uri_ptr->uri_field.first) ? Qnil : \
6
+ rb_str_new(uri_ptr->uri_field.first, uri_ptr->uri_field.afterLast - uri_ptr->uri_field.first))
7
+
8
+ #define RB_URIPARSER_ATTR_READER(attribute, original) \
9
+ static VALUE \
10
+ rb_uriparser_get_##attribute(VALUE self) \
11
+ { \
12
+ struct uri_data *data; \
13
+ \
14
+ /* lazy load */ \
15
+ Data_Get_Struct(self, struct uri_data, data); \
16
+ if(RB_TYPE_P(data->attribute, T_UNDEF)) { \
17
+ if(data->uri) { \
18
+ data->attribute = URI_TEXT_RANGE(data->uri, original); \
19
+ } else { \
20
+ data->attribute = Qnil; \
21
+ } \
22
+ } \
23
+ \
24
+ return data->attribute; \
25
+ }
26
+
27
+ #define RB_URIPARSER_ATTR_WRITER(attribute) \
28
+ static VALUE \
29
+ rb_uriparser_set_##attribute(VALUE self, VALUE attribute) \
30
+ { \
31
+ VALUE old; \
32
+ struct uri_data *data; \
33
+ \
34
+ Data_Get_Struct(self, struct uri_data, data); \
35
+ old = data->attribute; \
36
+ data->attribute = StringValue(attribute); \
37
+ rb_gc_mark(old); \
38
+ return data->attribute; \
39
+ }
40
+
41
+ #define RB_URIPARSER_ATTR_ACCESSOR(attribute, original) \
42
+ RB_URIPARSER_ATTR_READER(attribute, original); \
43
+ RB_URIPARSER_ATTR_WRITER(attribute);
44
+
45
+ /* Parser structure reused across requests */
46
+ static UriParserStateA uri_parse_state;
47
+ static VALUE rb_mUriParser;
48
+ static VALUE rb_cUri_Class;
49
+
50
+ struct uri_data {
51
+ UriUriA *uri; /* Parsed URI data */
52
+ VALUE scheme;
53
+ VALUE userinfo;
54
+ VALUE password;
55
+ VALUE host;
56
+ VALUE str_port;
57
+ VALUE path;
58
+ VALUE query;
59
+ VALUE opaque;
60
+ VALUE registry;
61
+ VALUE fragment;
62
+ };
63
+
64
+ static void
65
+ rb_uriparser_mark(void *p)
66
+ {
67
+ struct uri_data *ptr = p;
68
+
69
+ if (ptr) {
70
+ rb_gc_mark(ptr->scheme);
71
+ rb_gc_mark(ptr->userinfo);
72
+ rb_gc_mark(ptr->password);
73
+ rb_gc_mark(ptr->host);
74
+ rb_gc_mark(ptr->str_port);
75
+ rb_gc_mark(ptr->path);
76
+ rb_gc_mark(ptr->query);
77
+ rb_gc_mark(ptr->opaque);
78
+ rb_gc_mark(ptr->registry);
79
+ rb_gc_mark(ptr->fragment);
80
+ }
81
+ }
82
+
83
+ static void
84
+ rb_uriparser_free(void *p)
85
+ {
86
+ struct uri_data *ptr = p;
87
+
88
+ if(ptr) {
89
+ uriFreeUriMembersA(ptr->uri);
90
+ xfree(ptr->uri);
91
+ xfree(ptr);
92
+ }
93
+ }
94
+
95
+ static VALUE
96
+ rb_uriparser_s_allocate(VALUE klass)
97
+ {
98
+ struct uri_data *data = ALLOC(struct uri_data);
99
+
100
+ if(data) {
101
+ data->uri = NULL;
102
+ data->scheme = Qundef;
103
+ data->userinfo = Qundef;
104
+ data->password = Qundef;
105
+ data->host = Qundef;
106
+ data->str_port = Qundef;
107
+ data->path = Qundef;
108
+ data->query = Qundef;
109
+ data->opaque = Qundef;
110
+ data->registry = Qundef;
111
+ data->fragment = Qundef;
112
+ } else {
113
+ rb_raise(rb_eRuntimeError, "unable to create UriParser::Generic class");
114
+ }
115
+
116
+ return Data_Wrap_Struct(klass, rb_uriparser_mark, rb_uriparser_free, data);
117
+ }
118
+
119
+ static VALUE
120
+ rb_uriparser_s_parse(VALUE klass, VALUE uri_obj)
121
+ {
122
+ char *uri_str = StringValueCStr(uri_obj);
123
+ UriUriA *uri = ALLOC(UriUriA);
124
+ struct uri_data *data;
125
+ VALUE generic_uri;
126
+
127
+ generic_uri = rb_class_new_instance(0, NULL, rb_cUri_Class);
128
+ Data_Get_Struct(generic_uri, struct uri_data, data);
129
+
130
+ data->uri = uri;
131
+ uri_parse_state.uri = uri;
132
+ if(uriParseUriA(&uri_parse_state, uri_str) != URI_SUCCESS) {
133
+ rb_raise(rb_eStandardError, "unable to parse the URI");
134
+ }
135
+
136
+ return generic_uri;
137
+ }
138
+
139
+ static VALUE
140
+ rb_uriparser_initialize(VALUE self)
141
+ {
142
+ return self;
143
+ }
144
+
145
+ RB_URIPARSER_ATTR_ACCESSOR(scheme, scheme);
146
+ RB_URIPARSER_ATTR_ACCESSOR(userinfo, userInfo);
147
+ RB_URIPARSER_ATTR_ACCESSOR(host, hostText);
148
+ RB_URIPARSER_ATTR_ACCESSOR(str_port, portText);
149
+ RB_URIPARSER_ATTR_ACCESSOR(query, query);
150
+ RB_URIPARSER_ATTR_ACCESSOR(fragment, fragment);
151
+ RB_URIPARSER_ATTR_WRITER(path);
152
+
153
+ static VALUE
154
+ rb_uriparser_get_path(VALUE self)
155
+ {
156
+ struct uri_data *data;
157
+
158
+ /* lazy load */
159
+ Data_Get_Struct(self, struct uri_data, data);
160
+ if(RB_TYPE_P(data->path, T_UNDEF)) {
161
+ if(data->uri) {
162
+ if(data->uri->pathHead) {
163
+ /* starts with slash */
164
+ UriPathSegmentA *path_segment = data->uri->pathHead;
165
+ data->path = rb_str_new("/", 1);
166
+ do { /* go through the linked list */
167
+ /* check if there is a slash to add */
168
+ if(*path_segment->text.afterLast == '/') {
169
+ rb_str_cat(data->path, path_segment->text.first,
170
+ path_segment->text.afterLast - path_segment->text.first + 1);
171
+ } else {
172
+ rb_str_cat(data->path, path_segment->text.first,
173
+ path_segment->text.afterLast - path_segment->text.first);
174
+ }
175
+ path_segment = path_segment->next;
176
+ } while(path_segment);
177
+ } else {
178
+ data->path = rb_str_new("", 0);
179
+ }
180
+ } else {
181
+ data->path = Qnil;
182
+ }
183
+ }
184
+
185
+ return data->path;
186
+ }
187
+
188
+ void
189
+ Init_uriparser_ext()
190
+ {
191
+ rb_mUriParser = rb_define_module("UriParser");
192
+ rb_cUri_Class = rb_define_class_under(rb_mUriParser, "URI", rb_cObject);
193
+
194
+ rb_define_alloc_func(rb_cUri_Class, rb_uriparser_s_allocate);
195
+ rb_define_method(rb_cUri_Class, "initialize", rb_uriparser_initialize, 0);
196
+ rb_define_method(rb_cUri_Class, "scheme", rb_uriparser_get_scheme, 0);
197
+ rb_define_method(rb_cUri_Class, "scheme=", rb_uriparser_set_scheme, 1);
198
+ rb_define_method(rb_cUri_Class, "userinfo", rb_uriparser_get_userinfo, 0);
199
+ rb_define_method(rb_cUri_Class, "userinfo=", rb_uriparser_set_userinfo, 1);
200
+ rb_define_method(rb_cUri_Class, "host", rb_uriparser_get_host, 0);
201
+ rb_define_method(rb_cUri_Class, "host=", rb_uriparser_set_host, 1);
202
+ rb_define_method(rb_cUri_Class, "str_port", rb_uriparser_get_str_port, 0);
203
+ rb_define_method(rb_cUri_Class, "str_port=", rb_uriparser_set_str_port, 1);
204
+ rb_define_method(rb_cUri_Class, "path", rb_uriparser_get_path, 0);
205
+ rb_define_method(rb_cUri_Class, "path=", rb_uriparser_set_path, 1);
206
+ rb_define_method(rb_cUri_Class, "query", rb_uriparser_get_query, 0);
207
+ rb_define_method(rb_cUri_Class, "query=", rb_uriparser_set_query, 1);
208
+ rb_define_method(rb_cUri_Class, "fragment", rb_uriparser_get_fragment, 0);
209
+ rb_define_method(rb_cUri_Class, "fragment=", rb_uriparser_set_fragment, 1);
210
+
211
+ /* TODO: include opaque and registry methods */
212
+
213
+ rb_define_singleton_method(rb_mUriParser, "parse", rb_uriparser_s_parse, 1);
214
+ }
data/lib/uriparser.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'uriparser_ext'
2
+
3
+ module UriParser
4
+ class URI
5
+ def port
6
+ @port ||= if str_port.nil?
7
+ nil
8
+ else
9
+ str_port.to_i
10
+ end
11
+ end
12
+
13
+ def port=value
14
+ @port = value.to_i
15
+ str_port = value
16
+ end
17
+
18
+ def user
19
+ userinfo.split(':').first
20
+ end
21
+
22
+ def password
23
+ userinfo.split(':')[1]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'uri'
2
+ require 'uriparser'
3
+
4
+ # wrapper the ruby URI class
5
+ module URI
6
+ def self.parser uri
7
+ UriParser.parse(uri)
8
+ end
9
+ end
10
+
11
+ module Kernel
12
+ def URI(uri)
13
+ UriParser.parse(uri)
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module UriParser
2
+ VERSION = '0.1.1'
3
+ end
Binary file
Binary file
@@ -0,0 +1,17 @@
1
+ require './lib/uriparser/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'ruby-uriparser'
5
+ s.version = UriParser::VERSION
6
+ s.date = Time.now
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ['Thiago Lewin']
9
+ s.email = ['thiago_lewin@yahoo.com.br']
10
+ s.homepage = 'https://github.com/tlewin/ruby-uriparser'
11
+ s.summary = 'Ruby wrapper for uriparser C library'
12
+ s.description = s.summary
13
+ s.require_paths = ['lib']
14
+ s.files = Dir['**/*'] - ['ruby-uriparser-0.0.1.gem']
15
+ s.extensions = ["ext/uriparser_ext/extconf.rb"]
16
+ s.license = 'MIT'
17
+ end
@@ -0,0 +1,238 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ ECHO1 = $(V:1=@:)
9
+ ECHO = $(ECHO1:0=@echo)
10
+
11
+ #### Start of system configuration section. ####
12
+
13
+ srcdir = ../../../../ext/uriparser_ext
14
+ topdir = /Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0
15
+ hdrdir = $(topdir)
16
+ arch_hdrdir = /Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin12.3.0
17
+ PATH_SEPARATOR = :
18
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
19
+ prefix = /Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247
20
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
21
+ rubyarchprefix = $(rubylibprefix)/$(arch)
22
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
23
+ exec_prefix = $(prefix)
24
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
25
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
26
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
27
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
28
+ sitehdrdir = $(rubyhdrdir)/site_ruby
29
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
30
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
31
+ vendorlibdir = $(vendordir)/$(ruby_version)
32
+ vendordir = $(rubylibprefix)/vendor_ruby
33
+ sitearchdir = $(sitelibdir)/$(sitearch)
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ sitedir = $(rubylibprefix)/site_ruby
36
+ rubyarchdir = $(rubylibdir)/$(arch)
37
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
38
+ sitearchincludedir = $(includedir)/$(sitearch)
39
+ archincludedir = $(includedir)/$(arch)
40
+ sitearchlibdir = $(libdir)/$(sitearch)
41
+ archlibdir = $(libdir)/$(arch)
42
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
43
+ mandir = $(datarootdir)/man
44
+ localedir = $(datarootdir)/locale
45
+ libdir = $(exec_prefix)/lib
46
+ psdir = $(docdir)
47
+ pdfdir = $(docdir)
48
+ dvidir = $(docdir)
49
+ htmldir = $(docdir)
50
+ infodir = $(datarootdir)/info
51
+ docdir = $(datarootdir)/doc/$(PACKAGE)
52
+ oldincludedir = /usr/include
53
+ includedir = $(prefix)/include
54
+ localstatedir = $(prefix)/var
55
+ sharedstatedir = $(prefix)/com
56
+ sysconfdir = $(DESTDIR)/etc
57
+ datadir = $(datarootdir)
58
+ datarootdir = $(prefix)/share
59
+ libexecdir = $(exec_prefix)/libexec
60
+ sbindir = $(exec_prefix)/sbin
61
+ bindir = $(exec_prefix)/bin
62
+ archdir = $(rubyarchdir)
63
+
64
+
65
+ CC = /usr/bin/clang
66
+ CXX = clang++
67
+ LIBRUBY = $(LIBRUBY_A)
68
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
69
+ LIBRUBYARG_SHARED =
70
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
71
+ empty =
72
+ OUTFLAG = -o $(empty)
73
+ COUTFLAG = -o $(empty)
74
+
75
+ RUBY_EXTCONF_H =
76
+ cflags = $(optflags) $(debugflags) $(warnflags)
77
+ optflags = -O3 -fno-fast-math
78
+ debugflags = -ggdb3
79
+ warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration
80
+ CCDLFLAGS = -fno-common
81
+ CFLAGS = $(CCDLFLAGS) -O3 -I/Users/mpapis/.sm/pkg/active/include -fPIC -pipe $(ARCH_FLAG)
82
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
83
+ DEFS =
84
+ CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
85
+ CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG)
86
+ ldflags = -L. -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector
87
+ dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress
88
+ ARCH_FLAG = -arch x86_64
89
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
90
+ LDSHARED = $(CC) -dynamic -bundle
91
+ LDSHAREDXX = $(CXX) -dynamic -bundle
92
+ AR = ar
93
+ EXEEXT =
94
+
95
+ RUBY_INSTALL_NAME = ruby
96
+ RUBY_SO_NAME = ruby
97
+ RUBYW_INSTALL_NAME =
98
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
99
+ RUBYW_BASE_NAME = rubyw
100
+ RUBY_BASE_NAME = ruby
101
+
102
+ arch = x86_64-darwin12.3.0
103
+ sitearch = $(arch)
104
+ ruby_version = 2.0.0
105
+ ruby = $(bindir)/ruby
106
+ RUBY = $(ruby)
107
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/defines.h $(arch_hdrdir)/ruby/config.h
108
+
109
+ RM = rm -f
110
+ RM_RF = $(RUBY) -run -e rm -- -rf
111
+ RMDIRS = rmdir -p
112
+ MAKEDIRS = mkdir -p
113
+ INSTALL = /usr/bin/install
114
+ INSTALL_PROG = $(INSTALL) -m 0755
115
+ INSTALL_DATA = $(INSTALL) -m 644
116
+ COPY = cp
117
+ TOUCH = exit >
118
+
119
+ #### End of system configuration section. ####
120
+
121
+ preload =
122
+
123
+ libpath = . $(libdir)
124
+ LIBPATH = -L. -L$(libdir)
125
+ DEFFILE =
126
+
127
+ CLEANFILES = mkmf.log
128
+ DISTCLEANFILES =
129
+ DISTCLEANDIRS =
130
+
131
+ extout =
132
+ extout_prefix =
133
+ target_prefix =
134
+ LOCAL_LIBS =
135
+ LIBS = -luriparser -lpthread -ldl -lobjc
136
+ ORIG_SRCS = uriparser.c
137
+ SRCS = $(ORIG_SRCS)
138
+ OBJS = uriparser.o
139
+ HDRS =
140
+ TARGET = uriparser_ext
141
+ TARGET_NAME = uriparser_ext
142
+ TARGET_ENTRY = Init_$(TARGET_NAME)
143
+ DLLIB = $(TARGET).bundle
144
+ EXTSTATIC =
145
+ STATIC_LIB =
146
+
147
+ BINDIR = $(DESTDIR)$(bindir)
148
+ RUBYCOMMONDIR = $(DESTDIR)$(sitedir)$(target_prefix)
149
+ RUBYLIBDIR = $(DESTDIR)$(sitelibdir)$(target_prefix)
150
+ RUBYARCHDIR = $(DESTDIR)$(sitearchdir)$(target_prefix)
151
+ HDRDIR = $(DESTDIR)$(rubyhdrdir)/ruby$(target_prefix)
152
+ ARCHHDRDIR = $(DESTDIR)$(rubyhdrdir)/$(arch)/ruby$(target_prefix)
153
+
154
+ TARGET_SO = $(DLLIB)
155
+ CLEANLIBS = $(TARGET).bundle
156
+ CLEANOBJS = *.o *.bak
157
+
158
+ all: $(DLLIB)
159
+ static: $(STATIC_LIB)
160
+ .PHONY: all install static install-so install-rb
161
+ .PHONY: clean clean-so clean-static clean-rb
162
+
163
+ clean-static::
164
+ clean-rb-default::
165
+ clean-rb::
166
+ clean-so::
167
+ clean: clean-so clean-static clean-rb-default clean-rb
168
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
169
+
170
+ distclean-rb-default::
171
+ distclean-rb::
172
+ distclean-so::
173
+ distclean-static::
174
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
175
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
176
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
177
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
178
+
179
+ realclean: distclean
180
+ install: install-so install-rb
181
+
182
+ install-so: $(DLLIB) ./.RUBYARCHDIR.time
183
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
184
+ clean-static::
185
+ -$(Q)$(RM) $(STATIC_LIB)
186
+ install-rb: pre-install-rb install-rb-default
187
+ install-rb-default: pre-install-rb-default
188
+ pre-install-rb: Makefile
189
+ pre-install-rb-default: Makefile
190
+ pre-install-rb-default:
191
+ $(ECHO) installing default uriparser_ext libraries
192
+ ./.RUBYARCHDIR.time:
193
+ $(Q) $(MAKEDIRS) $(RUBYARCHDIR)
194
+ $(Q) $(TOUCH) $@
195
+
196
+ site-install: site-install-so site-install-rb
197
+ site-install-so: install-so
198
+ site-install-rb: install-rb
199
+
200
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .C .o
201
+
202
+ .cc.o:
203
+ $(ECHO) compiling $(<)
204
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
205
+
206
+ .mm.o:
207
+ $(ECHO) compiling $(<)
208
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
209
+
210
+ .cxx.o:
211
+ $(ECHO) compiling $(<)
212
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
213
+
214
+ .cpp.o:
215
+ $(ECHO) compiling $(<)
216
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
217
+
218
+ .C.o:
219
+ $(ECHO) compiling $(<)
220
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $<
221
+
222
+ .c.o:
223
+ $(ECHO) compiling $(<)
224
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
225
+
226
+ .m.o:
227
+ $(ECHO) compiling $(<)
228
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $<
229
+
230
+ $(DLLIB): $(OBJS) Makefile
231
+ $(ECHO) linking shared-object $(DLLIB)
232
+ -$(Q)$(RM) $(@)
233
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
234
+ $(Q) test -z '$(RUBY_CODESIGN)' || codesign -s '$(RUBY_CODESIGN)' -f $@
235
+
236
+
237
+
238
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,61 @@
1
+ have_library: checking for main() in -luriparser... -------------------- yes
2
+
3
+ "/usr/bin/clang -o conftest -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin12.3.0 -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I../../../../ext/uriparser_ext -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -I/Users/mpapis/.sm/pkg/active/include -fPIC -pipe conftest.c -L. -L/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/lib -L. -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector -arch x86_64 -lruby-static -lpthread -ldl -lobjc "
4
+ ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
5
+ checked program was:
6
+ /* begin */
7
+ 1: #include "ruby.h"
8
+ 2:
9
+ 3: int main(int argc, char **argv)
10
+ 4: {
11
+ 5: return 0;
12
+ 6: }
13
+ /* end */
14
+
15
+ "/usr/bin/clang -o conftest -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin12.3.0 -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I../../../../ext/uriparser_ext -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -I/Users/mpapis/.sm/pkg/active/include -fPIC -pipe conftest.c -L. -L/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/lib -L. -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector -arch x86_64 -lruby-static -luriparser -lpthread -ldl -lobjc "
16
+ conftest.c:5:57: error: use of undeclared identifier 'main'
17
+ int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
18
+ ^
19
+ 1 error generated.
20
+ checked program was:
21
+ /* begin */
22
+ 1: #include "ruby.h"
23
+ 2:
24
+ 3: /*top*/
25
+ 4: extern int t(void);
26
+ 5: int t(void) { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
27
+ 6: int main(int argc, char **argv)
28
+ 7: {
29
+ 8: if (argc > 1000000) {
30
+ 9: printf("%p", &t);
31
+ 10: }
32
+ 11:
33
+ 12: return 0;
34
+ 13: }
35
+ /* end */
36
+
37
+ "/usr/bin/clang -o conftest -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/x86_64-darwin12.3.0 -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0/ruby/backward -I/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/include/ruby-2.0.0 -I../../../../ext/uriparser_ext -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -I/Users/mpapis/.sm/pkg/active/include -fPIC -pipe conftest.c -L. -L/Users/thiagolewin/.rvm/rubies/ruby-2.0.0-p247/lib -L. -L/Users/mpapis/.sm/pkg/active/lib -L/usr/lib -fPIC -Bstatic -fstack-protector -arch x86_64 -lruby-static -luriparser -lpthread -ldl -lobjc "
38
+ conftest.c:5:15: warning: implicit declaration of function 'main' is invalid in C99 [-Wimplicit-function-declaration]
39
+ int t(void) { main(); return 0; }
40
+ ^
41
+ 1 warning generated.
42
+ ld: warning: directory not found for option '-L/Users/mpapis/.sm/pkg/active/lib'
43
+ checked program was:
44
+ /* begin */
45
+ 1: #include "ruby.h"
46
+ 2:
47
+ 3: /*top*/
48
+ 4: extern int t(void);
49
+ 5: int t(void) { main(); return 0; }
50
+ 6: int main(int argc, char **argv)
51
+ 7: {
52
+ 8: if (argc > 1000000) {
53
+ 9: printf("%p", &t);
54
+ 10: }
55
+ 11:
56
+ 12: return 0;
57
+ 13: }
58
+ /* end */
59
+
60
+ --------------------
61
+
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-uriparser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Thiago Lewin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby wrapper for uriparser C library
14
+ email:
15
+ - thiago_lewin@yahoo.com.br
16
+ executables: []
17
+ extensions:
18
+ - ext/uriparser_ext/extconf.rb
19
+ extra_rdoc_files: []
20
+ files:
21
+ - benchmark/benchmark.rb
22
+ - ext/uriparser_ext/extconf.rb
23
+ - ext/uriparser_ext/uriparser.c
24
+ - Gemfile
25
+ - lib/uriparser/uri_gem.rb
26
+ - lib/uriparser/version.rb
27
+ - lib/uriparser.rb
28
+ - lib/uriparser_ext.bundle
29
+ - LICENSE
30
+ - Rakefile
31
+ - README.md
32
+ - ruby-uriparser-0.1.0.gem
33
+ - ruby-uriparser.gemspec
34
+ - tmp/x86_64-darwin12.3.0/stage/lib/uriparser_ext.bundle
35
+ - tmp/x86_64-darwin12.3.0/uriparser_ext/2.0.0/Makefile
36
+ - tmp/x86_64-darwin12.3.0/uriparser_ext/2.0.0/mkmf.log
37
+ - tmp/x86_64-darwin12.3.0/uriparser_ext/2.0.0/uriparser.o
38
+ - tmp/x86_64-darwin12.3.0/uriparser_ext/2.0.0/uriparser_ext.bundle
39
+ homepage: https://github.com/tlewin/ruby-uriparser
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.0.6
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Ruby wrapper for uriparser C library
63
+ test_files: []