wes-cloudkit 1.0.0

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: e718504b7784eadd1d4386d4f2c71029d50495bf
4
+ data.tar.gz: a724d0f62b19939324c9da09d2e1d8f090e96860
5
+ SHA512:
6
+ metadata.gz: 832bc556f234fc67544f6a6c91a999bb3e5c2a91bb07b4870bd5cf1d7d910885706af158344b2a406d689e3e7cfdef2cd9f59fa50fea118882caf4d1e77fdce9
7
+ data.tar.gz: 52aaa6aa97cd332d1eff8abd220f6a917c49e7a5e0bb2409b20cdc612f7a64162b2dbef1010e370f6ab652b5a5886e8f04597043dbc0c5dbd27140c92d4cc289
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,51 @@
1
+ require "json"
2
+ require "ostruct"
3
+ require "Wes/cloudkit/configuration"
4
+
5
+ module Wes
6
+ module Cloudkit
7
+ class AppConfig
8
+ def initialize
9
+ @json = parse
10
+ end
11
+
12
+ def all
13
+ json
14
+ end
15
+
16
+ def node(s)
17
+ OpenStruct.new json[s]
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :json
23
+
24
+ def configuration
25
+ Configuration
26
+ end
27
+
28
+ def aws_env
29
+ configuration.aws_env
30
+ end
31
+
32
+ def path
33
+ File.join(
34
+ root, "config", "#{aws_env}.config.json"
35
+ )
36
+ end
37
+
38
+ def parse
39
+ OpenStruct.new(
40
+ JSON.parse(
41
+ File.read(path)
42
+ )
43
+ )
44
+ end
45
+
46
+ def root
47
+ configuration.root
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,34 @@
1
+ require "aws-sdk"
2
+ require "wes/cloudkit/configuration"
3
+
4
+ module Wes
5
+ module Cloudkit
6
+ class AwsCreds
7
+ def self.get
8
+ new.get
9
+ end
10
+
11
+ def get
12
+ if env == "production"
13
+ ::Aws::InstanceProfileCredentials.new
14
+ else
15
+ ::Aws::Credentials.new(config.access_key, config.secret_key)
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def config
22
+ configuration.app_config.node "app"
23
+ end
24
+
25
+ def configuration
26
+ Configuration
27
+ end
28
+
29
+ def env
30
+ configuration.env
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require "wes/cloudkit/app_config"
2
+
3
+ module Wes
4
+ module Cloudkit
5
+ class Configuration
6
+ class << self
7
+ attr_accessor :namespace, :root
8
+
9
+ def app_config
10
+ @app_config = AppConfig.new
11
+ end
12
+
13
+ def aws_env
14
+ ENV["AWS_ENV"] || "development"
15
+ end
16
+
17
+ def configure(&block)
18
+ yield self
19
+ self
20
+ end
21
+
22
+ def env
23
+ ENV["RACK_ENV"] || "development"
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,53 @@
1
+ require "ostruct"
2
+ require "wes/cloudkit/configuration"
3
+
4
+ module Wes
5
+ module Cloudkit
6
+ class Routing
7
+ attr_reader :routes
8
+
9
+ def initialize(routes)
10
+ @routes = routes.map do |h|
11
+ OpenStruct.new(h).tap do |os|
12
+ os.klass = "#{namespace}::#{class_name os.file}"
13
+ end
14
+ end
15
+ end
16
+
17
+ def require_all
18
+ @routes.each { |r| require_class r.file }
19
+ end
20
+
21
+ private
22
+
23
+ def class_name(s)
24
+ name = ""
25
+ parts = s.split "/"
26
+ count = parts.size - 1
27
+
28
+ parts.each_with_index do |p, i|
29
+ unless p.include?("_")
30
+ name << p.capitalize
31
+ name << "::" unless i == count
32
+ next
33
+ end
34
+ name << p.split("_").map(&:capitalize).join("")
35
+ end
36
+
37
+ name
38
+ end
39
+
40
+ def configuration
41
+ Configuration
42
+ end
43
+
44
+ def namespace
45
+ "#{configuration.namespace}::Controller"
46
+ end
47
+
48
+ def require_class(file)
49
+ require "app/controller/#{file}"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ module Wes
2
+ module Cloudkit
3
+ VERSION = "1.0.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "wes/cloudkit/aws_creds"
2
+ require "wes/cloudkit/configuration"
3
+ require "wes/cloudkit/routing"
4
+ require "wes/cloudkit/version"
5
+
6
+ module Wes
7
+ module Cloudkit
8
+ def self.aws_creds
9
+ AwsCreds.get
10
+ end
11
+
12
+ def self.aws_env
13
+ Configuration.aws_env
14
+ end
15
+
16
+ def self.config(node = nil)
17
+ node ? Configuration.app_config.node(node) : Configuration.app_config.all
18
+ end
19
+
20
+ def self.configure(&block)
21
+ Configuration.configure(&block)
22
+ end
23
+
24
+ def self.dev?
25
+ Configuration.env == "development"
26
+ end
27
+
28
+ def self.env
29
+ Configuration.env
30
+ end
31
+
32
+ def self.go!
33
+ $LOAD_PATH << File.join(Configuration.root)
34
+ require "pry" if dev?
35
+ end
36
+
37
+ def self.prod?
38
+ Configuration.env == "production"
39
+ end
40
+
41
+ def self.routing(routes)
42
+ Routing.new routes
43
+ end
44
+
45
+ def self.test?
46
+ Configuration.env == "test"
47
+ end
48
+ end
49
+ end
@@ -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 "wes/cloudkit/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "wes-cloudkit"
8
+ spec.version = Wes::Cloudkit::VERSION
9
+ spec.authors = [""]
10
+ spec.email = [""]
11
+
12
+ spec.summary = ""
13
+ spec.homepage = ""
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{\A(wes-cloudkit.gemspec|lib|Gemfile)}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+
24
+ spec.add_dependency "aws-sdk", "~> 2"
25
+ spec.add_dependency "json"
26
+ spec.add_dependency "pry"
27
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wes-cloudkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - ''
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws-sdk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - ''
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - Gemfile
105
+ - lib/wes/cloudkit.rb
106
+ - lib/wes/cloudkit/app_config.rb
107
+ - lib/wes/cloudkit/aws_creds.rb
108
+ - lib/wes/cloudkit/configuration.rb
109
+ - lib/wes/cloudkit/routing.rb
110
+ - lib/wes/cloudkit/version.rb
111
+ - wes-cloudkit.gemspec
112
+ homepage: ''
113
+ licenses: []
114
+ metadata: {}
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 2.5.1
132
+ signing_key:
133
+ specification_version: 4
134
+ summary: ''
135
+ test_files: []