thrustio-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTJjYTVlMzAxMGIyNjBkMDM4MzAzNWMwNTA0ZDczMTJiMDU5NDlmYQ==
5
+ data.tar.gz: !binary |-
6
+ ODFiYjQxODg1YTZiZTMyMmY1NDhhODk4NWYwYThjNDM0NDVjNDhjZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTdjMWY0NGMyODBmNzAzODNlMzlmNjUyYjdhOWJiNWRmZGIzNzlkZDU0NzQz
10
+ NTE4MzgwNThkMmJmMDE3NDA5NjVkMGEyYzE2YmRkMzBlMjhkOWU1NjM4MzRl
11
+ NGRmYTlmYTdiZDkwMjVkMTZiOTE2MmE4NjFiNjU1MmUxNTU1N2E=
12
+ data.tar.gz: !binary |-
13
+ NDRkOTQ4ZGRmYjU2MmRhMjAyYTg5Mjk5MDRhMGFhOGJhNzE0Mjk4NjQ4NDE5
14
+ ZWIzNDRlMGE1MzZhODQyNzBkYjY1ZDIwM2MyNTcwZTVhMmI3NGRkNzNhODEy
15
+ MjRiZjg3N2RjNzA0MWZhZDBhNzMyNTIzOTdlZjgxNTUxMDllZjA=
data/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rdoc", "~> 3.12"
10
+ gem "bundler", "~> 1.0"
11
+ gem "jeweler", "~> 2.0.1"
12
+ gem "simplecov", ">= 0"
13
+ end
14
+
15
+
16
+ gem 'rest-client'
17
+
18
+ group :test do
19
+ gem 'mocha'
20
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.2)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ docile (1.1.5)
9
+ faraday (0.9.0)
10
+ multipart-post (>= 1.2, < 3)
11
+ git (1.2.9.1)
12
+ github_api (0.11.3)
13
+ addressable (~> 2.3)
14
+ descendants_tracker (~> 0.0.1)
15
+ faraday (~> 0.8, < 0.10)
16
+ hashie (>= 1.2)
17
+ multi_json (>= 1.7.5, < 2.0)
18
+ nokogiri (~> 1.6.0)
19
+ oauth2
20
+ hashie (2.1.2)
21
+ highline (1.6.18)
22
+ jeweler (2.0.1)
23
+ builder
24
+ bundler (>= 1.0)
25
+ git (>= 1.2.5)
26
+ github_api
27
+ highline (>= 1.6.15)
28
+ nokogiri (>= 1.5.10)
29
+ rake
30
+ rdoc
31
+ json (1.8.2)
32
+ jwt (0.1.8)
33
+ multi_json (>= 1.5)
34
+ metaclass (0.0.1)
35
+ mime-types (2.5)
36
+ mini_portile (0.6.2)
37
+ mocha (1.1.0)
38
+ metaclass (~> 0.0.1)
39
+ multi_json (1.11.0)
40
+ multi_xml (0.5.2)
41
+ multipart-post (2.0.0)
42
+ nokogiri (1.6.6.2)
43
+ mini_portile (~> 0.6.0)
44
+ oauth2 (0.9.3)
45
+ faraday (>= 0.8, < 0.10)
46
+ jwt (~> 0.1.8)
47
+ multi_json (~> 1.3)
48
+ multi_xml (~> 0.5)
49
+ rack (~> 1.2)
50
+ rack (1.6.1)
51
+ rake (10.4.2)
52
+ rdoc (3.12.2)
53
+ json (~> 1.4)
54
+ rest-client (1.6.7)
55
+ mime-types (>= 1.16)
56
+ simplecov (0.9.0)
57
+ docile (~> 1.1.0)
58
+ multi_json
59
+ simplecov-html (~> 0.8.0)
60
+ simplecov-html (0.8.0)
61
+ thread_safe (0.3.5)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler (~> 1.0)
68
+ jeweler (~> 2.0.1)
69
+ mocha
70
+ rdoc (~> 3.12)
71
+ rest-client
72
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 dhunnapotha
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.rdoc ADDED
@@ -0,0 +1,24 @@
1
+ = thrustio-ruby
2
+
3
+ Ruby gem for thrustio api
4
+
5
+ == Usage
6
+
7
+ client = Thrust::AnyMail::Client.new(<secret_key>) #eg: Thrust::AnyMail::Client.new('yourkey')
8
+ client.search(<full_name_to_search>, <domain>) #eg: client.search("Gautam Chandra", "gmail.com")
9
+ client.searchesLeft
10
+
11
+ == Contributing to thrustio-ruby
12
+
13
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
14
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
15
+ * Fork the project.
16
+ * Start a feature/bugfix branch.
17
+ * Commit and push until you are happy with your contribution.
18
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
19
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
20
+
21
+ == Copyright
22
+
23
+ Copyright (c) 2015 Gautam Chandra. See LICENSE.txt for further details.
24
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "thrustio-ruby"
18
+ gem.homepage = "http://github.com/dhunnapotha/thrustio-ruby"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Ruby library for ThrustIO - as of now, just anymail}
21
+ gem.description = %Q{}
22
+ gem.email = "gautam4you@gmail.com"
23
+ gem.authors = ["Gautam Chandra"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "thrustio-ruby #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,45 @@
1
+ require 'rest-client'
2
+
3
+ module Thrust
4
+ module AnyMail
5
+
6
+ API_URL = "https://thrust.io/api/v1/mail"
7
+ SEARCH_URL = "#{API_URL}/search"
8
+ SEARCHES_LEFT_URL = "#{API_URL}/searchesLeft"
9
+
10
+ class Client
11
+
12
+ def initialize key
13
+ @secret_key = key
14
+ end
15
+
16
+ def search name, domain
17
+ params = build_search_params name, domain
18
+ response = JSON.parse(RestClient.post SEARCH_URL, params)
19
+ response['emails']
20
+ end
21
+
22
+ def searchesLeft
23
+ params = build_serches_left_params
24
+ response = JSON.parse(RestClient.post SEARCHES_LEFT_URL, params)
25
+ response['searches'].to_i
26
+ end
27
+
28
+ private
29
+
30
+ def build_serches_left_params
31
+ {
32
+ :key => @secret_key
33
+ }
34
+ end
35
+
36
+ def build_search_params name, domain
37
+ {
38
+ :name => name,
39
+ :domain => domain,
40
+ :key => @secret_key
41
+ }
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1 @@
1
+ require 'anymail/anymail'
data/test/helper.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'simplecov'
2
+ require 'thrustio-ruby'
3
+ require 'test/unit'
4
+ require 'mocha/test_unit'
5
+ require 'json'
6
+
7
+
8
+ module SimpleCov::Configuration
9
+ def clean_filters
10
+ @filters = []
11
+ end
12
+ end
13
+
14
+ SimpleCov.configure do
15
+ clean_filters
16
+ load_adapter 'test_frameworks'
17
+ end
18
+
19
+ ENV["COVERAGE"] && SimpleCov.start do
20
+ add_filter "/.rvm/"
21
+ end
22
+ require 'rubygems'
23
+ require 'bundler'
24
+ begin
25
+ Bundler.setup(:default, :development)
26
+ rescue Bundler::BundlerError => e
27
+ $stderr.puts e.message
28
+ $stderr.puts "Run `bundle install` to install missing gems"
29
+ exit e.status_code
30
+ end
31
+ require 'test/unit'
32
+
33
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
34
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
35
+ require 'thrustio-ruby'
36
+
37
+ class Test::Unit::TestCase
38
+ end
@@ -0,0 +1 @@
1
+ require 'helper'
@@ -0,0 +1,35 @@
1
+
2
+ class AnyMailClientTest < Test::Unit::TestCase
3
+
4
+ def test_constants
5
+ assert_equal "https://thrust.io/api/v1/mail", Thrust::AnyMail::API_URL
6
+ assert_equal "https://thrust.io/api/v1/mail/search", Thrust::AnyMail::SEARCH_URL
7
+ assert_equal "https://thrust.io/api/v1/mail/searchesLeft", Thrust::AnyMail::SEARCHES_LEFT_URL
8
+ end
9
+
10
+
11
+ def test_search_should_post_necessary_params_and_return_array_of_emails
12
+ client = Thrust::AnyMail::Client.new('dummy-key')
13
+ expected_params = {:name => "Gautam Chandra" , :domain => "gmail.com", :key => "dummy-key"}
14
+ stubbed_response = {:status => "success", :emails => ["gautam@gmail.com", "gautam.chandra@gmail.com"]}.to_json
15
+
16
+ RestClient.expects(:post).with("https://thrust.io/api/v1/mail/search", expected_params).returns(stubbed_response)
17
+
18
+ expected_emails = ["gautam@gmail.com", "gautam.chandra@gmail.com"]
19
+ assert_equal expected_emails, client.search("Gautam Chandra", "gmail.com")
20
+
21
+ end
22
+
23
+
24
+ def test_searches_left_should_post_necessary_params_and_return_the_count_of_searches_left
25
+ client = Thrust::AnyMail::Client.new('dummy-key')
26
+ expected_params = {:key => "dummy-key"}
27
+ stubbed_response = {:status => "success", :searches => "40"}.to_json
28
+
29
+ RestClient.expects(:post).with("https://thrust.io/api/v1/mail/searchesLeft", expected_params).returns(stubbed_response)
30
+
31
+ assert_equal 40, client.searchesLeft
32
+ end
33
+
34
+ end
35
+
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: thrustio-ruby 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "thrustio-ruby"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Gautam Chandra"]
14
+ s.date = "2015-05-26"
15
+ s.description = ""
16
+ s.email = "gautam4you@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/anymail/anymail.rb",
29
+ "lib/thrustio-ruby.rb",
30
+ "test/helper.rb",
31
+ "test/test_thrustio-ruby.rb",
32
+ "test/unit/test_anymail.rb",
33
+ "thrustio-ruby.gemspec"
34
+ ]
35
+ s.homepage = "http://github.com/dhunnapotha/thrustio-ruby"
36
+ s.licenses = ["MIT"]
37
+ s.rubygems_version = "2.2.2"
38
+ s.summary = "Ruby library for ThrustIO - as of now, just anymail"
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 4
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
45
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
48
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<rest-client>, [">= 0"])
51
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
52
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
53
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
54
+ s.add_dependency(%q<simplecov>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<rest-client>, [">= 0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_dependency(%q<simplecov>, [">= 0"])
62
+ end
63
+ end
64
+
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: thrustio-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gautam Chandra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ version_requirements: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ! '>='
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ name: rest-client
20
+ prerelease: false
21
+ requirement: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ! '>='
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '3.12'
33
+ name: rdoc
34
+ prerelease: false
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '3.12'
40
+ type: :development
41
+ - !ruby/object:Gem::Dependency
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ name: bundler
48
+ prerelease: false
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 2.0.1
61
+ name: jeweler
62
+ prerelease: false
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 2.0.1
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ name: simplecov
76
+ prerelease: false
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ description: ''
84
+ email: gautam4you@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - LICENSE.txt
89
+ - README.rdoc
90
+ files:
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - lib/anymail/anymail.rb
98
+ - lib/thrustio-ruby.rb
99
+ - test/helper.rb
100
+ - test/test_thrustio-ruby.rb
101
+ - test/unit/test_anymail.rb
102
+ - thrustio-ruby.gemspec
103
+ homepage: http://github.com/dhunnapotha/thrustio-ruby
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Ruby library for ThrustIO - as of now, just anymail
127
+ test_files: []