bomb_bomb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +11 -0
- data/bomb_bomb.gemspec +23 -0
- data/lib/bomb_bomb/version.rb +3 -0
- data/lib/bomb_bomb.rb +43 -0
- data/test/bomb_bomb_test.rb +44 -0
- data/test/test_helper.rb +11 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bafd47b8c63d4f9ddd0fef3f8a67e20895f0fc62
|
4
|
+
data.tar.gz: 1911e3bcd3ab765beefc38f495ad882d4f004491
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f3a7e9671d4240a3a567d44594b255aeb37fd9737548ef8404bc499fa9a4eafb2b6a7ae078a0c5aec130cf882386e0c981250b099ef890119e47f17cc0677b37
|
7
|
+
data.tar.gz: fc82d305d4798572e7ca624a364261193133312368072fe0147e01c0f0ade459669a908c70e3e2db7948f6e4d5e6b31fe73dba0bf1b88bed3ce633804191b31b
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Guille Carlos
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# BombBomb
|
2
|
+
[![CodeClimate](https://codeclimate.com/github/guillec/bomb_bomb.png)](https://codeclimate.com/github/guillec/bomb_bomb)
|
3
|
+
[![Build
|
4
|
+
Status](https://travis-ci.org/guillec/bomb_bomb.png)](https://travis-ci.org/guillec/bomb_bomb)
|
5
|
+
|
6
|
+
TODO: Write a gem description
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'bomb_bomb'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install bomb_bomb
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
TODO: Write usage instructions here
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bomb_bomb.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bomb_bomb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bomb_bomb"
|
8
|
+
spec.version = BombBomb::VERSION
|
9
|
+
spec.authors = ["Guille Carlos"]
|
10
|
+
spec.email = ["guille@bitpop.in"]
|
11
|
+
spec.description = %q{Gem for the BombBomb API}
|
12
|
+
spec.summary = %q{Gem for the BombBomb API}
|
13
|
+
spec.homepage = "https://github.com/guillec/bomb_bomb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/bomb_bomb.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require "bomb_bomb/version"
|
2
|
+
require "net/http"
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module BombBomb
|
6
|
+
|
7
|
+
class API
|
8
|
+
def initialize(email, pw)
|
9
|
+
@email = email
|
10
|
+
@pw = pw
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(method, args)
|
14
|
+
parsed_response = make_call(method, args)
|
15
|
+
parsed_response
|
16
|
+
end
|
17
|
+
|
18
|
+
def method_missing(method, *args)
|
19
|
+
method = camelize_method(method)
|
20
|
+
call(method, args)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def param_fields(args)
|
25
|
+
params = {}
|
26
|
+
params["email"] = @email
|
27
|
+
params["pw"] = @pw
|
28
|
+
params = args.first.merge(params) if args.first
|
29
|
+
params
|
30
|
+
end
|
31
|
+
|
32
|
+
def make_call(method, args)
|
33
|
+
uri = URI("https://app.bombbomb.com/app/api/api.php?method=#{method}")
|
34
|
+
response = Net::HTTP.post_form(uri, param_fields(args))
|
35
|
+
JSON.load("[#{response.body}]").first
|
36
|
+
end
|
37
|
+
|
38
|
+
def camelize_method(method)
|
39
|
+
method = method.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
40
|
+
testmethod = method[0].chr.upcase + method[1..-1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "bomb_bomb"
|
3
|
+
require "minitest/mock"
|
4
|
+
|
5
|
+
describe "BombBomb API method calls samples" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@email = "guille@fivestreet.com"
|
9
|
+
@pw = "12345"
|
10
|
+
@bomb = BombBomb::API.new(@email, @pw)
|
11
|
+
|
12
|
+
#Fake Response
|
13
|
+
FakeResponse = Struct.new(:body)
|
14
|
+
@response = FakeResponse.new("{}")
|
15
|
+
@mock = MiniTest::Mock.new
|
16
|
+
@mock.expect :body, @response.body
|
17
|
+
end
|
18
|
+
|
19
|
+
it "checks if login is valid" do
|
20
|
+
|
21
|
+
Net::HTTP.stub(:post_form, @mock) do
|
22
|
+
@bomb.is_valid_login
|
23
|
+
end
|
24
|
+
|
25
|
+
assert @mock.verify
|
26
|
+
end
|
27
|
+
|
28
|
+
it "gets all lists" do
|
29
|
+
Net::HTTP.stub(:post_form, @mock) do
|
30
|
+
@bomb.get_lists
|
31
|
+
end
|
32
|
+
|
33
|
+
assert @mock.verify
|
34
|
+
end
|
35
|
+
|
36
|
+
it "gets contacts of a list" do
|
37
|
+
Net::HTTP.stub(:post_form, @mock) do
|
38
|
+
@bomb.get_list_contacts( :list_id => "idtolist")
|
39
|
+
end
|
40
|
+
|
41
|
+
assert @mock.verify
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bomb_bomb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guille Carlos
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-21 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: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
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
|
+
description: Gem for the BombBomb API
|
42
|
+
email:
|
43
|
+
- guille@bitpop.in
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- bomb_bomb.gemspec
|
54
|
+
- lib/bomb_bomb.rb
|
55
|
+
- lib/bomb_bomb/version.rb
|
56
|
+
- test/bomb_bomb_test.rb
|
57
|
+
- test/test_helper.rb
|
58
|
+
homepage: https://github.com/guillec/bomb_bomb
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.0.3
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Gem for the BombBomb API
|
82
|
+
test_files:
|
83
|
+
- test/bomb_bomb_test.rb
|
84
|
+
- test/test_helper.rb
|