singleton-ruby 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: 2eafb488acb5e9534e211a2757110e9768841fa62c6e49fc791b2751a7e3cc70
4
- data.tar.gz: cd8aa70499702d69ce4a8d5f936fd4ac6b41bc5500283e2514135cb5e9f10b77
3
+ metadata.gz: 9948a8ed190dc317c552c9dd9ca2f2f1579aa7903765562b44fe8ec4684f7531
4
+ data.tar.gz: 037a56320794f476e2aa4de9b09a50f52d348ce652838a30604a613b6cbe2f4b
5
5
  SHA512:
6
- metadata.gz: 39a6c18b36bd1850962a17517811589b1e3a16b7949980be4f0839bc4bbcc7e02025b1d4d0929dc6f18e2126fa77926bd374ad65dc48ab90c36c51bbea0da666
7
- data.tar.gz: cfb42233c159ffd9639dccfc73e953f43943c964702f7e0742fbb1fe3da078bfbffb6aee21123c1629810d13731b7dbe414e250c56deb2afad1b4a69e79aeb56
6
+ metadata.gz: 4d568de3d1de3df32358f2ae5232868beb28de9e59d41d7d470473ebf789a4d868e6d8a1ef10cff24d4e59375f907a46d622c3180e00b77d95af64ffc246f4ec
7
+ data.tar.gz: 6f4a695dacfc078c449070fec32992f133c39abeca3a9a1a093258014f0e3db24d92da36635fde18869817541c356c89ef0ecdf697e75c24c3aa273691bbf904
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "https://rubygems.org"
2
+
3
+ if !!File::ALT_SEPARATOR
4
+ gemspec :name => 'singleton-ruby.windows'
5
+ else
6
+ gemspec :name => 'singleton-ruby'
7
+ end
8
+
9
+ gem 'rake', :require => false
10
+
11
+ group :test do
12
+ gem 'simplecov', :require => false
13
+ gem 'rspec'
14
+ gem 'webmock'
15
+ end
16
+
17
+ #gem 'releasinator', '~> 0.6'
data/Rakefile ADDED
@@ -0,0 +1,140 @@
1
+ # load `rake build/install/release tasks'
2
+ require 'bundler/setup'
3
+ require_relative './lib/version'
4
+
5
+ namespace :ruby do
6
+ Bundler::GemHelper.install_tasks(:name => 'singleton-ruby')
7
+ end
8
+
9
+ require "rspec/core/rake_task"
10
+
11
+ desc "Run all specs"
12
+ RSpec::Core::RakeTask.new('spec')
13
+
14
+ desc "Run unit specs"
15
+ RSpec::Core::RakeTask.new('spec:unit') do |t|
16
+ t.pattern = 'spec/unit/*_spec.rb'
17
+ end
18
+
19
+ desc "Run integration specs"
20
+ RSpec::Core::RakeTask.new('spec:integration') do |t|
21
+ t.pattern = 'spec/integration/*_spec.rb'
22
+ end
23
+
24
+ desc "Print specdocs"
25
+ RSpec::Core::RakeTask.new(:doc) do |t|
26
+ t.rspec_opts = ["--format", "specdoc", "--dry-run"]
27
+ t.pattern = 'spec/**/*_spec.rb'
28
+ end
29
+
30
+ desc "Run all examples with RCov"
31
+ RSpec::Core::RakeTask.new('rcov') do |t|
32
+ t.pattern = 'spec/*_spec.rb'
33
+ t.rcov = true
34
+ t.rcov_opts = ['--exclude', 'examples']
35
+ end
36
+
37
+ desc 'Regenerate authors file'
38
+ task :authors do
39
+ Dir.chdir(File.dirname(__FILE__)) do
40
+ File.open('AUTHORS', 'w') do |f|
41
+ f.write <<-EOM
42
+ The Ruby REST Client would not be what it is today without the help of
43
+ the following kind souls:
44
+
45
+ EOM
46
+ end
47
+
48
+ sh 'git shortlog -s | cut -f 2 >> AUTHORS'
49
+ end
50
+ end
51
+
52
+ task :default do
53
+ sh 'rake -T'
54
+ end
55
+
56
+ def alias_task(alias_task, original)
57
+ desc "Alias for rake #{original}"
58
+ task alias_task, Rake.application[original].arg_names => original
59
+ end
60
+ alias_task(:test, :spec)
61
+
62
+ ############################
63
+
64
+ WindowsPlatforms = %w{x86-mingw32 x64-mingw32 x86-mswin32}
65
+
66
+ namespace :all do
67
+
68
+ desc "Build rest-client #{VERSION} for all platforms"
69
+ task :build => ['ruby:build'] + \
70
+ WindowsPlatforms.map {|p| "windows:#{p}:build"}
71
+
72
+ desc "Create tag v#{VERSION} and for all platforms build and " \
73
+ "push rest-client #{VERSION} to Rubygems"
74
+ task :release => ['build', 'ruby:release'] + \
75
+ WindowsPlatforms.map {|p| "windows:#{p}:push"}
76
+
77
+ end
78
+
79
+ namespace :windows do
80
+ spec_path = File.join(File.dirname(__FILE__), 'rest-client.windows.gemspec')
81
+
82
+ WindowsPlatforms.each do |platform|
83
+ namespace platform do
84
+ gem_filename = "rest-client-#{VERSION}-#{platform}.gem"
85
+ base = File.dirname(__FILE__)
86
+ pkg_dir = File.join(base, 'pkg')
87
+ gem_file_path = File.join(pkg_dir, gem_filename)
88
+
89
+ desc "Build #{gem_filename} into the pkg directory"
90
+ task 'build' do
91
+ orig_platform = ENV['BUILD_PLATFORM']
92
+ begin
93
+ ENV['BUILD_PLATFORM'] = platform
94
+
95
+ sh("gem build -V #{spec_path}") do |ok, res|
96
+ if ok
97
+ FileUtils.mkdir_p(pkg_dir)
98
+ FileUtils.mv(File.join(base, gem_filename), pkg_dir)
99
+ Bundler.ui.confirm("rest-client #{VERSION} " \
100
+ "built to pkg/#{gem_filename}")
101
+ else
102
+ abort "Command `gem build` failed: #{res}"
103
+ end
104
+ end
105
+
106
+ ensure
107
+ ENV['BUILD_PLATFORM'] = orig_platform
108
+ end
109
+ end
110
+
111
+ desc "Push #{gem_filename} to Rubygems"
112
+ task 'push' do
113
+ sh("gem push #{gem_file_path}")
114
+ end
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ ############################
121
+
122
+ require 'rdoc/task'
123
+
124
+ Rake::RDocTask.new do |t|
125
+ t.rdoc_dir = 'rdoc'
126
+ t.title = "rest-client, fetch RESTful resources effortlessly"
127
+ t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
128
+ t.options << '--charset' << 'utf-8'
129
+ t.rdoc_files.include('README.md')
130
+ t.rdoc_files.include('lib/*.rb')
131
+ end
132
+
133
+ ############################
134
+
135
+ require 'rubocop/rake_task'
136
+
137
+ RuboCop::RakeTask.new(:rubocop) do |t|
138
+ t.options = ['--display-cop-names']
139
+ end
140
+ alias_task(:lint, :rubocop)
@@ -0,0 +1,3 @@
1
+ To copy a PayPal SDK default configuration and initializer to your Rails App.
2
+
3
+ rails g sgtnclient:install
@@ -0,0 +1,15 @@
1
+ module SgtnClient
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def copy_config_file
7
+ copy_file "sgtnclient.yml", "config/sgtnclient.yml"
8
+ end
9
+
10
+ def copy_initializer_file
11
+ copy_file "sgtnclient.rb", "config/initializers/sgtnclient.rb"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,2 @@
1
+ SgtnClient.load("config/sgtnclient.yml", Rails.env)
2
+ PSgtnClient.logger = Rails.logger
@@ -0,0 +1,33 @@
1
+ test: &default
2
+
3
+ # Credentials for REST APIs
4
+ client_id: tee
5
+ client_secret: 89987
6
+
7
+ # Mode can be 'live' or 'sandbox'
8
+ mode: sandbox
9
+
10
+ # Credentials for Classic APIs
11
+ app_id: APP-80W284485P519543T
12
+ username: linr
13
+ password: fdasf
14
+ signature: sfds-RWy
15
+ # # With Certificate
16
+ # cert_path: "config/cert_key.pem"
17
+ sandbox_email_address: linr@vmware.com
18
+
19
+ # #Product Name
20
+ product_name: logInsight
21
+
22
+ # # bundle version
23
+ version: 4.8.1
24
+
25
+ # # HTTP Proxy
26
+ vip_server: https://g11n-vip-dev-1.eng.vmware.com:8090
27
+
28
+ development:
29
+ <<: *default
30
+
31
+ production:
32
+ <<: *default
33
+ mode: live
@@ -0,0 +1,92 @@
1
+ require 'json'
2
+
3
+ module SgtnClient
4
+
5
+ module Core
6
+ autoload :Request, "sgtn-client/core/request"
7
+ autoload :Cache, "sgtn-client/core/cache"
8
+ end
9
+
10
+ class Translation
11
+
12
+ include Logging
13
+
14
+ def self.getString(component, key, locale)
15
+ cache_key = get_cachekey(component, locale)
16
+ SgtnClient::Core::Cache.initialize()
17
+ items = get_cache(cache_key)
18
+ if items.nil?
19
+ items = getTranslations(component, locale)
20
+ write_cache(cache_key, items)
21
+ end
22
+ if items.nil?
23
+ return key
24
+ end
25
+ str = items["messages"][key]
26
+ return str
27
+ end
28
+
29
+ private
30
+
31
+ def self.getTranslations(component, locale)
32
+ env = SgtnClient::Config.default_environment
33
+ mode = SgtnClient::Config.configurations[env]["bundle_mode"]
34
+ if mode == 'offline'
35
+ return get_offbundle(component, locale)
36
+ else
37
+ return get_server(component, locale)
38
+ end
39
+ end
40
+
41
+ def self.get_offbundle(component, locale)
42
+ env = SgtnClient::Config.default_environment
43
+ product_name = SgtnClient::Config.configurations[env]["product_name"]
44
+ version = SgtnClient::Config.configurations[env]["version"]
45
+ offline_bundle = SgtnClient::Config.configurations[env]["offline_bundle"]
46
+ bundlepath = offline_bundle + "/l10n/bundles/" + product_name + "/" + version + "/" + component + "/messages_" + locale + ".json"
47
+ SgtnClient.logger.info "Getting translations from offline bundle: " + bundlepath
48
+ begin
49
+ file = File.read(bundlepath)
50
+ data_hash = JSON.parse(file)
51
+ rescue => exception
52
+ SgtnClient.logger.error exception.message
53
+ end
54
+ return data_hash
55
+ end
56
+
57
+ def self.get_server(component, locale)
58
+ env = SgtnClient::Config.default_environment
59
+ product_name = SgtnClient::Config.configurations[env]["product_name"]
60
+ vip_server = SgtnClient::Config.configurations[env]["vip_server"]
61
+ SgtnClient.logger.info "Getting translations from server: " + vip_server
62
+ version = SgtnClient::Config.configurations[env]["version"]
63
+ url = vip_server + "/i18n/api/v2/translation/products/" + product_name + "/versions/" + version + "/locales/" + locale + "/components/" + component+ "?checkTranslationStatus=false&machineTranslation=false&pseudo=false"
64
+ begin
65
+ obj = SgtnClient::Core::Request.get(url)
66
+ rescue => exception
67
+ SgtnClient.logger.error exception.message
68
+ end
69
+ if obj != nil
70
+ obj = obj["data"]
71
+ end
72
+ return obj
73
+ end
74
+
75
+ def self.get_cache(cache_key)
76
+ items = SgtnClient::Core::Cache.get(cache_key)
77
+ return items
78
+ end
79
+
80
+ def self.write_cache(cache_key, items)
81
+ SgtnClient::Core::Cache.put(cache_key, items, 144000)
82
+ end
83
+
84
+ def self.get_cachekey(component, locale)
85
+ env = SgtnClient::Config.default_environment
86
+ product_name = SgtnClient::Config.configurations[env]["product_name"]
87
+ version = SgtnClient::Config.configurations[env]["version"]
88
+ return product_name + "_" + version + "_" + component + "_" + locale
89
+ end
90
+ end
91
+
92
+ end
@@ -0,0 +1,43 @@
1
+ require 'date'
2
+
3
+ module SgtnClient::Core
4
+ class Cache
5
+ Entry = Struct.new(:expiry, :value)
6
+
7
+ def self.initialize(opts={})
8
+ $data = Hash.new
9
+ $opts = opts
10
+ end
11
+
12
+ def self.keys
13
+ $data.keys
14
+ end
15
+
16
+ def self.get(key)
17
+ $data[key][:value] if has(key)
18
+ end
19
+
20
+ def self.has(key)
21
+ $data.has_key? key
22
+ end
23
+
24
+ def self.put(key, value, ttl=nil)
25
+ ttl ||= @opts[:ttl]
26
+ $data[key] = Entry.new(DateTime.new + Rational(ttl, 1440), value)
27
+ end
28
+
29
+ def self.delete(key)
30
+ $data.delete key
31
+ end
32
+
33
+ def self.clear
34
+ $data = Hash.new
35
+ end
36
+
37
+ def self.invalidate
38
+ now = DateTime.new
39
+ $data.delete_if {|k, v| v[:expiry] < now}
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,172 @@
1
+ require 'erb'
2
+ require 'yaml'
3
+
4
+ module SgtnClient
5
+ #include Exceptions
6
+ module Configuration
7
+
8
+ def config
9
+ @config ||= Config.config
10
+ end
11
+
12
+ def set_config(env, override_configurations = {})
13
+ @config =
14
+ case env
15
+ when Config
16
+ env
17
+ when Hash
18
+ begin
19
+ config.dup.merge!(env)
20
+ rescue Errno::ENOENT => error
21
+ Config.new(env)
22
+ end
23
+ else
24
+ Config.config(env, override_configurations)
25
+ end
26
+ end
27
+
28
+ alias_method :config=, :set_config
29
+
30
+ end
31
+
32
+
33
+ class Config
34
+
35
+ attr_accessor :username, :password, :signature, :app_id, :cert_path,
36
+ :token, :token_secret, :subject,
37
+ :http_timeout, :http_proxy,
38
+ :device_ipaddress, :sandbox_email_address,
39
+ :mode, :endpoint, :merchant_endpoint, :platform_endpoint, :ipn_endpoint,
40
+ :rest_endpoint, :rest_token_endpoint, :client_id, :client_secret,
41
+ :openid_endpoint, :openid_redirect_uri, :openid_client_id, :openid_client_secret,
42
+ :verbose_logging, :product_name, :version, :vip_server, :bundle_mode, :offline_bundle
43
+
44
+
45
+ # Create Config object
46
+ # === Options(Hash)
47
+ # * <tt>username</tt> -- Username
48
+ # * <tt>password</tt> -- Password
49
+ # * <tt>signature</tt> (Optional if certificate present) -- Signature
50
+ # * <tt>app_id</tt> -- Application ID
51
+ # * <tt>cert_path</tt> (Optional if signature present) -- Certificate file path
52
+ def initialize(options)
53
+ merge!(options)
54
+ end
55
+
56
+ # Override configurations
57
+ def merge!(options)
58
+ options.each do |key, value|
59
+ send("#{key}=", value)
60
+ end
61
+ self
62
+ end
63
+
64
+ class << self
65
+
66
+ @@config_cache = {}
67
+
68
+ # Load configurations from file
69
+ # === Arguments
70
+ # * <tt>file_name</tt> -- Configuration file path
71
+ # * <tt>default_environment</tt> (Optional) -- default environment configuration to load
72
+ # === Example
73
+ # Config.load('config/paypal.yml', 'development')
74
+ def load(file_name, default_env = default_environment)
75
+ @@config_cache = {}
76
+ @@configurations = read_configurations(file_name)
77
+ @@default_environment = default_env
78
+ config
79
+ end
80
+
81
+
82
+ # Get default environment name
83
+ def default_environment
84
+ @@default_environment ||= ENV['SGTN_ENV'] || ENV['RACK_ENV'] || ENV['RAILS_ENV'] || "development"
85
+ end
86
+
87
+
88
+ # Set default environment
89
+ def default_environment=(env)
90
+ @@default_environment = env.to_s
91
+ end
92
+
93
+ def configure(options = {}, &block)
94
+ begin
95
+ self.config.merge!(options)
96
+ rescue Errno::ENOENT
97
+ self.configurations = { default_environment => options }
98
+ end
99
+ block.call(self.config) if block
100
+ self.config
101
+ end
102
+ alias_method :set_config, :configure
103
+
104
+ # Create or Load Config object based on given environment and configurations.
105
+ # === Attributes
106
+ # * <tt>env</tt> (Optional) -- Environment name
107
+ # * <tt>override_configuration</tt> (Optional) -- Override the configuration given in file.
108
+ # === Example
109
+ # Config.config
110
+ # Config.config(:development)
111
+ # Config.config(:development, { :app_id => "XYZ" })
112
+ def config(env = default_environment, override_configuration = {})
113
+ if env.is_a? Hash
114
+ override_configuration = env
115
+ env = default_environment
116
+ end
117
+ if override_configuration.nil? or override_configuration.empty?
118
+ default_config(env)
119
+ else
120
+ default_config(env).dup.merge!(override_configuration)
121
+ end
122
+ end
123
+
124
+ def default_config(env = nil)
125
+ env = (env || default_environment).to_s
126
+ if configurations[env]
127
+ @@config_cache[env] ||= new(configurations[env])
128
+ else
129
+ raise SgtnClient::Exceptions::MissingConfig.new("Configuration[#{env}] NotFound")
130
+ end
131
+ end
132
+
133
+ # Get raw configurations in Hash format.
134
+ def configurations
135
+ @@configurations ||= read_configurations
136
+ end
137
+
138
+ # Set configuration
139
+ def configurations=(configs)
140
+ @@config_cache = {}
141
+ @@configurations = configs && Hash[configs.map{|k,v| [k.to_s, v] }]
142
+ end
143
+
144
+ # Set logger
145
+ def logger=(logger)
146
+ Logging.logger = logger
147
+ end
148
+
149
+ # Get logger
150
+ def logger
151
+ if @@configurations[:mode] == 'live' and Logging.logger.level == Logger::DEBUG
152
+ Logging.logger.warn "DEBUG log level not allowed in live mode for security of confidential information. Changing log level to INFO..."
153
+ Logging.logger.level = Logger::INFO
154
+ end
155
+ Logging.logger
156
+ end
157
+
158
+ private
159
+ # Read configurations from the given file name
160
+ # === Arguments
161
+ # * <tt>file_name</tt> (Optional) -- Configuration file path
162
+ def read_configurations(file_name = "config/sgtnclient.yml")
163
+ erb = ERB.new(File.read(file_name))
164
+ erb.filename = file_name
165
+ YAML.load(erb.result)
166
+ end
167
+
168
+
169
+ end
170
+ end
171
+
172
+ end
@@ -0,0 +1,112 @@
1
+ require 'json'
2
+ require 'pp'
3
+
4
+ module SgtnClient
5
+ module Exceptions
6
+ class ConnectionError < StandardError # :nodoc:
7
+ attr_reader :response
8
+
9
+ def initialize(response, message = nil)
10
+ @response = response
11
+ @message = message
12
+ end
13
+
14
+ def to_s
15
+ begin
16
+ response_body = JSON.parse(response.body)
17
+ debug_id = response["paypal-debug-id"]
18
+ debug_id = response["correlation-id"] if debug_id.to_s == ''
19
+ debug_id = response_body["debug_id"] if debug_id.to_s == ''
20
+ rescue
21
+ end
22
+ message = "Failed."
23
+ message << " Response code = #{response.code}." if response.respond_to?(:code)
24
+ message << " Response message = #{response.message}." if response.respond_to?(:message)
25
+ message << " Response debug ID = #{debug_id}." if debug_id
26
+ message
27
+ end
28
+ end
29
+
30
+ # Raised when a Timeout::Error occurs.
31
+ class TimeoutError < ConnectionError
32
+ def initialize(message)
33
+ @message = message
34
+ end
35
+ def to_s; @message ;end
36
+ end
37
+
38
+ # Raised when a OpenSSL::SSL::SSLError occurs.
39
+ class SSLError < ConnectionError
40
+ def initialize(message)
41
+ @message = message
42
+ end
43
+ def to_s; @message ;end
44
+ end
45
+
46
+ # 3xx Redirection
47
+ class Redirection < ConnectionError # :nodoc:
48
+ def to_s
49
+ response['Location'] ? "#{super} => #{response['Location']}" : super
50
+ end
51
+ end
52
+
53
+ class MissingParam < ArgumentError # :nodoc:
54
+ end
55
+
56
+ class MissingConfig < StandardError # :nodoc:
57
+ end
58
+
59
+ # 4xx Client Error
60
+ class ClientError < ConnectionError # :nodoc:
61
+ end
62
+
63
+ # 400 Bad Request
64
+ class BadRequest < ClientError # :nodoc:
65
+ end
66
+
67
+ # 401 Unauthorized
68
+ class UnauthorizedAccess < ClientError # :nodoc:
69
+ end
70
+
71
+ # 403 Forbidden
72
+ class ForbiddenAccess < ClientError # :nodoc:
73
+ end
74
+
75
+ # 404 Not Found
76
+ class ResourceNotFound < ClientError # :nodoc:
77
+ end
78
+
79
+ # 409 Conflict
80
+ class ResourceConflict < ClientError # :nodoc:
81
+ end
82
+
83
+ # 410 Gone
84
+ class ResourceGone < ClientError # :nodoc:
85
+ end
86
+
87
+ # 422 Unprocessable Entity
88
+ class ResourceInvalid < ClientError # :nodoc:
89
+ end
90
+
91
+ # 5xx Server Error
92
+ class ServerError < ConnectionError # :nodoc:
93
+ end
94
+
95
+ # 405 Method Not Allowed
96
+ class MethodNotAllowed < ClientError # :nodoc:
97
+ def allowed_methods
98
+ @response['Allow'].split(',').map { |verb| verb.strip.downcase.to_sym }
99
+ end
100
+ end
101
+
102
+ # API error: returned as 200 + "error" key in response.
103
+ class UnsuccessfulApiCall < RuntimeError
104
+ attr_reader :api_error
105
+
106
+ def initialize(api_error)
107
+ super(api_error['message'])
108
+ @api_error = api_error
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,50 @@
1
+ require 'logger'
2
+
3
+ module SgtnClient
4
+
5
+ # Include Logging module to provide logger functionality.
6
+ # == Configure logger
7
+ # Logging.logger = Logger.new(STDERR)
8
+ #
9
+ # == Example
10
+ # include Logger
11
+ # logger.info "Debug message"
12
+ module Logging
13
+
14
+ # Get logger object
15
+ def logger
16
+ @logger ||= Logging.logger
17
+ end
18
+
19
+ def log_event(message, &block)
20
+ start_time = Time.now
21
+ block.call
22
+ ensure
23
+ logger.info sprintf("[%.3fs] %s", Time.now - start_time, message)
24
+ end
25
+
26
+ class << self
27
+
28
+ # Get or Create configured logger based on the default environment configuration
29
+ def logger
30
+ @logger ||= Logger.new(STDERR)
31
+ end
32
+
33
+ # Set logger directly and clear the loggers cache.
34
+ # === Attributes
35
+ # * <tt>logger</tt> -- Logger object
36
+ # === Example
37
+ # Logging.logger = Logger.new(STDERR)
38
+ def logger=(logger)
39
+ @logger = logger
40
+ if Config.config.mode.eql? 'live' and @logger.level == Logger::DEBUG
41
+ @logger.warn "DEBUG log level not allowed in sandbox mode for security of confidential information. Changing log level to INFO..."
42
+ @logger.level = Logger::INFO
43
+ end
44
+ end
45
+
46
+ end
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,17 @@
1
+ require 'rest-client'
2
+ require 'multi_json'
3
+
4
+ module SgtnClient::Core
5
+ class Request
6
+ def self.get(url)
7
+ res = RestClient.get(url)
8
+ begin
9
+ obj = MultiJson.load(res)
10
+ rescue MultiJson::ParseError => exception
11
+ exception.data
12
+ exception.cause
13
+ end
14
+ return obj
15
+ end
16
+ end
17
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ require "sgtn-client/sgtn-client"
2
+
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ VERSION_INFO = [0, 0, 3].freeze
3
+ VERSION = VERSION_INFO.map(&:to_s).join('.').freeze
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'bundler/setup'
2
- require_relative '../lib/sgtn-client.rb'
2
+ require_relative '../lib/sgtn-client/sgtn-client.rb'
3
3
 
