adminbox 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6006b257d5e310e403d352d0d88e526351100e99
4
- data.tar.gz: e80d11dfec76e90e3b5f28d7175bc74e3951ed27
3
+ metadata.gz: 4e960e2562c2265160a3aa839fca09c26a89edf5
4
+ data.tar.gz: 7b6b1164628678a9e6fe5626028ef32d9cb000ea
5
5
  SHA512:
6
- metadata.gz: 874fcae5f42ddd05c6b3dbd854130ee7cc88dc1f48c8229032ea9deeac393cda7e7936510d2e327b14a1c0af86fc19086532020451776c1422bffc3fe2a4bd96
7
- data.tar.gz: 7b83c24afad968edbde00f011236522bfaa99284aca9fea59b7754d7076fb59036ed3d6156e5c293bae80b6c4425717731b6f28e8e5f2b0dfa049e3edf6c35d4
6
+ metadata.gz: 1aa7697216e65764b73b441ff1f928b744ff9b9404439fe71a19f54c9160b07efbf03c1181ee39d6ece53ee33c27c8ceafa5c949ac52c9852a846570daed8ef0
7
+ data.tar.gz: c8dcaf42f1d3e9aec2d399469fea5fa8bb36ef850d360503b588145ab48b604ecd107af95c5773e96b72f80d31bd41cfc24300a6ca4f2644458f1633b7ad3527
data/adminbox.gemspec CHANGED
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "adminbox"
8
8
  spec.version = Adminbox::VERSION
9
9
  spec.authors = ["Andrew Allen"]
10
- spec.email = ["andrew@agilearcade.com"]
10
+ spec.email = ["andrew@adminbox.co"]
11
11
 
12
12
  spec.summary = %q{Official AdminBox gem that enables advanced functionality}
13
13
  spec.description = %q{Official AdminBox gem that enables advanced functionality}
14
- spec.homepage = "https://www.agilearcade.com"
14
+ spec.homepage = "https://www.adminbox.co"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -30,7 +30,10 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
+ spec.add_runtime_dependency "jwt", "~> 1.5.6"
34
+
33
35
  spec.add_development_dependency "bundler", "~> 1.13"
34
36
  spec.add_development_dependency "rake", "~> 10.0"
35
37
  spec.add_development_dependency "rspec", "~> 3.0"
38
+ spec.add_development_dependency "pry"
36
39
  end
data/lib/adminbox.rb CHANGED
@@ -1,5 +1,19 @@
1
+ require "jwt"
1
2
  require "adminbox/version"
3
+ require "adminbox/exceptions"
4
+ require "adminbox/configuration"
5
+ require "adminbox/command"
2
6
 
3
7
  module Adminbox
4
- # Your code goes here...
8
+ class << self
9
+ attr_writer :configuration
10
+
11
+ def configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def configure
16
+ yield(configuration)
17
+ end
18
+ end
5
19
  end
@@ -0,0 +1,52 @@
1
+ module Adminbox
2
+ class Command
3
+ attr_reader :encoded_jwt
4
+
5
+ def initialize(jwt)
6
+ @encoded_jwt = jwt
7
+ end
8
+
9
+ def execute
10
+ subcommand = Object.const_get("Commands::#{table_module}::#{name}")
11
+ subcommand.new(encoded_jwt).execute
12
+ end
13
+
14
+ def shared_secret
15
+ Adminbox.configuration.shared_secret
16
+ end
17
+
18
+ def decoded_jwt
19
+ @decoded_jwt ||= begin
20
+ JWT.decode(encoded_jwt, shared_secret)
21
+ rescue JWT::VerificationError
22
+ raise Adminbox::InvalidSignature
23
+ rescue JWT::ExpiredSignature
24
+ raise Adminbox::ExpiredSignature
25
+ end
26
+ end
27
+
28
+ def payload
29
+ decoded_jwt[0]
30
+ end
31
+
32
+ def headers
33
+ decoded_jwt[1]
34
+ end
35
+
36
+ def name
37
+ payload["command"]
38
+ end
39
+
40
+ def table
41
+ payload["table"]
42
+ end
43
+
44
+ def table_module
45
+ table.split('_').collect(&:capitalize).join
46
+ end
47
+
48
+ def ids
49
+ payload["ids"]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,5 @@
1
+ module Adminbox
2
+ class Configuration
3
+ attr_accessor :shared_secret
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Adminbox
2
+ class Error < StandardError; end
3
+ class InvalidSignature < Error; end
4
+ class ExpiredSignature < Error; end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Adminbox
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminbox
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
  - Andrew Allen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jwt
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.5.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,9 +66,23 @@ dependencies:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
68
  version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  description: Official AdminBox gem that enables advanced functionality
56
84
  email:
57
- - andrew@agilearcade.com
85
+ - andrew@adminbox.co
58
86
  executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
@@ -71,8 +99,11 @@ files:
71
99
  - bin/console
72
100
  - bin/setup
73
101
  - lib/adminbox.rb
102
+ - lib/adminbox/command.rb
103
+ - lib/adminbox/configuration.rb
104
+ - lib/adminbox/exceptions.rb
74
105
  - lib/adminbox/version.rb
75
- homepage: https://www.agilearcade.com
106
+ homepage: https://www.adminbox.co
76
107
  licenses:
77
108
  - MIT
78
109
  metadata: