roqua-rom-api 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bde7b277fe62ad02a254c9b2178396c604d84a59
4
+ data.tar.gz: 2837225a0fa190fa140be2c54b40fd7a8c527f5d
5
+ SHA512:
6
+ metadata.gz: a86a5bce3202da7c8f33303469ed2d1d0f5d5972284adff5c260c746a2517816182243a853c4589e5d72d49e4442bba313d3d9e75c68d7c0d5cb639f63aa3ff6
7
+ data.tar.gz: 8114eae0d7166e741dedd0d6ae86ce260bc5bec8ab154af2f7011aa4500d47f623db2aeb253b95a16e788f1508e884263211507fcc435ee38b245afdd8b56d9e
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,49 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # jeweler generated
16
+ pkg
17
+
18
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
19
+ #
20
+ # * Create a file at ~/.gitignore
21
+ # * Include files you want ignored
22
+ # * Run: git config --global core.excludesfile ~/.gitignore
23
+ #
24
+ # After doing this, these files will be ignored in all your git projects,
25
+ # saving you from having to 'pollute' every project you touch with them
26
+ #
27
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
28
+ #
29
+ # For MacOS:
30
+ #
31
+ #.DS_Store
32
+
33
+ # For TextMate
34
+ #*.tmproj
35
+ #tmtags
36
+
37
+ # For emacs:
38
+ #*~
39
+ #\#*
40
+ #.\#*
41
+
42
+ # For vim:
43
+ #*.swp
44
+
45
+ # For redcar:
46
+ #.redcar
47
+
48
+ # For rubinius:
49
+ #*.rbc
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'guard-rspec', '~> 4.2.6'
7
+ gem 'fuubar', '~> 1.3.2'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ roqua-rom-api (0.0.1)
5
+ active_interaction (~> 1.0.4)
6
+ httparty (~> 0.12.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ active_interaction (1.0.4)
12
+ activemodel (>= 3, < 5)
13
+ activemodel (4.0.2)
14
+ activesupport (= 4.0.2)
15
+ builder (~> 3.1.0)
16
+ activesupport (4.0.2)
17
+ i18n (~> 0.6, >= 0.6.4)
18
+ minitest (~> 4.2)
19
+ multi_json (~> 1.3)
20
+ thread_safe (~> 0.1)
21
+ tzinfo (~> 0.3.37)
22
+ atomic (1.1.14)
23
+ builder (3.1.4)
24
+ celluloid (0.15.2)
25
+ timers (~> 1.1.0)
26
+ celluloid-io (0.15.0)
27
+ celluloid (>= 0.15.0)
28
+ nio4r (>= 0.5.0)
29
+ coderay (1.1.0)
30
+ diff-lcs (1.2.5)
31
+ ffi (1.9.3)
32
+ formatador (0.2.4)
33
+ fuubar (1.3.2)
34
+ rspec (>= 2.14.0, < 3.1.0)
35
+ ruby-progressbar (~> 1.3)
36
+ guard (2.4.0)
37
+ formatador (>= 0.2.4)
38
+ listen (~> 2.1)
39
+ lumberjack (~> 1.0)
40
+ pry (>= 0.9.12)
41
+ thor (>= 0.18.1)
42
+ guard-rspec (4.2.6)
43
+ guard (~> 2.1)
44
+ rspec (>= 2.14, < 4.0)
45
+ httparty (0.12.0)
46
+ json (~> 1.8)
47
+ multi_xml (>= 0.5.2)
48
+ i18n (0.6.9)
49
+ json (1.8.1)
50
+ listen (2.5.0)
51
+ celluloid (>= 0.15.2)
52
+ celluloid-io (>= 0.15.0)
53
+ rb-fsevent (>= 0.9.3)
54
+ rb-inotify (>= 0.9)
55
+ lumberjack (1.0.4)
56
+ method_source (0.8.2)
57
+ minitest (4.7.5)
58
+ multi_json (1.8.4)
59
+ multi_xml (0.5.5)
60
+ nio4r (1.0.0)
61
+ pry (0.9.12.6)
62
+ coderay (~> 1.0)
63
+ method_source (~> 0.8)
64
+ slop (~> 3.4)
65
+ rake (10.1.1)
66
+ rb-fsevent (0.9.4)
67
+ rb-inotify (0.9.3)
68
+ ffi (>= 0.5.0)
69
+ rspec (2.14.1)
70
+ rspec-core (~> 2.14.0)
71
+ rspec-expectations (~> 2.14.0)
72
+ rspec-mocks (~> 2.14.0)
73
+ rspec-core (2.14.7)
74
+ rspec-expectations (2.14.5)
75
+ diff-lcs (>= 1.1.3, < 2.0)
76
+ rspec-mocks (2.14.5)
77
+ ruby-progressbar (1.4.1)
78
+ slop (3.4.7)
79
+ thor (0.18.1)
80
+ thread_safe (0.1.3)
81
+ atomic
82
+ timers (1.1.0)
83
+ tzinfo (0.3.38)
84
+ yard (0.8.7.3)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bundler (~> 1.0)
91
+ fuubar (~> 1.3.2)
92
+ guard-rspec (~> 4.2.6)
93
+ rake (~> 10.1)
94
+ roqua-rom-api!
95
+ yard (~> 0.8)
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec, cmd: 'bundle exec rspec --format Fuubar --colour' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Samuel Esposito
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.md ADDED
@@ -0,0 +1,18 @@
1
+ # roqua-rom-api
2
+
3
+ Description goes here.
4
+
5
+ ## Contributing to roqua-rom-api
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * 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.
14
+
15
+ ## Copyright
16
+
17
+ Copyright (c) 2014 Samuel Esposito. See LICENSE.txt for further details.
18
+
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+
4
+ begin
5
+ require 'bundler'
6
+ rescue LoadError => e
7
+ warn e.message
8
+ warn "Run `gem install bundler` to install Bundler."
9
+ exit(-1)
10
+ end
11
+
12
+ begin
13
+ Bundler.setup(:development)
14
+ rescue Bundler::BundlerError => e
15
+ warn e.message
16
+ warn "Run `bundle install` to install missing gems."
17
+ exit e.status_code
18
+ end
19
+
20
+ require 'rake'
21
+
22
+ task test: :spec
23
+ task default: :spec
24
+
25
+ require "bundler/gem_tasks"
26
+
27
+ require 'yard'
28
+ YARD::Rake::YardocTask.new
29
+ task doc: :yard
@@ -0,0 +1,53 @@
1
+ require 'httparty'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ class Base
6
+ def self.get(url, params = {})
7
+ # TODO: Handle http basic authentication here
8
+ HTTParty.get(api_base + url + '.json', query: params, basic_auth: authentication)
9
+ end
10
+
11
+ def self.post(url, params = {})
12
+ # TODO: Handle http basic authentication here
13
+ HTTParty.post(api_base + url + '.json', query: params, basic_auth: authentication)
14
+ end
15
+
16
+ def self.put(url, params = {})
17
+ # TODO: Handle http basic authentication here
18
+ HTTParty.put(api_base + url + '.json', query: params, basic_auth: authentication)
19
+ end
20
+
21
+ def self.delete(url, params = {})
22
+ # TODO: Handle http basic authentication here
23
+ HTTParty.delete(api_base + url + '.json', query: params, basic_auth: authentication)
24
+ end
25
+
26
+ private
27
+
28
+ def self.rom_host
29
+ @roqua_rom_host || ENV['ROQUA_ROM_HOST']
30
+ end
31
+
32
+ def self.username
33
+ @roqua_rom_key || ENV['ROQUA_ROM_KEY']
34
+ end
35
+
36
+ def self.password
37
+ @roqua_rom_secret || ENV['ROQUA_ROM_SECRET']
38
+ end
39
+
40
+ def self.authentication
41
+ {username: username, password: password}
42
+ end
43
+
44
+ def self.api_path
45
+ '/api/v1'
46
+ end
47
+
48
+ def self.api_base
49
+ rom_host + api_path
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,17 @@
1
+ module Roqua
2
+ module RomApi
3
+ class StartProtocolSubscription < ActiveInteraction::Base
4
+ string :dossier_id
5
+ string :protocol_key
6
+ time :start_at, default: nil
7
+ integer :daily_start_time, default: nil
8
+
9
+ def execute
10
+ Base.post '/protocol_subscriptions', dossier_id: dossier_id,
11
+ protocol_key: protocol_key,
12
+ start_at: (start_at.to_i if start_at),
13
+ daily_start_time: daily_start_time
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module Roqua
2
+ module RomApi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ require 'roqua/rom_api/version'
2
+ require 'active_interaction'
3
+ require 'roqua/rom_api/base'
4
+ require 'roqua/rom_api/start_protocol_subscription'
@@ -0,0 +1 @@
1
+ require 'roqua/rom_api'
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/roqua/rom_api/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "roqua-rom-api"
6
+ gem.version = Roqua::RomApi::VERSION
7
+ gem.summary = %q{API wrapper gem around RoQua's ROM API}
8
+ gem.description = %q{Provides authenticated access to ROM utilities}
9
+ gem.license = "MIT"
10
+ gem.authors = ["Samuel Esposito"]
11
+ gem.email = "s.esposito@roqua.nl"
12
+ gem.homepage = "https://github.com/roqua/rom/blob/master/rom_api/README.md"
13
+
14
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ['lib']
18
+
19
+ gem.add_dependency 'httparty', '~> 0.12.0'
20
+ gem.add_dependency 'active_interaction', '~> 1.0.4'
21
+
22
+ gem.add_development_dependency 'bundler', '~> 1.0'
23
+ gem.add_development_dependency 'rake', '~> 10.1'
24
+ gem.add_development_dependency 'yard', '~> 0.8'
25
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ module Roqua
4
+ describe RomApi::Base do
5
+ let(:url) { '/some/url' }
6
+ let(:params) { {some: 'params'} }
7
+ before do
8
+ RomApi::Base.instance_eval do
9
+ @roqua_rom_host = 'http://roqua.dev'
10
+ @roqua_rom_key = 'uname'
11
+ @roqua_rom_secret = 'pwd'
12
+ end
13
+ end
14
+
15
+ describe '.get' do
16
+ it 'performs a get request to a rom_api passing in some parameters' do
17
+ expect(HTTParty).to receive(:get).with('http://roqua.dev/api/v1/some/url.json',
18
+ query: params,
19
+ basic_auth: {username: 'uname', password: 'pwd'})
20
+ RomApi::Base.get(url, params)
21
+ end
22
+ end
23
+
24
+ describe '.post' do
25
+ it 'performs a get request to a rom_api passing in some parameters' do
26
+ expect(HTTParty).to receive(:post).with('http://roqua.dev/api/v1/some/url.json',
27
+ query: params,
28
+ basic_auth: {username: 'uname', password: 'pwd'})
29
+ RomApi::Base.post(url, params)
30
+ end
31
+ end
32
+
33
+ describe '.put' do
34
+ it 'performs a get request to a rom_api passing in some parameters' do
35
+ expect(HTTParty).to receive(:put).with('http://roqua.dev/api/v1/some/url.json',
36
+ query: params,
37
+ basic_auth: {username: 'uname', password: 'pwd'})
38
+ RomApi::Base.put(url, params)
39
+ end
40
+ end
41
+
42
+ describe '.delete' do
43
+ it 'performs a get request to a rom_api passing in some parameters' do
44
+ expect(HTTParty).to receive(:delete).with('http://roqua.dev/api/v1/some/url.json',
45
+ query: params,
46
+ basic_auth: {username: 'uname', password: 'pwd'})
47
+ RomApi::Base.delete(url, params)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe StartProtocolSubscription do
4
+ it 'does a post to the rom protocol_subscription api' do
5
+ options = {dossier_id: 'some_dossier_id',
6
+ protocol_key: 'some_key',
7
+ start_at: Time.now,
8
+ daily_start_time: 32400} # nine o'clock
9
+ expect(Base).to receive(:post).with '/protocol_subscriptions', dossier_id: options[:dossier_id],
10
+ protocol_key: options[:protocol_key],
11
+ start_at: options[:start_at].to_i,
12
+ daily_start_time: options[:daily_start_time]
13
+ StartProtocolSubscription.run(options)
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Roqua::RomApi do
4
+ it "should have a VERSION constant" do
5
+ expect(subject.const_get('VERSION')).to_not be_empty
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require 'rspec'
2
+ require 'roqua-rom-api'
3
+ include Roqua::RomApi
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roqua-rom-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Esposito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.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.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: active_interaction
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.8'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.8'
83
+ description: Provides authenticated access to ROM utilities
84
+ email: s.esposito@roqua.nl
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - ".document"
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - Guardfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/roqua-rom-api.rb
98
+ - lib/roqua/rom_api.rb
99
+ - lib/roqua/rom_api/base.rb
100
+ - lib/roqua/rom_api/start_protocol_subscription.rb
101
+ - lib/roqua/rom_api/version.rb
102
+ - roqua_rom_api.gemspec
103
+ - spec/lib/roqua/rom_api/base_spec.rb
104
+ - spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
105
+ - spec/lib/roqua_rom_api_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: https://github.com/roqua/rom/blob/master/rom_api/README.md
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.1
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: API wrapper gem around RoQua's ROM API
131
+ test_files:
132
+ - spec/lib/roqua/rom_api/base_spec.rb
133
+ - spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
134
+ - spec/lib/roqua_rom_api_spec.rb
135
+ - spec/spec_helper.rb
136
+ has_rdoc: