net-imap-proxy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 105b3fd8365f4604a8c7c75d577df63eb932e26d34a39e1502ba3be05da4cf2e
4
+ data.tar.gz: 7b470cfe39c43b82f3e2439338e75136bf509a61f53f4aca2275ee96b6efca0e
5
+ SHA512:
6
+ metadata.gz: 5a0e1a176e95c0feffd7df9d169d46bfa407cd4ac5fe9121daa6fb7731ba50760bb00c52c67de30b62c8386c3d219b144115c07cdde0b9b0c5b521a886610a73
7
+ data.tar.gz: 828242beb88179d595fb2cd6376b5b335dfa01e58062c5926103de2d6cf46d26cf5457cb938281e01bf0492839b728064631ff13a335dc3b8fc4b40d83d6dcf5
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /bin/test
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at sebastian.johnsson@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in net-imap-proxy.gemspec
6
+ gemspec
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ net-imap-proxy (0.1.0)
5
+ proxifier (~> 1.0, >= 1.0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ mail (2.7.1)
12
+ mini_mime (>= 0.1.1)
13
+ mini_mime (1.0.2)
14
+ proxifier (1.0.3)
15
+ rake (10.5.0)
16
+ rspec (3.8.0)
17
+ rspec-core (~> 3.8.0)
18
+ rspec-expectations (~> 3.8.0)
19
+ rspec-mocks (~> 3.8.0)
20
+ rspec-core (3.8.2)
21
+ rspec-support (~> 3.8.0)
22
+ rspec-expectations (3.8.4)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-mocks (3.8.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-support (3.8.2)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.17)
35
+ mail (~> 2.7, >= 2.7.1)
36
+ net-imap-proxy!
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Sebastian Johnsson
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,72 @@
1
+ # Net::IMAP::Proxy
2
+
3
+ Proxy support for Ruby's NET::IMAP library.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'net-imap-proxy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install net-imap-proxy
20
+
21
+ ## Usage
22
+
23
+ The recommended way to use this gem is to use the [Mail gem](https://github.com/mikel/mail) and the provided [retriever method](lib/net/imap/proxy/retriever_method.rb):
24
+
25
+ ```ruby
26
+ Mail.defaults do
27
+ retriever_method ::Net::IMAP::Proxy::RetrieverMethod,
28
+ address: 'imap.gmail.com',
29
+ port: 993,
30
+ user_name: 'username@gmail.com',
31
+ password: 'somePassw0rd',
32
+ enable_ssl: true,
33
+ proxy_address: 'http://proxy.domain.com',
34
+ proxy_port: 8080
35
+ end
36
+
37
+ Mail.find(mailbox: "Inbox", order: :desc, count: :all)&.each do |email|
38
+ puts "From: #{email.from&.first&.strip}. Subject: #{email.subject}"
39
+ end
40
+ ```
41
+
42
+ If you want to use the gem without the [Mail gem](https://github.com/mikel/mail), instantiate an instance of the `Proxy` class and use it to make IMAP requests:
43
+
44
+ ```ruby
45
+ address = 'imap.gmail.com'
46
+ port = 993
47
+ proxy_address = 'http://proxy.domain.com' # Authentication is also supported, e.g. http://user:password@proxy.domain.com
48
+ proxy_port = 8080
49
+
50
+ proxy = Net::IMAP::Proxy.new(address, port, proxy_address, proxy_port, true, nil, false) # true, nil, false = enable ssl, without specifying certs and disable ssl verification
51
+ proxy.login('username@gmail.com', 'somePassw0rd')
52
+ proxy.select("INBOX")
53
+ pp proxy.search(["ALL"])
54
+ ```
55
+
56
+ ## Development
57
+
58
+ 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.
59
+
60
+ 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).
61
+
62
+ ## Contributing
63
+
64
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SebastianJ/net-imap-proxy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
65
+
66
+ ## License
67
+
68
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
69
+
70
+ ## Code of Conduct
71
+
72
+ Everyone interacting in the Net::IMAP::Proxy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/SebastianJ/net-imap-proxy/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "net/imap/proxy"
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,24 @@
1
+ require 'net/imap'
2
+ require 'proxifier'
3
+
4
+ module Net
5
+ class IMAP
6
+ class Proxy < IMAP
7
+ autoload :RetrieverMethod, 'net/imap/proxy/retriever_method'
8
+
9
+ attr_reader :proxy_address, :proxy_port
10
+
11
+ def initialize(address, port, proxy_address = nil, proxy_port = nil, use_ssl = false, certs = nil, verify = false)
12
+ @proxy_address = proxy_address
13
+ @proxy_port = proxy_port
14
+
15
+ super(address, port, use_ssl, certs, verify)
16
+ end
17
+
18
+ private
19
+ def tcp_socket(address, port)
20
+ Proxifier::Proxy("#{proxy_address}:#{proxy_port}").open(address, port)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,52 @@
1
+ require 'net/imap'
2
+
3
+ begin
4
+ require 'mail'
5
+ rescue LoadError
6
+ puts 'The mail gem is required to use the DeliveryMethod class.'
7
+ end
8
+
9
+ module Net
10
+ class IMAP
11
+ class Proxy < IMAP
12
+ # for use with the mail gem
13
+ class RetrieverMethod < ::Mail::IMAP
14
+ private
15
+
16
+ # adapted from
17
+ # https://github.com/mikel/mail/blob/master/lib/mail/network/retriever_methods/imap.rb#L160
18
+ def start(config=Mail::Configuration.instance, &block)
19
+ raise ArgumentError.new("Mail::Retrievable#imap_start takes a block") unless block_given?
20
+
21
+ if settings[:enable_starttls] && settings[:enable_ssl]
22
+ raise ArgumentError, ":enable_starttls and :enable_ssl are mutually exclusive. Set :enable_ssl if you're on an IMAPS connection. Set :enable_starttls if you're on an IMAP connection and using STARTTLS for secure TLS upgrade."
23
+ end
24
+
25
+ init_params = [
26
+ settings[:address], settings[:port],
27
+ settings[:proxy_address], settings[:proxy_port],
28
+ settings[:enable_ssl], nil, false
29
+ ]
30
+
31
+ imap = Net::IMAP::Proxy.new(*init_params)
32
+ imap.starttls if settings[:enable_starttls]
33
+
34
+ if settings[:authentication].nil?
35
+ imap.login(settings[:user_name], settings[:password])
36
+ else
37
+ # Note that Net::IMAP#authenticate('LOGIN', ...) is not equal with Net::IMAP#login(...)!
38
+ # (see also http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/imap/rdoc/classes/Net/IMAP.html#M000718)
39
+ imap.authenticate(settings[:authentication], settings[:user_name], settings[:password])
40
+ end
41
+
42
+ yield imap
43
+ ensure
44
+ if defined?(imap) && imap && !imap.disconnected?
45
+ imap.disconnect
46
+ end
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,9 @@
1
+ require 'net/imap'
2
+
3
+ module Net
4
+ class IMAP
5
+ class Proxy < IMAP
6
+ VERSION = "0.1.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "net/imap/proxy/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "net-imap-proxy"
8
+ spec.version = Net::IMAP::Proxy::VERSION
9
+ spec.authors = ["Sebastian Johnsson"]
10
+ spec.email = ["sebastian.johnsson@gmail.com"]
11
+
12
+ spec.summary = %q{Proxy support for Ruby's Net::IMAP library.}
13
+ spec.description = %q{Proxy support for Ruby's Net::IMAP library.}
14
+ spec.homepage = "https://github.com/SebastianJ/net-imap-proxy"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "exe"
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_dependency 'proxifier', '~> 1.0', '>= 1.0.3'
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.17"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+
32
+ spec.add_development_dependency 'mail', '~> 2.7', '>= 2.7.1'
33
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: net-imap-proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian Johnsson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: proxifier
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.17'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.17'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: mail
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '2.7'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.7.1
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '2.7'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 2.7.1
95
+ description: Proxy support for Ruby's Net::IMAP library.
96
+ email:
97
+ - sebastian.johnsson@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - ".gitignore"
103
+ - ".rspec"
104
+ - ".travis.yml"
105
+ - CODE_OF_CONDUCT.md
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/net/imap/proxy.rb
114
+ - lib/net/imap/proxy/retriever_method.rb
115
+ - lib/net/imap/proxy/version.rb
116
+ - net-imap-proxy.gemspec
117
+ homepage: https://github.com/SebastianJ/net-imap-proxy
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubygems_version: 3.0.3
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Proxy support for Ruby's Net::IMAP library.
140
+ test_files: []