applocate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 468efd2520ecc1a8d0ca539261a7105cecd61013
4
+ data.tar.gz: e3d93987a697c56958ca289c88c766848b27630e
5
+ SHA512:
6
+ metadata.gz: 854a0c54742a9071e84e9ea0d966aab1abd9d29c689a3d8a64cb5164290f25c5158c0e92b4b12b64a0e845cba2b5d28ca76e341e4784671d60b8ee6c90ed913a
7
+ data.tar.gz: 5fa73757974f74738dcd77969ef613bf89c5e89a9cf55424d2108f69ea9f7200dd0b3e38a447f068c74ab3a499f023152dde1446ab1203b6535e673d855b638b
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,82 @@
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/**/*
4
+ - bin/**/*
5
+ - db/**/*
6
+ - Guardfile
7
+ - applocate.gemspec
8
+
9
+ Style/RescueModifier:
10
+ Enabled: false
11
+
12
+ LineLength:
13
+ Enabled: false
14
+
15
+ MethodLength:
16
+ Max: 16
17
+ Enabled: false
18
+
19
+ ClassLength:
20
+ Enabled: true
21
+
22
+ Metrics/AbcSize:
23
+ Max: 32
24
+
25
+ Documentation:
26
+ # don't require classes to be documented
27
+ Enabled: false
28
+
29
+ CollectionMethods:
30
+ # don't prefer map to collect, recuce to inject
31
+ Enabled: true
32
+
33
+ Encoding:
34
+ # no need to always specify encoding
35
+ Enabled: false
36
+
37
+ StringLiterals:
38
+ # use single or double-quoted strings, as you please
39
+ Enabled: false
40
+
41
+ PerlBackrefs:
42
+ # TODO: regular expression matching with $1, $2, etc.
43
+ Enabled: false
44
+
45
+ BlockNesting:
46
+ # TODO: fix too much nesting
47
+ Max: 4
48
+
49
+ Blocks:
50
+ # allow multi-line blocks like expect {}
51
+ Enabled: false
52
+
53
+ WordArray:
54
+ # %w vs. ['', ...]
55
+ Enabled: false
56
+
57
+ CyclomaticComplexity:
58
+ Enabled: false
59
+
60
+ DoubleNegation:
61
+ Enabled: false
62
+
63
+ RedundantSelf:
64
+ Enabled: false
65
+
66
+ PredicateName:
67
+ Enabled: false
68
+
69
+ Style/IfUnlessModifier:
70
+ MaxLineLength: 120
71
+
72
+ Style/BracesAroundHashParameters:
73
+ Enabled: false
74
+
75
+ Style/TrivialAccessors:
76
+ Enabled: false
77
+
78
+ Style/GuardClause:
79
+ Enabled: false
80
+
81
+ Lint/UnusedBlockArgument:
82
+ Enabled: false
@@ -0,0 +1,16 @@
1
+ before_install:
2
+ - gem install bundler
3
+ - gem install rake
4
+
5
+ language: ruby
6
+
7
+ cache: bundler
8
+
9
+ rvm:
10
+ - 2.1.5
11
+ - 2.2.0
12
+
13
+ notifications:
14
+ email: false
15
+
16
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in applocate.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'pry'
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'guard-bundler'
11
+ gem 'guard-rubocop'
12
+ gem 'rb-fsevent'
13
+ gem 'growl'
14
+ gem 'json'
15
+ gem 'github-markup'
16
+ gem 'rubocop'
17
+ end
@@ -0,0 +1,20 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ group :specs, halt_on_fail: true do
5
+ guard :rspec, cmd: 'bundle exec rspec' do
6
+ watch(%r{^spec/.+_spec\.rb$})
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec/" }
9
+ end
10
+
11
+ guard :rubocop do
12
+ watch(%r{^lib/(.+)\.rb$})
13
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
14
+ end
15
+ end
16
+
17
+ guard 'bundler' do
18
+ watch('Gemfile')
19
+ watch(/^.+\.gemspec/)
20
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Mark Madsen and AGiLE ANiMAL INC.
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.
@@ -0,0 +1,70 @@
1
+ # Applocate
2
+
3
+ This gem provides access to the Applocate API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'applocate'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install applocate
20
+
21
+ ## Usage
22
+
23
+ The Applocate gem will allow you to register devices with Applocate and then allow you to
24
+ push down restrictions profiles, app installations.
25
+
26
+ In order to access the API you will require a private token and a key.
27
+
28
+ You can set them as ENV variables ```APPLOCATE_TOKEN``` and ```APPLOCATE_SECRET``` or you can specify them in your
29
+ config as an initializer file. If you are connecting to a private Applocate server you can specify the base URL of
30
+ the server with ```APPLOCATE_BASE_URL```
31
+
32
+ ```ruby
33
+ #/config/initializers/applocate.rb
34
+
35
+ Applocate.configure do |config|
36
+ config.token = ENV['APPLOCATE_TOKEN']
37
+ config.secret = ENV['APPLOCATE_SECRET']
38
+ config.base_url = ENV['BASE_URL']
39
+ end
40
+ ```
41
+
42
+ Currently the following methods are supported:
43
+
44
+ ```ruby
45
+ # expected options -> { uuid: "ABCD-DCCDDC-12394812389-CDC" }
46
+ Applocate::API.restrict(options)
47
+ # returns a list (Array) of UUIDs with their status from the command.
48
+
49
+ # expected options -> { uuid: "ABCD-DCCDDC-12394812389-CDC" }
50
+ Applocate::API.unrestrict(options)
51
+ # returns a list (Array) of UUIDs with their status from the command.
52
+
53
+
54
+ # expected options -> { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "003274092" }
55
+ Applocate::API.install_app(options)
56
+ # returns a list (Array) of UUIDs with their status from the command.
57
+
58
+
59
+ # expected options -> { uuid: "ABCD-DCCDDC-12394812389-CDC" }
60
+ Applocate::API.app_list(options)
61
+ # returns a list (Array) of UUIDs with their apps.
62
+ ```
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it ( https://github.com/[my-github-username]/applocate/fork )
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create a new Pull Request
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :test, :development
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task :spec
13
+ require 'rainbow/ext/string' unless String.respond_to?(:color)
14
+ require 'rubocop/rake_task'
15
+ RuboCop::RakeTask.new(:rubocop)
16
+
17
+ task default: [:rubocop, :spec]
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'applocate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "applocate"
8
+ spec.version = Applocate::VERSION
9
+ spec.authors = ["Mark Madsen"]
10
+ spec.email = ["mm@idyll.io"]
11
+ spec.summary = 'Server API client for Applocate'
12
+ spec.description = 'Connect to applocate and provision devices and push profiles.'
13
+ spec.homepage = 'https://www.applocate.com'
14
+ spec.license = "MIT"
15
+
16
+ spec.add_runtime_dependency 'httparty'
17
+
18
+ spec.add_development_dependency 'yard'
19
+ spec.add_development_dependency 'rspec'
20
+ spec.add_development_dependency 'bundler', "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+
23
+ spec.files = `git ls-files -z`.split("\x0")
24
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
26
+ spec.require_paths = ["lib"]
27
+ end
@@ -0,0 +1,7 @@
1
+ require "applocate/version"
2
+ require "applocate/configuration"
3
+ require "applocate/api"
4
+
5
+ module Applocate
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,42 @@
1
+ require "httparty"
2
+
3
+ module Applocate
4
+ class API
5
+ include HTTParty
6
+ base_uri Applocate.configuration.base_url
7
+ headers 'Content-Type' => "application/json"
8
+ format :plain
9
+
10
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
11
+ def self.restrict(options)
12
+ response = self.post('/deploy/profile', body: options.to_json)
13
+ JSON.parse response.body rescue []
14
+ end
15
+
16
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
17
+ def self.unrestrict(options)
18
+ response = self.delete('/deploy/profile', body: options.to_json)
19
+ JSON.parse response.body rescue []
20
+ end
21
+
22
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "003274092" }
23
+ def self.install_app(options)
24
+ response = self.post('/deploy/app', body: options.to_json)
25
+ JSON.parse response.body rescue []
26
+ end
27
+
28
+ # expected options { uuid: "ABCD-DCCDDC-12394812389-CDC" }
29
+ def self.app_list(options)
30
+ response = self.post('/deploy/app_list', body: options.to_json)
31
+ JSON.parse response.body rescue []
32
+ end
33
+
34
+ def self.key
35
+ Applocate.configuration.token
36
+ end
37
+
38
+ def self.secret
39
+ Applocate.configuration.secret
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,25 @@
1
+ module Applocate
2
+ class Configuration
3
+ attr_accessor :token
4
+ attr_accessor :secret
5
+ attr_accessor :base_url
6
+
7
+ def initialize
8
+ @token = ENV["APPLOCATE_TOKEN"]
9
+ @secret = ENV["APPLOCATE_SECRET"]
10
+ @base_url = ENV["BASE_URL"] || "https://www.applocate.com/api/v1"
11
+ end
12
+ end
13
+
14
+ class << self
15
+ attr_accessor :configuration
16
+ end
17
+
18
+ def self.configuration
19
+ @configuration ||= Configuration.new
20
+ end
21
+
22
+ def self.configure
23
+ yield(configuration)
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Applocate
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ describe Applocate::API do
4
+ describe 'configuration' do
5
+ subject { Applocate::API }
6
+ before(:all) {
7
+ Applocate.configure do |config|
8
+ config.token = 'token'
9
+ config.secret = 'secret'
10
+ end
11
+ }
12
+
13
+ it 'uses the configured key' do
14
+ expect(subject.key).to eq('token')
15
+ end
16
+ it 'uses the configured secret' do
17
+ expect(subject.secret).to eq('secret')
18
+ end
19
+ it 'uses the base URI to be set to the default' do
20
+ expect(subject.base_uri).to eq("https://www.applocate.com/api/v1")
21
+ end
22
+ end
23
+
24
+ describe '.restrict' do
25
+ it 'pushes restrictions to a list of devices' do
26
+ device_list = { uuid: "ABCD-DCCDDC-12394812389-CDC" }
27
+ results = []
28
+
29
+ Applocate::API.should_receive(:post)
30
+ .with('/deploy/profile', body: device_list.to_json)
31
+ .and_return(results)
32
+
33
+ Applocate::API.restrict device_list
34
+ end
35
+
36
+ describe '.unrestrict' do
37
+ it 'removes the restrictions profile from devices' do
38
+ device_list = { uuid: "ABCD-DCCDDC-12394812389-CDC" }
39
+ results = []
40
+
41
+ Applocate::API.should_receive(:delete)
42
+ .with('/deploy/profile', body: device_list.to_json)
43
+ .and_return(results)
44
+
45
+ Applocate::API.unrestrict device_list
46
+ end
47
+ end
48
+
49
+ describe '.install_app' do
50
+ it 'removes the restrictions profile from devices' do
51
+ options = { uuid: "ABCD-DCCDDC-12394812389-CDC", itunes_id: "00123487" }
52
+ results = []
53
+
54
+ Applocate::API.should_receive(:post)
55
+ .with('/deploy/app', body: options.to_json)
56
+ .and_return(results)
57
+
58
+ Applocate::API.install_app options
59
+ end
60
+ end
61
+
62
+ describe '.app_list' do
63
+ it 'removes the restrictions profile from devices' do
64
+ device_list = { uuid: "ABCD-DCCDDC-12394812389-CDC" }
65
+ results = []
66
+
67
+ Applocate::API.should_receive(:post)
68
+ .with('/deploy/app_list', body: device_list.to_json)
69
+ .and_return(results)
70
+
71
+ Applocate::API.app_list device_list
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Applocate do
4
+ it "has a version" do
5
+ expect(Applocate::VERSION).to_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Applocate::Configuration do
4
+ describe 'configure' do
5
+ describe 'with ENV variables' do
6
+ before(:all) {
7
+ ENV["APPLOCATE_TOKEN"] = "APPLOCATE_TOKEN"
8
+ ENV["APPLOCATE_SECRET"] = "APPLOCATE_SECRET"
9
+ ENV["BASE_URL"] = "BASE_URL"
10
+ }
11
+
12
+ it 'adds a friend as a participant to the current conversation' do
13
+ expect(subject.token).to eq('APPLOCATE_TOKEN')
14
+ end
15
+
16
+ it 'adds a friend as a participant to the current conversation' do
17
+ expect(subject.secret).to eq('APPLOCATE_SECRET')
18
+ end
19
+
20
+ it 'adds a friend as a participant to the current conversation' do
21
+ expect(subject.base_url).to eq('BASE_URL')
22
+ end
23
+ end
24
+
25
+ describe 'with a configuration block' do
26
+ subject { Applocate.configuration }
27
+ before(:each) {
28
+ Applocate.configure do |config|
29
+ config.token = 'token'
30
+ config.secret = 'secret'
31
+ config.base_url = 'base_url'
32
+ end
33
+ }
34
+
35
+ it 'adds a friend as a participant to the current conversation' do
36
+ expect(subject.token).to eq('token')
37
+ end
38
+
39
+ it 'adds a friend as a participant to the current conversation' do
40
+ expect(subject.secret).to eq('secret')
41
+ end
42
+
43
+ it 'adds a friend as a participant to the current conversation' do
44
+ expect(subject.base_url).to eq('base_url')
45
+ end
46
+ end
47
+
48
+ it 'has a default value for base url' do
49
+ expect(subject.base_url).to eq("https://www.applocate.com/api/v1")
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support'))
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+
8
+ Bundler.require :default, :test
9
+
10
+ require 'pry'
11
+
12
+ RSpec.configure do |config|
13
+ # some (optional) config here
14
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: applocate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Madsen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-19 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'
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: yard
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Connect to applocate and provision devices and push profiles.
84
+ email:
85
+ - mm@idyll.io
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - Guardfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - applocate.gemspec
100
+ - lib/applocate.rb
101
+ - lib/applocate/api.rb
102
+ - lib/applocate/configuration.rb
103
+ - lib/applocate/version.rb
104
+ - spec/applocate/api_spec.rb
105
+ - spec/applocate/applocate_spec.rb
106
+ - spec/applocate/configuration_spec.rb
107
+ - spec/spec_helper.rb
108
+ homepage: https://www.applocate.com
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.2.2
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Server API client for Applocate
132
+ test_files:
133
+ - spec/applocate/api_spec.rb
134
+ - spec/applocate/applocate_spec.rb
135
+ - spec/applocate/configuration_spec.rb
136
+ - spec/spec_helper.rb
137
+ has_rdoc: