testcloud-support 0.0.0.4

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: 01dd7e4d819f252e0649e1866617951acf73848b
4
+ data.tar.gz: 8c06c131216c73b5339381ebb33b57c094cd337f
5
+ SHA512:
6
+ metadata.gz: 8d7f403a720332a0db3a426afd0ee3dc9db765cd32f1f7f578847453aa9a94ccec20f5c2b6c5f5d0b60478ab56cb6f91c4001a744620b7562c72ddffc413a945
7
+ data.tar.gz: 59ecc052d9ad9983bd4ed37154c623f0a350719389fbba78fc92cf009bab8cb9b5733fbea7cf486945e5a0525ad22a72fb2877136edc41b95ad40b2184e8c37f
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in testcloud-support.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec', '~> 3.0.0'
8
+ gem 'shoulda', '~> 3.5.0'
9
+ gem 'cucumber', '~> 1.3.16'
10
+ end
11
+
12
+ group :development, :test do
13
+ gem 'guard', '~> 2.6.1'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,91 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ testcloud-support (0.0.0.2)
5
+ activesupport (~> 4.1.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (4.1.5)
11
+ i18n (~> 0.6, >= 0.6.9)
12
+ json (~> 1.7, >= 1.7.7)
13
+ minitest (~> 5.1)
14
+ thread_safe (~> 0.1)
15
+ tzinfo (~> 1.1)
16
+ builder (3.2.2)
17
+ celluloid (0.15.2)
18
+ timers (~> 1.1.0)
19
+ coderay (1.1.0)
20
+ cucumber (1.3.16)
21
+ builder (>= 2.1.2)
22
+ diff-lcs (>= 1.1.3)
23
+ gherkin (~> 2.12)
24
+ multi_json (>= 1.7.5, < 2.0)
25
+ multi_test (>= 0.1.1)
26
+ diff-lcs (1.2.5)
27
+ ffi (1.9.3)
28
+ formatador (0.2.5)
29
+ gherkin (2.12.2)
30
+ multi_json (~> 1.3)
31
+ guard (2.6.1)
32
+ formatador (>= 0.2.4)
33
+ listen (~> 2.7)
34
+ lumberjack (~> 1.0)
35
+ pry (>= 0.9.12)
36
+ thor (>= 0.18.1)
37
+ i18n (0.6.11)
38
+ json (1.8.1)
39
+ listen (2.7.9)
40
+ celluloid (>= 0.15.2)
41
+ rb-fsevent (>= 0.9.3)
42
+ rb-inotify (>= 0.9)
43
+ lumberjack (1.0.9)
44
+ method_source (0.8.2)
45
+ minitest (5.4.1)
46
+ multi_json (1.10.1)
47
+ multi_test (0.1.1)
48
+ pry (0.10.1)
49
+ coderay (~> 1.1.0)
50
+ method_source (~> 0.8.1)
51
+ slop (~> 3.4)
52
+ rake (10.3.2)
53
+ rb-fsevent (0.9.4)
54
+ rb-inotify (0.9.5)
55
+ ffi (>= 0.5.0)
56
+ rspec (3.0.0)
57
+ rspec-core (~> 3.0.0)
58
+ rspec-expectations (~> 3.0.0)
59
+ rspec-mocks (~> 3.0.0)
60
+ rspec-core (3.0.4)
61
+ rspec-support (~> 3.0.0)
62
+ rspec-expectations (3.0.4)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.0.0)
65
+ rspec-mocks (3.0.4)
66
+ rspec-support (~> 3.0.0)
67
+ rspec-support (3.0.4)
68
+ shoulda (3.5.0)
69
+ shoulda-context (~> 1.0, >= 1.0.1)
70
+ shoulda-matchers (>= 1.4.1, < 3.0)
71
+ shoulda-context (1.2.1)
72
+ shoulda-matchers (2.6.2)
73
+ activesupport (>= 3.0.0)
74
+ slop (3.6.0)
75
+ thor (0.19.1)
76
+ thread_safe (0.3.4)
77
+ timers (1.1.0)
78
+ tzinfo (1.2.2)
79
+ thread_safe (~> 0.1)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ bundler (~> 1.7)
86
+ cucumber (~> 1.3.16)
87
+ guard (~> 2.6.1)
88
+ rake (~> 10.0)
89
+ rspec (~> 3.0.0)
90
+ shoulda (~> 3.5.0)
91
+ testcloud-support!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 John Faucett
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.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Testcloud::Support
2
+
3
+ Contains the following:
4
+
5
+ 1. Environments
6
+ 2. Configuration
7
+ 3. AR Database connection handling for non-rails apps
8
+ 4. Instrumentation helpers
9
+ 5. Logging
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'testcloud-support'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install testcloud-support
26
+
27
+ ## Usage
28
+
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/[my-github-username]/testcloud-support/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,10 @@
1
+ require 'testcloud/support/dependencies'
2
+
3
+ module Testcloud
4
+
5
+ # extends the global Testcloud module with absolutely required methods
6
+ require 'testcloud/support/global_methods'
7
+
8
+ module Support
9
+ end
10
+ end # Testcloud
@@ -0,0 +1,6 @@
1
+
2
+ # add autoload :MyModule without having to give the pathname
3
+ require 'active_support/dependencies/autoload'
4
+
5
+ # Fetch namespaced constants i.e. Object.qualified_const_get('Testcloud::Support::Yoda')
6
+ require 'active_support/core_ext/module/qualified_const'
@@ -0,0 +1,15 @@
1
+ module Testcloud
2
+ module Support
3
+ module VERSION
4
+ def self.gem_version
5
+ @gem_version ||= Gem::Version.new(STRING)
6
+ end
7
+
8
+ MAJOR = 0
9
+ MINOR = 0
10
+ PATCH = 0
11
+ PRE = 4
12
+ STRING = [MAJOR, MINOR, PATCH, PRE].join('.').freeze
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ require 'securerandom' # needed for per Thread uuid generation
2
+
3
+ module Testcloud
4
+ # Support extends the Testcloud module itself
5
+ # in order to add global methods that can be accessible by all projects that
6
+ # use the Testcloud namespace
7
+ class << self
8
+
9
+ FALLBACK_ENV = 'development'.freeze
10
+
11
+ # The preferred default environment is TESTCLOUD_ENV.
12
+ # The first fallback is to RAILS_ENV then RACK_ENV (for rails and rack apps), when nothing is set don't allow
13
+ # a nil env so we set it to FALLBACK_ENV
14
+ require 'active_support/string_inquirer'
15
+
16
+ def env
17
+ @_env ||= begin
18
+ default_env = ENV['TESTCLOUD_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || FALLBACK_ENV
19
+ ActiveSupport::StringInquirer.new(default_env)
20
+ end
21
+ end
22
+
23
+ def env=(environment)
24
+ @_env = ActiveSupport::StringInquirer.new(environment)
25
+ end
26
+
27
+ # We want to be able to uniquely identify separate threads
28
+ # but we should probably make this UUIDv5 for more assurance of uniqueness
29
+ def uuid=(uuid_value)
30
+ Thread.current[:uuid] = uuid_value
31
+ end
32
+
33
+ def uuid
34
+ Thread.current[:uuid] ||= SecureRandom.uuid
35
+ end
36
+
37
+ end # self
38
+ end
@@ -0,0 +1,2 @@
1
+ require 'active_support/dependencies/autoload'
2
+ require 'active_support/core_ext/module/qualified_const'
@@ -0,0 +1,26 @@
1
+ require 'testcloud/support/logging/default_logger'
2
+
3
+ module Testcloud
4
+ module Support
5
+
6
+ class << self
7
+ def logger
8
+ logger_class.logger
9
+ end
10
+
11
+
12
+ private
13
+ def logger_class
14
+ @logger ||= logger_for_environment(Testcloud.env)
15
+ end
16
+
17
+ def logger_for_environment(environment)
18
+ case environment
19
+ when 'development', 'test', 'production'
20
+ Logging::DefaultLogger.new
21
+ end
22
+ end
23
+ end # self
24
+
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ require 'logger'
2
+
3
+ module Testcloud
4
+ module Support
5
+ module Logging
6
+
7
+ class DefaultLogger
8
+ attr_reader :logger
9
+
10
+ def initialize
11
+ @logger = ::Logger.new(STDOUT)
12
+ @logger.datetime_format = '%Y-%M-%d %H:%M:%S'
13
+ @logger.formatter = proc do |severity, datetime, program_name, message|
14
+ "[#{severity}]: #{message} [#{datetime}]"
15
+ end
16
+ self
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'gem_version'
2
+
3
+ module Testcloud
4
+ module Support
5
+ def self.gem_version
6
+ VERSION.gem_version
7
+ end
8
+
9
+ def self.version
10
+ VERSION::STRING
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ require 'testcloud/support'
@@ -0,0 +1,8 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $:.unshift(lib) unless $:.include?(lib)
3
+
4
+ require 'testcloud_support'
5
+
6
+ RSpec.configure do |config|
7
+ config.pattern = 'spec/**/*_spec.rb'
8
+ end
@@ -0,0 +1,42 @@
1
+
2
+ describe Testcloud do
3
+
4
+ context 'environment' do
5
+
6
+ it 'should add an env reader method to the Testcloud module' do
7
+ expect(Testcloud).to respond_to(:env)
8
+ end
9
+
10
+ it 'should add an env setter method to the Testcloud module' do
11
+ expect(Testcloud).to respond_to(:env=)
12
+ end
13
+
14
+ it 'should be configurable through the env= setter' do
15
+ Testcloud.env = 'live_long_and_prosper'
16
+ expect(Testcloud.env).to eq('live_long_and_prosper')
17
+ end
18
+
19
+ it 'should be questionable' do
20
+ Testcloud.env = 'live_long_and_prosper'
21
+ expect(Testcloud.env).to respond_to(:production?)
22
+ expect(Testcloud.env.live_long_and_prosper?).to eq(true)
23
+ end
24
+
25
+ end
26
+
27
+ context 'uuid' do
28
+
29
+ it 'should create thread unique uuids' do
30
+ orig_uuid = Testcloud.uuid
31
+ other_uuid = nil
32
+ t = Thread.new do
33
+ other_uuid = Testcloud.uuid
34
+ end
35
+ t.join
36
+
37
+ expect(other_uuid).to_not eq(nil)
38
+ expect(orig_uuid).to_not eq(other_uuid)
39
+ end
40
+
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: testcloud-support
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - testCloud Team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-01 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.5
55
+ description:
56
+ email:
57
+ - team@testcloud.io
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - Gemfile.lock
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/testcloud/support.rb
68
+ - lib/testcloud/support/dependencies.rb
69
+ - lib/testcloud/support/gem_version.rb
70
+ - lib/testcloud/support/global_methods.rb
71
+ - lib/testcloud/support/loading.rb
72
+ - lib/testcloud/support/logger.rb
73
+ - lib/testcloud/support/logging/default_logger.rb
74
+ - lib/testcloud/support/version.rb
75
+ - lib/testcloud_support.rb
76
+ - spec/spec_helper.rb
77
+ - spec/testcloud/support_spec.rb
78
+ homepage: https://testcloud.io
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.0
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Shared components and utilities
102
+ test_files: []
103
+ has_rdoc: