dtk-common-core 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 44ec991368ee4472fa31ecbafe1d7d586285aefc
4
- data.tar.gz: 412a2aa06fb1c202e6257b1d28f502dac70fda07
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODQzZGUxMmM4NzgyZTdlODE0MDVjYWM3NTJmOTcyZmU3Y2ZiN2Q2MQ==
5
+ data.tar.gz: !binary |-
6
+ ZDM4OGVkYTZmNzg1MGUyYzYyMDZmMWUwMGViZTJiZTRkMzczNGRhMw==
5
7
  SHA512:
6
- metadata.gz: c95bf07d3b8ce45145ae864fd2336e7020bfaeb453a14d04da8ab8563b03e583b0dbe72722f147b23e63f8407117359f0749bf1351a415907f0a34e395fe2c72
7
- data.tar.gz: 55ec2353200ba662a2b14512cb2248c3e874ef35a0eba273cca42bbf7e10f9b0d35442de723f89e4fc8618f7de6033682e82dbc8a31d7c2292112065f9726827
8
+ metadata.gz: !binary |-
9
+ ODhmYWJiMTZiYzJmN2QxYWI4ZDZmMTkzMWJiM2IzYmZiN2I3OTFiM2RhNWJj
10
+ ZmVkMTk0YzZjZjFmZTQ5MDM5NzMwZmY0MzlhZThhOTdiNDc5MWQwMDM3MTEz
11
+ YmQ1MDlhODQ4MzM4Y2M2NjU3ZGU2YmU4MzY4ZDc3YTRhMjk3NmI=
12
+ data.tar.gz: !binary |-
13
+ NjQ2ZGJiZTUyMjUwNGRjN2RhYzJjMWQ2MDM1ZjUwODMzNWZjY2VhNDZhODNm
14
+ OGZkMTk1ZTM1ODhkZTJmOWVkYjFlNzRkM2M3NjcwNmU0YzVhY2QzMzc2Nzcy
15
+ ZWVlOWZjZWYxZDU3MTFlNmE1NTdiM2Y2Y2IzOThhODgzNjUyOWQ=
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.description = %q{DTK Common Core is a shared library used by several DTK components.}
8
8
  gem.summary = %q{Common libraries used for DTK CLI client.}
9
9
  gem.homepage = "https://github.com/rich-reactor8/dtk-common-repo"
10
- gem.licenses = ["GPL-3.0"]
10
+ gem.licenses = ["Apache-2.0"]
11
11
 
12
12
  gem.files = `git ls-files`.split($\)
13
13
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -145,4 +145,4 @@ module DTK
145
145
  end
146
146
  end
147
147
  end
148
- end
148
+ end
@@ -15,6 +15,6 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- module DtkCommonCore
19
- VERSION="0.8.0"
20
- end
18
+ module DtkCommonCore
19
+ VERSION="0.9.0"
20
+ end
@@ -140,4 +140,4 @@ module DTK
140
140
  "queue #{queue_name} does not exist"
141
141
  end
142
142
  end
143
- end
143
+ end
@@ -15,62 +15,62 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- #TODO: should have a Common namespace put in after DTK
19
- #When creating these objects, an internal errro class is passed to the creation functions
20
- module DTK
21
- class RestError
22
- def self.create(err)
23
- if RestUsageError.match?(err)
24
- RestUsageError.new(err)
25
- elsif NotFound.match?(err)
26
- NotFound.new(err)
27
- else
28
- Internal.new(err)
29
- end
30
- end
31
- def initialize(err)
32
- @code = nil
33
- @message = nil
34
- end
35
- def hash_form()
36
- {:code => code||:error, :message => message||''}
37
- end
38
- private
39
- attr_reader :code, :message
40
- public
41
- #its either its a usage or and internal (application error) bug
42
- class Internal < RestError
43
- def hash_form()
44
- super.merge(:internal => true)
45
- end
46
- private
47
- def initialize(err)
48
- super
49
- @message = "#{err.to_s} (#{err.backtrace.first})"
50
- end
51
- end
52
- class RestUsageError < RestError
53
- def initialize(err)
54
- super
55
- @message = err.to_s
56
- end
57
- def self.match?(err)
58
- err.kind_of?(ErrorUsage)
59
- end
60
- end
61
- class NotFound < RestUsageError
62
- def self.match?(err)
63
- err.kind_of?(::NoMethodError) and is_controller_method(err)
64
- end
65
- def initialize(err)
66
- super
67
- @code = :not_found
68
- @message = "'#{err.name}' was not found"
69
- end
70
- private
71
- def self.is_controller_method(err)
72
- err.to_s =~ /#<XYZ::.+Controller:/
73
- end
74
- end
75
- end
76
- end
18
+ #TODO: should have a Common namespace put in after DTK
19
+ #When creating these objects, an internal errro class is passed to the creation functions
20
+ module DTK
21
+ class RestError
22
+ def self.create(err)
23
+ if RestUsageError.match?(err)
24
+ RestUsageError.new(err)
25
+ elsif NotFound.match?(err)
26
+ NotFound.new(err)
27
+ else
28
+ Internal.new(err)
29
+ end
30
+ end
31
+ def initialize(err)
32
+ @code = nil
33
+ @message = nil
34
+ end
35
+ def hash_form()
36
+ {:code => code||:error, :message => message||''}
37
+ end
38
+ private
39
+ attr_reader :code, :message
40
+ public
41
+ #its either its a usage or and internal (application error) bug
42
+ class Internal < RestError
43
+ def hash_form()
44
+ super.merge(:internal => true)
45
+ end
46
+ private
47
+ def initialize(err)
48
+ super
49
+ @message = "#{err.to_s} (#{err.backtrace.first})"
50
+ end
51
+ end
52
+ class RestUsageError < RestError
53
+ def initialize(err)
54
+ super
55
+ @message = err.to_s
56
+ end
57
+ def self.match?(err)
58
+ err.kind_of?(ErrorUsage)
59
+ end
60
+ end
61
+ class NotFound < RestUsageError
62
+ def self.match?(err)
63
+ err.kind_of?(::NoMethodError) and is_controller_method(err)
64
+ end
65
+ def initialize(err)
66
+ super
67
+ @code = :not_found
68
+ @message = "'#{err.name}' was not found"
69
+ end
70
+ private
71
+ def self.is_controller_method(err)
72
+ err.to_s =~ /#<XYZ::.+Controller:/
73
+ end
74
+ end
75
+ end
76
+ end
@@ -15,52 +15,53 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- module DTK
19
- module Common
20
- class SimpleHashObject < Hash
21
- def initialize(initial_val=nil,&block)
22
- block ? super(&block) : super()
23
- if initial_val
24
- replace(initial_val)
25
- end
26
- end
27
- end
28
-
29
- # require 'active_support/ordered_hash'
30
- # class SimpleOrderedHash < ::ActiveSupport::OrderedHash
31
- class SimpleOrderedHash < Hash
32
- def initialize(elements=[])
33
- super()
34
- elements = [elements] unless elements.kind_of?(Array)
35
- elements.each{|el|self[el.keys.first] = el.values.first}
36
- end
37
-
38
- #set unless value is nill
39
- def set_unless_nil(k,v)
40
- self[k] = v unless v.nil?
41
- end
42
- end
43
-
44
- class PrettyPrintHash < SimpleOrderedHash
45
- #field with '?' suffix means optioanlly add depending on whether name present and non-null in source
46
- #if block is given then apply to source[name] rather than returning just source[name]
47
- def add(model_object,*keys,&block)
48
- keys.each do |key|
49
- #if marked as optional skip if not present
50
- if key.to_s =~ /(^.+)\?$/
51
- key = $1.to_sym
52
- next unless model_object[key]
53
- end
54
- #special treatment of :id
55
- val = (key == :id ? model_object.id : model_object[key])
56
- self[key] = (block ? block.call(val) : val)
57
- end
58
- self
59
- end
60
-
61
- def slice(*keys)
62
- keys.inject(self.class.new){|h,k|h.merge(k => self[k])}
63
- end
64
- end
65
- end
66
- end
18
+ module DTK
19
+ module Common
20
+ class SimpleHashObject < Hash
21
+ def initialize(initial_val=nil,&block)
22
+ block ? super(&block) : super()
23
+ if initial_val
24
+ replace(initial_val)
25
+ end
26
+ end
27
+ end
28
+
29
+ # require 'active_support/ordered_hash'
30
+ # class SimpleOrderedHash < ::ActiveSupport::OrderedHash
31
+ class SimpleOrderedHash < Hash
32
+ def initialize(elements=[])
33
+ super()
34
+ elements = [elements] unless elements.kind_of?(Array)
35
+ elements.each{|el|self[el.keys.first] = el.values.first}
36
+ end
37
+
38
+ #set unless value is nill
39
+ def set_unless_nil(k,v)
40
+ self[k] = v unless v.nil?
41
+ end
42
+ end
43
+
44
+ class PrettyPrintHash < SimpleOrderedHash
45
+ #field with '?' suffix means optioanlly add depending on whether name present and non-null in source
46
+ #if block is given then apply to source[name] rather than returning just source[name]
47
+ def add(model_object,*keys,&block)
48
+ keys.each do |key|
49
+ #if marked as optional skip if not present
50
+ if key.to_s =~ /(^.+)\?$/
51
+ key = $1.to_sym
52
+ next unless model_object[key]
53
+ end
54
+ #special treatment of :id
55
+ val = (key == :id ? model_object.id : model_object[key])
56
+ self[key] = (block ? block.call(val) : val)
57
+ end
58
+ self
59
+ end
60
+
61
+ def slice(*keys)
62
+ keys.inject(self.class.new){|h,k|h.merge(k => self[k])}
63
+ end
64
+ end
65
+ end
66
+ end
67
+
data/lib/log.rb CHANGED
@@ -15,40 +15,40 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- #TODO: bring in a production quality ruby logging capability that gets wrapped here
19
- #TODO: would put this in config
20
- module DTK
21
- module Log
22
- Config = Hash.new
23
- Config[:print_time] = false
24
- Config[:print_method] = false
25
-
26
- def self.info(msg, out = $stdout)
27
- out << "info: "
28
- out << format(msg)
29
- end
30
- def self.debug(msg, out = $stdout)
31
- out << "debug: "
32
- out << format(msg)
33
- end
34
- def self.error(msg, out = $stdout)
35
- out << "error: "
36
- out << format(msg)
37
- end
38
- def self.info_pp(obj, out = $stdout)
39
- out << Aux::pp_form(obj)
40
- end
41
- def self.debug_pp(obj, out = $stdout)
42
- out << Aux::pp_form(obj)
43
- obj
44
- end
45
- private
46
- def self.format(msg)
47
- ret = String.new
48
- ret << "#{Time.now}: " if Config[:print_time]
49
- ret << "in fn: #{this_parent_method}: " if Config[:print_method]
50
- ret << msg
51
- ret << "\n"
52
- end
53
- end
54
- end
18
+ #TODO: bring in a production quality ruby logging capability that gets wrapped here
19
+ #TODO: would put this in config
20
+ module DTK
21
+ module Log
22
+ Config = Hash.new
23
+ Config[:print_time] = false
24
+ Config[:print_method] = false
25
+
26
+ def self.info(msg, out = $stdout)
27
+ out << "info: "
28
+ out << format(msg)
29
+ end
30
+ def self.debug(msg, out = $stdout)
31
+ out << "debug: "
32
+ out << format(msg)
33
+ end
34
+ def self.error(msg, out = $stdout)
35
+ out << "error: "
36
+ out << format(msg)
37
+ end
38
+ def self.info_pp(obj, out = $stdout)
39
+ out << Aux::pp_form(obj)
40
+ end
41
+ def self.debug_pp(obj, out = $stdout)
42
+ out << Aux::pp_form(obj)
43
+ obj
44
+ end
45
+ private
46
+ def self.format(msg)
47
+ ret = String.new
48
+ ret << "#{Time.now}: " if Config[:print_time]
49
+ ret << "in fn: #{this_parent_method}: " if Config[:print_method]
50
+ ret << msg
51
+ ret << "\n"
52
+ end
53
+ end
54
+ end
@@ -250,4 +250,4 @@ module DTK
250
250
  end
251
251
  end
252
252
  end
253
- end
253
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtk-common-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rich PELAVIN
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -31,8 +31,8 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".gitignore"
35
- - ".license_header"
34
+ - .gitignore
35
+ - .license_header
36
36
  - Gemfile
37
37
  - LICENSE
38
38
  - README.md
@@ -49,7 +49,7 @@ files:
49
49
  - lib/response.rb
50
50
  homepage: https://github.com/rich-reactor8/dtk-common-repo
51
51
  licenses:
52
- - GPL-3.0
52
+ - Apache-2.0
53
53
  metadata: {}
54
54
  post_install_message:
55
55
  rdoc_options: []
@@ -57,17 +57,17 @@ require_paths:
57
57
  - lib
58
58
  required_ruby_version: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - ! '>='
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
65
+ - - ! '>='
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.4.1
70
+ rubygems_version: 2.4.8
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: Common libraries used for DTK CLI client.