restpack_core_service 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -0
- data/README.md +8 -24
- data/lib/restpack_core_service/services/domain/by_identifier.rb +28 -9
- data/lib/restpack_core_service/version.rb +1 -1
- data/restpack_core_service.gemspec +1 -0
- data/spec/services/domain/by_identifier_spec.rb +11 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 504634bab2bf42ecded107859f2945e18a0df86f
|
4
|
+
data.tar.gz: d8d5fedf8d9dce3edc41bc5d3cf6bbce4e254be7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8bd5796073fbd62000fe529561a636508aaa2039561e04cd86c46fcff8bc00dbc54446bf087ea0805edc11c9acaa44f3381f9e72bb21eb4b5e168ec841b9f4a
|
7
|
+
data.tar.gz: bc2c6b127ba0757ea07d0ed3006ecb3db2613f3e55551ea9b7f28bd6b46a1d39939ea15d4d0126074279d6e272d0ff19c4859f6c267798acda098b10d6063f40
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.0.0
|
4
|
+
#http://reefpoints.dockyard.com/ruby/2013/03/29/running-postgresql-9-2-on-travis-ci.html
|
5
|
+
before_script:
|
6
|
+
- sudo /etc/init.d/postgresql stop
|
7
|
+
- sudo cp /etc/postgresql/9.1/main/pg_hba.conf ./
|
8
|
+
- sudo apt-get remove postgresql postgresql-9.1 -qq --purge
|
9
|
+
- source /etc/lsb-release
|
10
|
+
- echo "deb http://apt.postgresql.org/pub/repos/apt/ $DISTRIB_CODENAME-pgdg main" > pgdg.list
|
11
|
+
- sudo mv pgdg.list /etc/apt/sources.list.d/
|
12
|
+
- wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
|
13
|
+
- sudo apt-get update
|
14
|
+
- sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install postgresql-9.2 postgresql-contrib-9.2 -qq
|
15
|
+
- sudo /etc/init.d/postgresql stop
|
16
|
+
- sudo cp ./pg_hba.conf /etc/postgresql/9.2/main
|
17
|
+
- sudo /etc/init.d/postgresql start
|
18
|
+
- psql -c 'create database restpack_core_service_test;' -U postgres
|
19
|
+
- psql -c 'create role travis login;' -U postgres
|
20
|
+
script: bundle exec rake test
|
data/README.md
CHANGED
@@ -1,29 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# restpack_core_service
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/RestPack/restpack_core_service.png?branch=master)](https://travis-ci.org/RestPack/restpack_core_service) [![Code Climate](https://codeclimate.com/github/RestPack/restpack_core_service.png)](https://codeclimate.com/github/RestPack/restpack_core_service) [![Dependency Status](https://gemnasium.com/RestPack/restpack_core_service.png)](https://gemnasium.com/RestPack/restpack_core_service) [![Gem Version](https://badge.fury.io/rb/restpack_core_service.png)](http://badge.fury.io/rb/restpack_core_service)
|
4
4
|
|
5
|
-
|
5
|
+
**Work In Progress**
|
6
6
|
|
7
|
-
|
7
|
+
This gem provides services for managing Applications and Domains.
|
8
8
|
|
9
|
-
|
9
|
+
## Development Setup
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install restpack_core_service
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
11
|
+
1. install postgres
|
12
|
+
2. create a `restpack_core_service_test` database
|
13
|
+
3. rake
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'public_suffix'
|
2
|
+
|
1
3
|
module RestPack::Core::Service::Commands::Domain
|
2
4
|
class ByIdentifier < RestPack::Service::Command
|
3
5
|
required do
|
@@ -9,15 +11,32 @@ module RestPack::Core::Service::Commands::Domain
|
|
9
11
|
end
|
10
12
|
|
11
13
|
def execute
|
12
|
-
|
13
|
-
inputs,
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
result
|
19
|
-
|
20
|
-
|
14
|
+
identifiers = [
|
15
|
+
inputs[:identifier],
|
16
|
+
get_domain(identifier)
|
17
|
+
]
|
18
|
+
|
19
|
+
identifiers.reject(&:nil?).each do |identifier|
|
20
|
+
result = Core::Serializers::DomainSerializer.resource(
|
21
|
+
inputs,
|
22
|
+
Core::Models::Domain.where(identifier: identifier)
|
23
|
+
)
|
24
|
+
|
25
|
+
if result[:domains].any?
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
status :not_found
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def get_domain(identifier)
|
36
|
+
begin
|
37
|
+
PublicSuffix.parse(identifier).domain
|
38
|
+
rescue
|
39
|
+
nil
|
21
40
|
end
|
22
41
|
end
|
23
42
|
end
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "restpack_service"
|
22
22
|
spec.add_dependency "restpack_serializer"
|
23
23
|
spec.add_dependency "restpack_gem"
|
24
|
+
spec.add_dependency "public_suffix", "~> 1.3.1"
|
24
25
|
spec.add_dependency "sinatra", "~> 1.4.3"
|
25
26
|
spec.add_dependency "pg", "~> 0.16"
|
26
27
|
|
@@ -29,6 +29,17 @@ describe Core::Commands::Domain::ByIdentifier do
|
|
29
29
|
response.result[:applications].length.should == 1
|
30
30
|
response.result[:applications].first[:id].should == @domain.application_id.to_s
|
31
31
|
end
|
32
|
+
|
33
|
+
context 'with subdomain in identifier' do
|
34
|
+
let(:params) { {
|
35
|
+
identifier: "www.#{@domain.identifier}",
|
36
|
+
includes: 'applications'
|
37
|
+
} }
|
38
|
+
|
39
|
+
it 'is valid' do
|
40
|
+
response.success?.should == true
|
41
|
+
end
|
42
|
+
end
|
32
43
|
end
|
33
44
|
|
34
45
|
context 'with invalid :identifier' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restpack_core_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin Joyce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: restpack_service
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: public_suffix
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.3.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.3.1
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: sinatra
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -187,6 +201,7 @@ extra_rdoc_files: []
|
|
187
201
|
files:
|
188
202
|
- .gitignore
|
189
203
|
- .rspec
|
204
|
+
- .travis.yml
|
190
205
|
- Gemfile
|
191
206
|
- LICENSE.txt
|
192
207
|
- README.md
|