aptible-gridiron 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3194ca3112f7c2c9adcd06904ad681ca00ced37c
4
- data.tar.gz: f31fa4fda6c721aafae9f42de9a9edcc76a865e7
3
+ metadata.gz: f127554a7074b9d3669b9579f7e76430cc28fc3f
4
+ data.tar.gz: 2c5581ada148a2f8d2c25c76fcbb3ae5f1eafcac
5
5
  SHA512:
6
- metadata.gz: 0ae03ee9ed2f392c72910a473f1fbca5d82dbffa48dd9089b0119c98562ad1c954596736008b49fadfe46ef455d1a1de2fc48dd7378adb82a24fb78427fc0240
7
- data.tar.gz: 4147963ff65de92ed65d4e4e7d9a36f916fa8e633ba98ae9f9107c2449c7163a1fa1ebd8cbc4ed6dee7798fddeea5f86a4f11322f5df918e2e01ba96b6f4dd06
6
+ metadata.gz: 809629814ec53416b4e33a3b8e62519751111c9027449e81ccd08d627e4d66ef379b542dbc3855d3d41d6ad53aada82db95d6cd81dc9261f9493ac11265ea277
7
+ data.tar.gz: 39a634672142fcd716411176b46a3d55e07cd39d361191550fb41187150bd80369f34276ed465a2c8b2b826d53bcb166bf4378505cc97edd3f776cae73be434b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ![](https://raw.github.com/aptible/straptible/master/lib/straptible/rails/templates/public.api/icon-60px.png) Aptible::Gridiron
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/gridiron.png)](https://rubygems.org/gems/gridiron)
3
+ [![Gem Version](https://badge.fury.io/rb/aptible-gridiron.png)](https://rubygems.org/gems/aptible-gridiron)
4
4
  [![Build Status](https://travis-ci.org/aptible/gridiron-ruby.png?branch=master)](https://travis-ci.org/aptible/gridiron-ruby)
5
5
  [![Dependency Status](https://gemnasium.com/aptible/gridiron-ruby.png)](https://gemnasium.com/aptible/gridiron-ruby)
6
6
 
@@ -38,15 +38,11 @@ criterion.name
38
38
  # => "Policy Manual"
39
39
  ```
40
40
 
41
- To work with organization-specific evidence (i.e., documents and events), you may set the `Aptible::Gridiron.configuration.organization` variable. For example:
41
+ To work with organization-specific evidence (i.e., documents and events), you may pass `:organization` as a parameter in any initializer. For example:
42
42
 
43
43
  ```ruby
44
44
  organization = Aptible::Auth::Organization.all(token: token).first
45
- Aptible::Gridiron.configure do |config|
46
- config.organization = organization
47
- end
48
-
49
- gridiron = Aptible::Gridiron::Agent.new(token: token)
45
+ gridiron = Aptible::Gridiron::Agent.new(token: token, organization: organization)
50
46
  criterion = gridiron.protocols.first.procedures.first.criteria.first
51
47
  criterion.documents.count
52
48
  # => 1
@@ -64,7 +60,6 @@ document.expires_at
64
60
  | Parameter | Description | Default |
65
61
  | --------- | ----------- | --------------- |
66
62
  | `root_url` | Root URL of the Gridiron server | `ENV['GRIDIRON_ROOT_URL']` or [https://gridiron.aptible.com](https://gridiron.aptible.com) |
67
- | `organization` | `Aptible::Auth::Organization` instance to be used for all documents/events | `nil` |
68
63
 
69
64
  To point the client at a different server (e.g., during development), add the following to your application's initializers (or set the `GRIDIRON_ROOT_URL` environment variable):
70
65
 
@@ -13,9 +13,6 @@ module Aptible
13
13
  has :root_url,
14
14
  classes: [String],
15
15
  default: ENV['GRIDIRON_ROOT_URL'] || 'https://gridiron.aptible.com'
16
- has :organization,
17
- classes: [Aptible::Auth::Organization, NilClass],
18
- default: nil
19
16
  end
20
17
  end
21
18
  end
@@ -11,6 +11,26 @@ module Aptible
11
11
  field :evidence_type
12
12
  field :scope
13
13
  field :default_expiry
14
+
15
+ def documents
16
+ evidence_type == 'document' ? super : []
17
+ end
18
+
19
+ def events
20
+ evidence_type == 'event' ? super : []
21
+ end
22
+
23
+ def status
24
+ green? ? 'green' : 'red'
25
+ end
26
+
27
+ # TODO: Move to Gridiron, or fix logic
28
+ def green?
29
+ return true if evidence_type == 'event'
30
+
31
+ return false unless documents.first
32
+ documents.first.expires_at > Time.now
33
+ end
14
34
  end
15
35
  end
16
36
  end
@@ -5,6 +5,7 @@ module Aptible
5
5
 
6
6
  field :id
7
7
  field :data
8
+ field :created_at, type: Time
8
9
 
9
10
  def organization
10
11
  auth = Aptible::Auth::Organization.new(token: token, headers: headers)
@@ -3,21 +3,24 @@ require 'aptible/resource'
3
3
  module Aptible
4
4
  module Gridiron
5
5
  class Resource < Aptible::Resource::Base
6
- def self.normalize_params(params = {})
7
- # TODO: Figure out a more natural solution than this monkey patch
8
- if (organization = Aptible::Gridiron.configuration.organization)
9
- params.merge!(organization: organization.href)
10
- end
6
+ def outgoing_uri_filter(params)
7
+ params.merge!(organization: organization) if organization
8
+ end
11
9
 
12
- super(params)
10
+ def organization
11
+ # TODO: Is there another way to persist organization across children
12
+ headers['X-Aptible-Organization']
13
13
  end
14
14
 
15
- def outgoing_uri_filter(params)
16
- if (organization = Aptible::Gridiron.configuration.organization)
17
- params.merge!(organization: organization.href)
15
+ def initialize(options = {})
16
+ if options.is_a?(Hash) && options[:organization]
17
+ options[:headers] ||= {}
18
+ options[:headers].merge!(
19
+ 'X-Aptible-Organization' => options[:organization].href
20
+ )
18
21
  end
19
22
 
20
- params
23
+ super(options)
21
24
  end
22
25
 
23
26
  def namespace
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Gridiron
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-gridiron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource