libproxy 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 50e16ad0be6f38bbe3afddf77a8cfa4be791110c
4
+ data.tar.gz: 298d8a7cdfbd22fecf98f751b0aae736f8d51855
5
+ SHA512:
6
+ metadata.gz: 2cc67babbbcbf75f62cafd81ca8cb1231df872e724b000d00b7837cd8f3d5e2caab8f42868935328c8a48538d931cba48f739eecb084f1bf9ec3c2cbad841d1b
7
+ data.tar.gz: bee5d5ac911cd9e44ae8da52f7457e66dffb686978671795c63f941e3d4f89c038d35e528570a3185e49ce8984b1cce77509e9cda1228323c3ad7a258ca3543c
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # rspec failure tracking
17
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,2 @@
1
+ Metrics/LineLength:
2
+ Enabled: false
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler
6
+ addons:
7
+ apt:
8
+ packages:
9
+ - libproxy-dev
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in libproxy.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Satoshi Matsumoto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # libproxy-ruby
2
+
3
+ [![Gem](https://img.shields.io/gem/v/libproxy.svg?style=flat-square)](https://rubygems.org/gems/libproxy)
4
+ [![Travis](https://img.shields.io/travis/kaorimatz/libproxy-ruby.svg?style=flat-square)](https://travis-ci.org/kaorimatz/libproxy-ruby)
5
+ [![Coveralls](https://img.shields.io/coveralls/kaorimatz/libproxy-ruby.svg?style=flat-square)](https://coveralls.io/github/kaorimatz/libproxy-ruby)
6
+ [![Gemnasium](https://img.shields.io/gemnasium/kaorimatz/libproxy-ruby.svg?style=flat-square)](https://gemnasium.com/kaorimatz/libproxy-ruby)
7
+
8
+ Ruby bindings for [libproxy](https://github.com/libproxy/libproxy).
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'libproxy'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install libproxy
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'libproxy'
30
+
31
+ proxy_factory = Libproxy::ProxyFactory.new
32
+ proxies = proxy_factory.proxies('http://example.com/')
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kaorimatz/libproxy-ruby.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,15 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require 'rake/extensiontask'
7
+
8
+ task build: :compile
9
+
10
+ Rake::ExtensionTask.new('libproxy_ext') do |ext|
11
+ ext.ext_dir = 'ext/libproxy'
12
+ ext.lib_dir = 'lib/libproxy'
13
+ end
14
+
15
+ task default: %i[clobber compile spec]
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'libproxy'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ exit 1 unless have_library('proxy')
4
+
5
+ create_makefile('libproxy/libproxy_ext')
@@ -0,0 +1,97 @@
1
+ #include "libproxy_ext.h"
2
+
3
+ VALUE rb_eLibproxyError;
4
+
5
+ static void
6
+ proxy_factory_free(void *ptr)
7
+ {
8
+ px_proxy_factory_free((pxProxyFactory *)ptr);
9
+ }
10
+
11
+ static const rb_data_type_t proxy_factory_data_type = {
12
+ "proxy_factory",
13
+ { NULL, proxy_factory_free, NULL, },
14
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
15
+ };
16
+
17
+ static VALUE
18
+ rb_proxy_factory_s_allocate(VALUE klass)
19
+ {
20
+ return TypedData_Wrap_Struct(klass, &proxy_factory_data_type, 0);
21
+ }
22
+
23
+ /*
24
+ * call-seq:
25
+ * Libproxy::ProxyFactory.new -> proxy_factory
26
+ *
27
+ * Returns a new Libproxy::ProxyFactory object.
28
+ *
29
+ * Libproxy::ProxyFactory.new #=> #<Libproxy::ProxyFactory:0x007fde591a6500>
30
+ */
31
+ static VALUE
32
+ rb_proxy_factory_initialize(VALUE self)
33
+ {
34
+ pxProxyFactory *pf = px_proxy_factory_new();
35
+ if (pf == NULL) {
36
+ rb_raise(rb_eLibproxyError, "px_proxy_factory_new");
37
+ }
38
+
39
+ DATA_PTR(self) = pf;
40
+
41
+ return self;
42
+ }
43
+
44
+ static inline pxProxyFactory *
45
+ check_proxy_factory(VALUE self)
46
+ {
47
+ return rb_check_typeddata(self, &proxy_factory_data_type);
48
+ }
49
+
50
+ /*
51
+ * call-seq:
52
+ * proxy_factory.proxies(url) -> [string]
53
+ *
54
+ * Returns a list of proxies to use for <i>url</i> as an array.
55
+ *
56
+ * Libproxy::ProxyFactory.new.proxies("http://example.com")
57
+ * #=> ["socks://proxy.example.com:1080", "socks5://proxy.example.com:1080"]
58
+ */
59
+ static VALUE
60
+ rb_proxy_factory_proxies(VALUE self, VALUE url)
61
+ {
62
+ pxProxyFactory *pf = check_proxy_factory(self);
63
+ char **proxies;
64
+ int i;
65
+ VALUE ret;
66
+
67
+ StringValue(url);
68
+
69
+ proxies = px_proxy_factory_get_proxies(pf, RSTRING_PTR(url));
70
+ if (proxies == NULL) {
71
+ rb_raise(rb_eLibproxyError, "px_proxy_factory_get_proxies: url='%s'", RSTRING_PTR(url));
72
+ }
73
+
74
+ ret = rb_ary_new();
75
+ for (i = 0; proxies[i]; i++) {
76
+ rb_ary_push(ret, rb_str_new_cstr(proxies[i]));
77
+ free(proxies[i]);
78
+ }
79
+
80
+ free(proxies);
81
+
82
+ return ret;
83
+ }
84
+
85
+ void
86
+ Init_libproxy_ext(void)
87
+ {
88
+ VALUE rb_mLibproxy, rb_cProxyFactory;
89
+
90
+ rb_mLibproxy = rb_define_module("Libproxy");
91
+ rb_eLibproxyError = rb_define_class_under(rb_mLibproxy, "Error", rb_eStandardError);
92
+
93
+ rb_cProxyFactory = rb_define_class_under(rb_mLibproxy, "ProxyFactory", rb_cObject);
94
+ rb_define_alloc_func(rb_cProxyFactory, rb_proxy_factory_s_allocate);
95
+ rb_define_method(rb_cProxyFactory, "initialize", rb_proxy_factory_initialize, 0);
96
+ rb_define_method(rb_cProxyFactory, "proxies", rb_proxy_factory_proxies, 1);
97
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef LIBPROXY_EXT_H
2
+ #define LIBPROXY_EXT_H 1
3
+
4
+ #include "ruby.h"
5
+
6
+ #include <proxy.h>
7
+
8
+ #endif /* LIBPROXY_EXT_H */
@@ -0,0 +1,2 @@
1
+ require 'libproxy/version'
2
+ require 'libproxy/libproxy_ext'
@@ -0,0 +1,3 @@
1
+ module Libproxy
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'libproxy/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'libproxy'
9
+ spec.version = Libproxy::VERSION
10
+ spec.authors = ['Satoshi Matsumoto']
11
+ spec.email = ['kaorimatz@gmail.com']
12
+
13
+ spec.summary = 'Ruby bindings for libproxy'
14
+ spec.description = 'Ruby bindings for libproxy.'
15
+ spec.homepage = 'https://github.com/kaorimatz/libproxy-ruby'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+ spec.extensions = ['ext/libproxy/extconf.rb']
25
+
26
+ spec.add_development_dependency 'bundler'
27
+ spec.add_development_dependency 'coveralls'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rake-compiler'
30
+ spec.add_development_dependency 'rspec'
31
+ spec.add_development_dependency 'rubocop'
32
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libproxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Satoshi Matsumoto
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
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
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby bindings for libproxy.
98
+ email:
99
+ - kaorimatz@gmail.com
100
+ executables: []
101
+ extensions:
102
+ - ext/libproxy/extconf.rb
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".rubocop.yml"
108
+ - ".rubocop_todo.yml"
109
+ - ".travis.yml"
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/setup
116
+ - ext/libproxy/extconf.rb
117
+ - ext/libproxy/libproxy_ext.c
118
+ - ext/libproxy/libproxy_ext.h
119
+ - lib/libproxy.rb
120
+ - lib/libproxy/version.rb
121
+ - libproxy.gemspec
122
+ homepage: https://github.com/kaorimatz/libproxy-ruby
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.6.11
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Ruby bindings for libproxy
146
+ test_files: []