neonmob 0.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1 -0
- data/Manifest +8 -0
- data/Rakefile +12 -0
- data/lib/neon_mob.rb +38 -0
- data/lib/neonmob.rb +1 -0
- data/neonmob.gemspec +38 -0
- data/test/helper.rb +1 -0
- data/test/test_neon_mob.rb +45 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6ff1789a50f95cfafaed0c366cc23582cc397664
|
4
|
+
data.tar.gz: 872e942bee098a11dc197641a1fd17c4e32747f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62dbafcf5fd9343e81c7e7941ac93cc0986bed6d471f389a5ee41ea267fa27dd94b03fca83b1e88eb3625162ccc49ca031480598b60dc9609708e8dde4a60ebc
|
7
|
+
data.tar.gz: c6a18ae8c53020b70de5b511bd0453a7ba22a964a5d2ce83162a1c48d132647342f43a4c72b28b5be0384968bb359d5f2ecc1d479bdca46ccbf936c5bf99d02b
|
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
v0.0.0.pre Initial version
|
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'echoe'
|
2
|
+
|
3
|
+
Echoe.new('neonmob') do |gem|
|
4
|
+
gem.author = 'Sasha Gerrand'
|
5
|
+
gem.summary = 'API client for NeonMob.com'
|
6
|
+
gem.email = 'rubygems-neonmob@sgerrand.com'
|
7
|
+
gem.url = 'https://github.com/sgerrand/neonmob.rb'
|
8
|
+
gem.licenses = ['MIT']
|
9
|
+
gem.development_dependencies = ['minitest ~>0']
|
10
|
+
gem.runtime_dependencies = ['http ~>0']
|
11
|
+
gem.ignore_pattern = []
|
12
|
+
end
|
data/lib/neon_mob.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class NeonMob
|
5
|
+
URL = URI('https://www.neonmob.com')
|
6
|
+
|
7
|
+
def initialize(username, password)
|
8
|
+
@password = password
|
9
|
+
@username = username
|
10
|
+
end
|
11
|
+
|
12
|
+
def login
|
13
|
+
@login = post('/api/signin/', login_params).parse
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def logged_in?
|
19
|
+
@login['code'].nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
def login_params
|
23
|
+
{
|
24
|
+
:password => @password,
|
25
|
+
:username => @username,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def post(path, params = {})
|
30
|
+
HTTP[:accept => "application/json"].post(build_url(path), :json => params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_url(path)
|
34
|
+
URL.tap do |uri|
|
35
|
+
uri.path = path
|
36
|
+
end.to_s
|
37
|
+
end
|
38
|
+
end
|
data/lib/neonmob.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'neon_mob'
|
data/neonmob.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: neonmob 0.0.0.pre ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "neonmob"
|
6
|
+
s.version = "0.0.0.pre"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.require_paths = ["lib"]
|
10
|
+
s.authors = ["Sasha Gerrand"]
|
11
|
+
s.date = "2017-05-14"
|
12
|
+
s.description = "API client for NeonMob.com"
|
13
|
+
s.email = "rubygems-neonmob@sgerrand.com"
|
14
|
+
s.extra_rdoc_files = ["CHANGELOG", "lib/neon_mob.rb", "lib/neonmob.rb"]
|
15
|
+
s.files = ["CHANGELOG", "Manifest", "Rakefile", "lib/neon_mob.rb", "lib/neonmob.rb", "neonmob.gemspec", "test/helper.rb", "test/test_neon_mob.rb"]
|
16
|
+
s.homepage = "https://github.com/sgerrand/neonmob.rb"
|
17
|
+
s.licenses = ["MIT"]
|
18
|
+
s.rdoc_options = ["--line-numbers", "--title", "Neonmob"]
|
19
|
+
s.rubyforge_project = "neonmob"
|
20
|
+
s.rubygems_version = "2.4.5"
|
21
|
+
s.summary = "API client for NeonMob.com"
|
22
|
+
s.test_files = ["test/test_neon_mob.rb"]
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
s.specification_version = 4
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_runtime_dependency(%q<http>, ["~> 0"])
|
29
|
+
s.add_development_dependency(%q<minitest>, ["~> 0"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<http>, ["~> 0"])
|
32
|
+
s.add_dependency(%q<minitest>, ["~> 0"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<http>, ["~> 0"])
|
36
|
+
s.add_dependency(%q<minitest>, ["~> 0"])
|
37
|
+
end
|
38
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'minitest/autorun'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'neon_mob'
|
3
|
+
|
4
|
+
class TestNeonMob < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@adapter = Minitest::Mock.new
|
7
|
+
@response = Minitest::Mock.new
|
8
|
+
@subject = NeonMob.new('some_user', 'some_password')
|
9
|
+
@adapter.expect :post, @response, ['https://www.neonmob.com/api/signin/',
|
10
|
+
{
|
11
|
+
:json => {
|
12
|
+
:username => 'some_user',
|
13
|
+
:password => 'some_password',
|
14
|
+
}
|
15
|
+
}]
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_initialize_with_params
|
19
|
+
assert NeonMob.new('user', 'password')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_initialize_raises_error_without_params
|
23
|
+
assert_raises(ArgumentError) { NeonMob.new }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_login_succeeds
|
27
|
+
payload = {'redirect' => '/'}
|
28
|
+
@response.expect :parse, payload
|
29
|
+
HTTP.stub :[], @adapter do
|
30
|
+
assert_equal(payload, @subject.login)
|
31
|
+
end
|
32
|
+
@adapter.verify
|
33
|
+
@response.verify
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_login_fails
|
37
|
+
payload = {'code'=>'INVALID_LOGIN', 'field_errors'=>{}, 'detail'=>'Invalid login details, partner.'}
|
38
|
+
@response.expect :parse, payload
|
39
|
+
HTTP.stub :[], @adapter do
|
40
|
+
assert_equal(payload, @subject.login)
|
41
|
+
end
|
42
|
+
@adapter.verify
|
43
|
+
@response.verify
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neonmob
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0.pre
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sasha Gerrand
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: minitest
|
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: API client for NeonMob.com
|
42
|
+
email: rubygems-neonmob@sgerrand.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
46
|
+
- CHANGELOG
|
47
|
+
- lib/neon_mob.rb
|
48
|
+
- lib/neonmob.rb
|
49
|
+
files:
|
50
|
+
- CHANGELOG
|
51
|
+
- Manifest
|
52
|
+
- Rakefile
|
53
|
+
- lib/neon_mob.rb
|
54
|
+
- lib/neonmob.rb
|
55
|
+
- neonmob.gemspec
|
56
|
+
- test/helper.rb
|
57
|
+
- test/test_neon_mob.rb
|
58
|
+
homepage: https://github.com/sgerrand/neonmob.rb
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options:
|
64
|
+
- "--line-numbers"
|
65
|
+
- "--title"
|
66
|
+
- Neonmob
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '1.2'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project: neonmob
|
81
|
+
rubygems_version: 2.4.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: API client for NeonMob.com
|
85
|
+
test_files:
|
86
|
+
- test/test_neon_mob.rb
|