pad_utils 1.10.0 → 1.11.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: 6d5fba0204ba064f38f4360292e38fceffc180f5
4
- data.tar.gz: 1237b4dccf91136ae5f09159d2b118ad464b637d
3
+ metadata.gz: 164a7a9d1b5d575fa09d5a6912e78141cc8bd5aa
4
+ data.tar.gz: 9d418e97d8519acb4bcaf3773d66f9c279df8225
5
5
  SHA512:
6
- metadata.gz: 89c62f39ebb1cd2bdf788e11b04a1df84dc09e5cc0e86aa37940f28efdaaa11a9f3510ca26f21461404a5580d0e1b258d992bb8b49c2b46c3965ccc27dea80bb
7
- data.tar.gz: 828b14c1f37a80296995d513c986ad8cd29ceeb15463418ef8fa523e683e9cf3ef371293ff5330484384bd40c7e3b36871a11f53de0256b90b43d29562af781f
6
+ metadata.gz: 6d92e366b5ea10c6d66f9c5b34cd299cd58ff8aa5674050930d2ab7b55feeb7469372f126c769f0beb84016ad35c51d824ee5506d8aac46891803d827a02f653
7
+ data.tar.gz: 217ef6fb0b8bd57926ea645fdb558c5abb1bcbf6a0c694c64afe6adb156311f0833faa4b91593fe90622c3ab568446dc0da9ebdce36952a48d3023421c326577
@@ -80,10 +80,10 @@ module PadUtils
80
80
  #
81
81
  # @note Won't override directory content if it already exists.
82
82
  #
83
- # @param dir_name [String] the directory path and name
83
+ # @param dir_name [String] the directory path and name (add `/.`)
84
84
  # @return [Void] nothing
85
85
  # @example
86
- # PadUtils.create_directory("path/to/dir")
86
+ # PadUtils.create_directory("path/to/dir/.")
87
87
  def self.create_directory(dir_name)
88
88
  dirname = File.dirname(dir_name)
89
89
  unless File.directory?(dirname)
@@ -0,0 +1,70 @@
1
+ module PadUtils
2
+ module Padstone
3
+
4
+ # Prod server URL
5
+ SERVER = "http://padstone.io/services/v1"
6
+
7
+ # Dev server URL
8
+ DEV_SERVER = "http://localhost:3000/services/v1"
9
+
10
+ # Retrieves Padstone servers connection status.
11
+ #
12
+ # @return [Hash]
13
+ # @example
14
+ # result = PadUtils::Padstone::connection_status
15
+ # # => {dev: :up, prod: :down}
16
+ def self.connection_status
17
+ result = {}
18
+ result[:dev] = dev_connection_status
19
+ result[:prod] = prod_connection_status
20
+ result
21
+ end
22
+
23
+ # Checks if Padstone dev or prod server answers.
24
+ #
25
+ # @note Dev or Prod will be chosen based on `ENV['PADSTONE']` which can
26
+ # be `development` or `production`
27
+ # @return [Boolean]
28
+ # @example
29
+ # ENV['PADSTONE'] = 'development'
30
+ # PadUtils::Padstone.connected? # => true
31
+ def self.connected?
32
+ up = false
33
+ if ENV['PADSTONE'] == "development"
34
+ up = dev_connection_status == :up
35
+ else
36
+ up = prod_connection_status == :up
37
+ end
38
+ up
39
+ end
40
+
41
+ # Gets the connection status of the dev server.
42
+ #
43
+ # @return [Symbol] can be `:up` or `:down`
44
+ # @example
45
+ # PadUtils::Padstone.dev_connection_status # => :up
46
+ def self.dev_connection_status
47
+ reply = PadUtils.http_get("#{DEV_SERVER}/connection/rick")
48
+ if reply.nil? || reply[:message].nil? || reply[:message] != "morty"
49
+ :down
50
+ else
51
+ :up
52
+ end
53
+ end
54
+
55
+ # Gets the connection status of the prod server.
56
+ #
57
+ # @return [Symbol] can be `:up` or `:down`
58
+ # @example
59
+ # PadUtils::Padstone.prod_connection_status # => :down
60
+ def self.prod_connection_status
61
+ reply = PadUtils.http_get("#{SERVER}/connection/rick")
62
+ if reply.nil? || reply[:message].nil? || reply[:message] != "morty"
63
+ :down
64
+ else
65
+ :up
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -1,4 +1,4 @@
1
1
  module PadUtils
2
2
  # PadUtils version number
3
- VERSION = "1.10.0"
3
+ VERSION = "1.11.0"
4
4
  end
data/lib/pad_utils.rb CHANGED
@@ -9,6 +9,7 @@ require_relative "pad_utils/pad_color"
9
9
  require_relative "pad_utils/pad_code"
10
10
  require_relative "pad_utils/pad_security"
11
11
  require_relative "pad_utils/pad_http"
12
+ require_relative "pad_utils/padstone/connection"
12
13
 
13
14
  # Main namespace for PadUtils.
14
15
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pad_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Schuele
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-12 00:00:00.000000000 Z
11
+ date: 2016-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -74,6 +74,7 @@ files:
74
74
  - lib/pad_utils/pad_security.rb
75
75
  - lib/pad_utils/pad_text.rb
76
76
  - lib/pad_utils/pad_time.rb
77
+ - lib/pad_utils/padstone/connection.rb
77
78
  - lib/pad_utils/version.rb
78
79
  homepage: http://padstone.io
79
80
  licenses: