ruby-cyrus-sasl 0.0.1
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.
- data/.autotest +9 -0
- data/History.txt +4 -0
- data/LICENSE +25 -0
- data/Manifest.txt +22 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +48 -0
- data/Rakefile +26 -0
- data/ext/rubysasl/extconf.rb +8 -0
- data/ext/rubysasl/rubysasl.c +170 -0
- data/lib/ruby-cyrus-sasl/Callback.rb +17 -0
- data/lib/ruby-cyrus-sasl/Client.rb +30 -0
- data/lib/ruby-cyrus-sasl/ClientFacroty.rb +20 -0
- data/lib/ruby-cyrus-sasl/imap.rb +53 -0
- data/lib/ruby-cyrus-sasl.rb +6 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/tasks/extconf/rubysasl.rake +43 -0
- data/tasks/extconf.rake +13 -0
- data/test/test_helper.rb +3 -0
- data/test/test_ruby-cyrus-sasl.rb +11 -0
- data/test/test_rubysasl_extn.rb +10 -0
- metadata +106 -0
data/.autotest
ADDED
data/History.txt
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
4
|
+
permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
7
|
+
conditions and the following disclaimer.
|
8
|
+
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
10
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
11
|
+
provided with the distribution.
|
12
|
+
|
13
|
+
THIS SOFTWARE IS PROVIDED BY HAUKE MEHRTENS ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
14
|
+
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL HAUKE MEHRTENS OR
|
16
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
17
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
18
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
19
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
20
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
21
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
22
|
+
|
23
|
+
The views and conclusions contained in the software and documentation are those of the
|
24
|
+
authors and should not be interpreted as representing official policies, either expressed
|
25
|
+
or implied, of Hauke Mehrtens.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
.autotest
|
2
|
+
History.txt
|
3
|
+
LICENSE
|
4
|
+
Manifest.txt
|
5
|
+
PostInstall.txt
|
6
|
+
README.rdoc
|
7
|
+
Rakefile
|
8
|
+
ext/rubysasl/extconf.rb
|
9
|
+
ext/rubysasl/rubysasl.c
|
10
|
+
lib/ruby-cyrus-sasl.rb
|
11
|
+
lib/ruby-cyrus-sasl/Callback.rb
|
12
|
+
lib/ruby-cyrus-sasl/Client.rb
|
13
|
+
lib/ruby-cyrus-sasl/ClientFacroty.rb
|
14
|
+
lib/ruby-cyrus-sasl/imap.rb
|
15
|
+
script/console
|
16
|
+
script/destroy
|
17
|
+
script/generate
|
18
|
+
tasks/extconf.rake
|
19
|
+
tasks/extconf/rubysasl.rake
|
20
|
+
test/test_helper.rb
|
21
|
+
test/test_ruby-cyrus-sasl.rb
|
22
|
+
test/test_rubysasl_extn.rb
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
= ruby-cyrus-sasl
|
2
|
+
|
3
|
+
* http://github.com/#{github_username}/#{project_name}
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
FIX (describe your package)
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* FIX (list of features or problems)
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
FIX (code sample of usage)
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* FIX (list of requirements)
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
* FIX (sudo gem install, anything else)
|
24
|
+
|
25
|
+
== LICENSE:
|
26
|
+
|
27
|
+
(The MIT License)
|
28
|
+
|
29
|
+
Copyright (c) 2011 FIXME full name
|
30
|
+
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
32
|
+
a copy of this software and associated documentation files (the
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
37
|
+
the following conditions:
|
38
|
+
|
39
|
+
The above copyright notice and this permission notice shall be
|
40
|
+
included in all copies or substantial portions of the Software.
|
41
|
+
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/ruby-cyrus-sasl'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'ruby-cyrus-sasl' do
|
14
|
+
self.developer 'Hauke Mehrtens', 'hauke@hauke-m.de'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
# remove_task :default
|
26
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
dir_config("rubysasl")
|
4
|
+
raise Exception "can not find header \"sasl/sasl.h\"" unless find_header('sasl/sasl.h')
|
5
|
+
raise Exception "can not find lib \"sasl2\"" unless find_library('sasl2', "sasl_client_init")
|
6
|
+
raise Exception "can not find lib \"sasl2\"" unless have_library("sasl2")
|
7
|
+
raise Exception "can not find lib \"sasl2\"" unless have_func('sasl_client_step')
|
8
|
+
create_makefile("rubysasl")
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#include <sasl/sasl.h>
|
2
|
+
#include <ruby.h>
|
3
|
+
|
4
|
+
static sasl_callback_t callbacks[] = {
|
5
|
+
{
|
6
|
+
SASL_CB_PASS, NULL, NULL
|
7
|
+
}, {
|
8
|
+
SASL_CB_USER, NULL, NULL /* we'll handle these ourselves */
|
9
|
+
}, {
|
10
|
+
SASL_CB_AUTHNAME, NULL, NULL /* we'll handle these ourselves */
|
11
|
+
}, {
|
12
|
+
SASL_CB_LIST_END, NULL, NULL
|
13
|
+
}
|
14
|
+
};
|
15
|
+
|
16
|
+
VALUE mSasl;
|
17
|
+
VALUE cClientFactory;
|
18
|
+
VALUE cClient;
|
19
|
+
|
20
|
+
static VALUE t_sasl_client_init(VALUE self)
|
21
|
+
{
|
22
|
+
int result;
|
23
|
+
|
24
|
+
result = sasl_client_init(callbacks);
|
25
|
+
if (result != SASL_OK) {
|
26
|
+
rb_raise(rb_eException, "initializing libsasl");
|
27
|
+
}
|
28
|
+
return self;
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE t_sasl_client_new(VALUE self, VALUE service, VALUE serverFQDN, VALUE callback, VALUE localaddr, VALUE remoteaddr)
|
32
|
+
{
|
33
|
+
sasl_conn_t *c_conn;
|
34
|
+
VALUE conn;
|
35
|
+
int result;
|
36
|
+
VALUE argv[1];
|
37
|
+
char *c_service = (service != Qnil) ? RSTRING_PTR(service) : NULL;
|
38
|
+
char *c_serverFQDN = (serverFQDN != Qnil) ? RSTRING_PTR(serverFQDN) : NULL;
|
39
|
+
char *c_localaddr = (localaddr != Qnil) ? RSTRING_PTR(localaddr) : NULL;
|
40
|
+
char *c_remoteaddr = (remoteaddr != Qnil) ? RSTRING_PTR(remoteaddr) : NULL;
|
41
|
+
|
42
|
+
result = sasl_client_new(c_service, c_serverFQDN, c_localaddr, c_remoteaddr, NULL, 0, &c_conn);
|
43
|
+
if (result != SASL_OK) {
|
44
|
+
rb_raise(rb_eException, "allocating connection state");
|
45
|
+
return self;
|
46
|
+
}
|
47
|
+
|
48
|
+
//TODO: free this
|
49
|
+
conn = Data_Wrap_Struct(cClient, NULL, NULL, c_conn);
|
50
|
+
argv[0] = callback;
|
51
|
+
rb_obj_call_init(conn, 1, argv);
|
52
|
+
return conn;
|
53
|
+
}
|
54
|
+
|
55
|
+
static void call_callback(VALUE callbackFunc, sasl_interact_t *callback,const char *callback_name)
|
56
|
+
{
|
57
|
+
VALUE result;
|
58
|
+
VALUE challenge = (callback->challenge != NULL) ? rb_str_new2(callback->challenge) : Qnil;
|
59
|
+
VALUE prompt = (callback->prompt != NULL) ? rb_str_new2(callback->prompt) : Qnil;
|
60
|
+
VALUE defresult = (callback->defresult != NULL) ? rb_str_new2(callback->defresult) : Qnil;
|
61
|
+
ID passID = rb_intern(callback_name);
|
62
|
+
|
63
|
+
result = rb_funcall(callbackFunc, passID, 3, challenge, prompt, defresult);
|
64
|
+
callback->result = (result != Qnil) ? RSTRING_PTR(result) : NULL;
|
65
|
+
callback->len = (result != Qnil) ? RSTRING_LEN(result) : 0;
|
66
|
+
}
|
67
|
+
|
68
|
+
static void handle_callbacks(VALUE callbackFunc, sasl_interact_t *c_prompt_need)
|
69
|
+
{
|
70
|
+
sasl_interact_t *callback = c_prompt_need;
|
71
|
+
|
72
|
+
while (callback->id != SASL_CB_LIST_END)
|
73
|
+
{
|
74
|
+
switch (callback->id)
|
75
|
+
{
|
76
|
+
case SASL_CB_PASS:
|
77
|
+
call_callback(callbackFunc, callback, "password");
|
78
|
+
break;
|
79
|
+
case SASL_CB_AUTHNAME:
|
80
|
+
call_callback(callbackFunc, callback, "authid");
|
81
|
+
break;
|
82
|
+
case SASL_CB_USER:
|
83
|
+
call_callback(callbackFunc, callback, "userid");
|
84
|
+
break;
|
85
|
+
case SASL_CB_GETREALM:
|
86
|
+
call_callback(callbackFunc, callback, "realm");
|
87
|
+
break;
|
88
|
+
default:
|
89
|
+
printf("unkown callback 0x%lx", callback->id);
|
90
|
+
}
|
91
|
+
/* increment to next sasl_interact_t */
|
92
|
+
callback++;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
static VALUE t_sasl_client_start(VALUE self, VALUE mechlist)
|
97
|
+
{
|
98
|
+
sasl_conn_t *c_conn;
|
99
|
+
const char *c_mechlist = (mechlist != Qnil) ? RSTRING_PTR(mechlist) : NULL;
|
100
|
+
sasl_interact_t *c_prompt_need = NULL;
|
101
|
+
const char *c_clientout;
|
102
|
+
unsigned c_clientoutlen = 0;
|
103
|
+
const char *c_mech;
|
104
|
+
int err;
|
105
|
+
VALUE result;
|
106
|
+
|
107
|
+
Data_Get_Struct(self, sasl_conn_t, c_conn);
|
108
|
+
|
109
|
+
do {
|
110
|
+
err = sasl_client_start(c_conn, c_mechlist, &c_prompt_need, &c_clientout, &c_clientoutlen, &c_mech);
|
111
|
+
if (err == SASL_INTERACT) {
|
112
|
+
VALUE callbackFunc = rb_iv_get(self, "@callback");
|
113
|
+
handle_callbacks(callbackFunc, c_prompt_need);
|
114
|
+
}
|
115
|
+
} while (err == SASL_INTERACT);
|
116
|
+
|
117
|
+
if (err != SASL_OK && err != SASL_CONTINUE) {
|
118
|
+
rb_raise(rb_eException, "starting SASL negotiation details: %s", sasl_errdetail(c_conn));
|
119
|
+
return Qnil;
|
120
|
+
}
|
121
|
+
|
122
|
+
rb_iv_set(self, "@mech", rb_str_new2(c_mech));
|
123
|
+
result = rb_str_new(c_clientout, c_clientoutlen);
|
124
|
+
return result;
|
125
|
+
}
|
126
|
+
|
127
|
+
static VALUE t_sasl_client_step(VALUE self, VALUE serverin)
|
128
|
+
{
|
129
|
+
sasl_conn_t *c_conn;
|
130
|
+
const char *c_serverin;
|
131
|
+
unsigned c_serverinlen;
|
132
|
+
sasl_interact_t *c_prompt_need = NULL;
|
133
|
+
const char *c_clientout;
|
134
|
+
unsigned c_clientoutlen;
|
135
|
+
int err;
|
136
|
+
VALUE result;
|
137
|
+
|
138
|
+
Data_Get_Struct(self, sasl_conn_t, c_conn);
|
139
|
+
c_serverin = (serverin != Qnil) ? RSTRING_PTR(serverin) : NULL;
|
140
|
+
c_serverinlen = (serverin != Qnil) ? RSTRING_LEN(serverin) : 0;
|
141
|
+
|
142
|
+
do {
|
143
|
+
err = sasl_client_step(c_conn, c_serverin, c_serverinlen, &c_prompt_need, &c_clientout, &c_clientoutlen);
|
144
|
+
if (err == SASL_INTERACT) {
|
145
|
+
VALUE callbackFunc = rb_iv_get(self, "@callback");
|
146
|
+
handle_callbacks(callbackFunc, c_prompt_need);
|
147
|
+
}
|
148
|
+
} while (err == SASL_INTERACT);
|
149
|
+
|
150
|
+
if (err != SASL_OK && err != SASL_CONTINUE) {
|
151
|
+
rb_raise(rb_eException, "starting SASL negotiation details: %s", sasl_errdetail(c_conn));
|
152
|
+
return Qnil;
|
153
|
+
}
|
154
|
+
if (err == SASL_OK)
|
155
|
+
rb_iv_set(self, "@complete", Qtrue);
|
156
|
+
|
157
|
+
result = rb_str_new(c_clientout, c_clientoutlen);
|
158
|
+
return result;
|
159
|
+
}
|
160
|
+
|
161
|
+
void Init_rubysasl() {
|
162
|
+
mSasl = rb_define_module("RubyCyrusSASL");
|
163
|
+
cClientFactory = rb_define_class_under(mSasl, "ClientFactory", rb_cObject);
|
164
|
+
cClient = rb_define_class_under(mSasl, "Client", rb_cObject);
|
165
|
+
rb_define_method(cClientFactory, "sasl_client_init", t_sasl_client_init, 0);
|
166
|
+
rb_define_method(cClientFactory, "sasl_client_new", t_sasl_client_new, 5);
|
167
|
+
rb_define_method(cClient, "sasl_client_start", t_sasl_client_start, 1);
|
168
|
+
rb_define_method(cClient, "sasl_client_step", t_sasl_client_step, 1);
|
169
|
+
}
|
170
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RubyCyrusSASL
|
2
|
+
module Callback
|
3
|
+
|
4
|
+
def password challenge, prompt, defresult
|
5
|
+
end
|
6
|
+
|
7
|
+
def authid challenge, prompt, defresult
|
8
|
+
end
|
9
|
+
|
10
|
+
def userid challenge, prompt, defresult
|
11
|
+
end
|
12
|
+
|
13
|
+
def realm challenge, prompt, defresult
|
14
|
+
end
|
15
|
+
|
16
|
+
end #module Callback
|
17
|
+
end #module RubyCyrusSASL
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubysasl'
|
2
|
+
|
3
|
+
module RubyCyrusSASL
|
4
|
+
class Client
|
5
|
+
|
6
|
+
def initialize callback
|
7
|
+
@callback = callback
|
8
|
+
@complete = false
|
9
|
+
@mech = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def start mech_list
|
13
|
+
puts mech_list
|
14
|
+
sasl_client_start mech_list
|
15
|
+
end
|
16
|
+
|
17
|
+
def step challenge
|
18
|
+
sasl_client_step challenge
|
19
|
+
end
|
20
|
+
|
21
|
+
def mech
|
22
|
+
@mech
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete?
|
26
|
+
@complete
|
27
|
+
end
|
28
|
+
|
29
|
+
end #class Client
|
30
|
+
end #module RubyCyrusSASL
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$: << File.dirname(File.absolute_path(__FILE__))
|
2
|
+
require 'singleton'
|
3
|
+
require 'rubysasl.so'
|
4
|
+
require 'Client'
|
5
|
+
require 'Callback'
|
6
|
+
|
7
|
+
module RubyCyrusSASL
|
8
|
+
class ClientFactory
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
sasl_client_init
|
13
|
+
end
|
14
|
+
|
15
|
+
def create service, serverFQDN, callback, iplocalport = nil, ipremoteport = nil
|
16
|
+
sasl_client_new service, serverFQDN, callback, iplocalport, ipremoteport
|
17
|
+
end
|
18
|
+
|
19
|
+
end #class ClientFactory
|
20
|
+
end #module RubyCyrusSASL
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'net/imap'
|
2
|
+
require 'ruby-cyrus-sasl/ClientFacroty'
|
3
|
+
|
4
|
+
module Net
|
5
|
+
class IMAP
|
6
|
+
|
7
|
+
class SASLCallback
|
8
|
+
include RubyCyrusSASL::Callback
|
9
|
+
|
10
|
+
def initialize user, password, authname
|
11
|
+
@user = user
|
12
|
+
@password = password
|
13
|
+
@authname = authname
|
14
|
+
end
|
15
|
+
|
16
|
+
def password challenge, prompt, defresult
|
17
|
+
@password
|
18
|
+
end
|
19
|
+
|
20
|
+
def authid challenge, prompt, defresult
|
21
|
+
@authname
|
22
|
+
end
|
23
|
+
|
24
|
+
def userid challenge, prompt, defresult
|
25
|
+
@user
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def authenticate_cyrus user, password, authname
|
30
|
+
callback = SASLCallback.new user, password, authname
|
31
|
+
server_mechs = (@greeting.data.code.data.scan /AUTH=([^ ]+)/).join ", "
|
32
|
+
cyrus_sasl = RubyCyrusSASL::ClientFactory.instance.create "imap", @host, callback
|
33
|
+
start_result = cyrus_sasl.start server_mechs
|
34
|
+
send_command("AUTHENTICATE", cyrus_sasl.mech) do |resp|
|
35
|
+
if resp.instance_of?(ContinuationRequest)
|
36
|
+
if start_result && start_result.length != 0
|
37
|
+
s = [start_result].pack("m").gsub(/\n/, "")
|
38
|
+
send_string_data(s)
|
39
|
+
put_string(CRLF)
|
40
|
+
start_result = nil
|
41
|
+
else
|
42
|
+
data = cyrus_sasl.step(resp.data.text.unpack("m")[0])
|
43
|
+
data = "OK Success (privacy protection)" if cyrus_sasl.complete? and data == ""
|
44
|
+
s = [data].pack("m").gsub(/\n/, "")
|
45
|
+
send_string_data(s)
|
46
|
+
put_string(CRLF)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end # class IMAP
|
53
|
+
end #module Net
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/ruby-cyrus-sasl.rb'}"
|
9
|
+
puts "Loading ruby-cyrus-sasl gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
namespace :extconf do
|
2
|
+
extension = File.basename(__FILE__, '.rake')
|
3
|
+
|
4
|
+
ext = "ext/#{extension}"
|
5
|
+
ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
|
6
|
+
ext_files = FileList[
|
7
|
+
"#{ext}/*.c",
|
8
|
+
"#{ext}/*.h",
|
9
|
+
"#{ext}/*.rl",
|
10
|
+
"#{ext}/extconf.rb",
|
11
|
+
"#{ext}/Makefile",
|
12
|
+
# "lib"
|
13
|
+
]
|
14
|
+
|
15
|
+
|
16
|
+
task :compile => extension do
|
17
|
+
if Dir.glob("**/#{extension}.{o,so,dll}").length == 0
|
18
|
+
STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
19
|
+
STDERR.puts "Gem actually failed to build. Your system is"
|
20
|
+
STDERR.puts "NOT configured properly to build #{GEM_NAME}."
|
21
|
+
STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
22
|
+
exit(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Builds just the #{extension} extension"
|
27
|
+
task extension.to_sym => ["#{ext}/Makefile", ext_so ]
|
28
|
+
|
29
|
+
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
30
|
+
Dir.chdir(ext) do ruby "extconf.rb" end
|
31
|
+
end
|
32
|
+
|
33
|
+
file ext_so => ext_files do
|
34
|
+
Dir.chdir(ext) do
|
35
|
+
sh(PLATFORM =~ /win32/ ? 'nmake' : 'make') do |ok, res|
|
36
|
+
if !ok
|
37
|
+
require "fileutils"
|
38
|
+
FileUtils.rm Dir.glob('*.{so,o,dll,bundle}')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/tasks/extconf.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :extconf do
|
2
|
+
desc "Compiles the Ruby extension"
|
3
|
+
task :compile
|
4
|
+
end
|
5
|
+
|
6
|
+
task :compile => "extconf:compile"
|
7
|
+
|
8
|
+
task :test => :compile
|
9
|
+
|
10
|
+
BIN = "*.{bundle,jar,so,obj,pdb,lib,def,exp}"
|
11
|
+
$hoe.clean_globs |= ["ext/**/#{BIN}", "lib/**/#{BIN}", 'ext/**/Makefile']
|
12
|
+
$hoe.spec.require_paths = Dir['{lib,ext/*}']
|
13
|
+
$hoe.spec.extensions = FileList["ext/**/extconf.rb"].to_a
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-cyrus-sasl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Hauke Mehrtens
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-12-16 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: hoe
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 8
|
31
|
+
- 0
|
32
|
+
version: 2.8.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description: FIX (describe your package)
|
36
|
+
email:
|
37
|
+
- hauke@hauke-m.de
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions:
|
41
|
+
- ext/rubysasl/extconf.rb
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
- PostInstall.txt
|
46
|
+
files:
|
47
|
+
- .autotest
|
48
|
+
- History.txt
|
49
|
+
- LICENSE
|
50
|
+
- Manifest.txt
|
51
|
+
- PostInstall.txt
|
52
|
+
- README.rdoc
|
53
|
+
- Rakefile
|
54
|
+
- ext/rubysasl/extconf.rb
|
55
|
+
- ext/rubysasl/rubysasl.c
|
56
|
+
- lib/ruby-cyrus-sasl.rb
|
57
|
+
- lib/ruby-cyrus-sasl/Callback.rb
|
58
|
+
- lib/ruby-cyrus-sasl/Client.rb
|
59
|
+
- lib/ruby-cyrus-sasl/ClientFacroty.rb
|
60
|
+
- lib/ruby-cyrus-sasl/imap.rb
|
61
|
+
- script/console
|
62
|
+
- script/destroy
|
63
|
+
- script/generate
|
64
|
+
- tasks/extconf.rake
|
65
|
+
- tasks/extconf/rubysasl.rake
|
66
|
+
- test/test_helper.rb
|
67
|
+
- test/test_ruby-cyrus-sasl.rb
|
68
|
+
- test/test_rubysasl_extn.rb
|
69
|
+
has_rdoc: true
|
70
|
+
homepage: http://github.com/#{github_username}/#{project_name}
|
71
|
+
licenses: []
|
72
|
+
|
73
|
+
post_install_message: PostInstall.txt
|
74
|
+
rdoc_options:
|
75
|
+
- --main
|
76
|
+
- README.rdoc
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
- ext/rubysasl
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
segments:
|
94
|
+
- 0
|
95
|
+
version: "0"
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project: ruby-cyrus-sasl
|
99
|
+
rubygems_version: 1.3.7
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: FIX (describe your package)
|
103
|
+
test_files:
|
104
|
+
- test/test_rubysasl_extn.rb
|
105
|
+
- test/test_ruby-cyrus-sasl.rb
|
106
|
+
- test/test_helper.rb
|