4
4
  if ENV['COVERAGE']
5
5
  require 'simplecov'
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- require_relative '../../lib/sgtn-client.rb'
2
+ require_relative '../../lib/sgtn-client/sgtn-client.rb'
3
3
 
4
4
  describe SgtnClient do
5
5
 
@@ -1,6 +1,6 @@
1
1
  #require 'spec_helper'
2
2
  require 'stringio'
3
- require_relative '../../lib/sgtn-client.rb'
3
+ require_relative '../../lib/sgtn-client/sgtn-client.rb'
4
4
 
5
5
  describe SgtnClient::Logging do
6
6
  #Logging = SgtnClient::Logging
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: singleton-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware G11n Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -209,8 +209,22 @@ extensions: []
209
209
  extra_rdoc_files:
210
210
  - README.md
211
211
  files:
212
+ - Gemfile
212
213
  - README.md
213
- - lib/sgtn-client.rb
214
+ - Rakefile
215
+ - lib/generators/sgtnclient/USAGE
216
+ - lib/generators/sgtnclient/install_generator.rb
217
+ - lib/generators/sgtnclient/templates/sgtnclient.rb
218
+ - lib/generators/sgtnclient/templates/sgtnclient.yml
219
+ - lib/sgtn-client/api/translation.rb
220
+ - lib/sgtn-client/core/cache.rb
221
+ - lib/sgtn-client/core/config.rb
222
+ - lib/sgtn-client/core/exceptions.rb
223
+ - lib/sgtn-client/core/logging.rb
224
+ - lib/sgtn-client/core/request.rb
225
+ - lib/sgtn-client/sgtn-client.rb
226
+ - lib/singleton-ruby.rb
227
+ - lib/version.rb
214
228
  - spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_de.json
215
229
  - spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_en.json
216
230
  - spec/config/locales/l10n/bundles/logInsight/4.8.1/JAVA/messages_latest.json