tz_lookup_wrapper 0.0.4 → 0.1.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: 8857f1da7ee5eef9c2fa16aaea0756008d52f5cb
4
- data.tar.gz: cc41ea06e94ab6285e6651e3266dfca575243f43
3
+ metadata.gz: 7eb8b15985e2f6a21da69e535776fd557af4c1dc
4
+ data.tar.gz: 9675aac50f843725ace9e9c70f7ee15aa0e26644
5
5
  SHA512:
6
- metadata.gz: 6279162bd9827f65eb0108ad832ae27141a43a085c0a324a302937bb03113cf5b7dd97105a133b2223169ef5b3b21d69fff9e9f3543ff500548af47d3772e79f
7
- data.tar.gz: 35fbf1e9e3322624440d38bab028cc26861291e16ad4c036df205170944ac605c55c3f8643f5c33879d788a31cd4901a30651b022f5356339920f75553dc1254
6
+ metadata.gz: 8d3aea5abc34dfab4889f86abfd31a2491bb5ccc17091a217b4446e5e440152a8fbb256ee852bc5ad560fdacbf08b053da379e03a63fc61909704e48d04845ce
7
+ data.tar.gz: 052a6a115eb34c2841423a2db7ea4e5a86f84fc341c3e0cab3870e35796a3a5328fcb1cea9a60e7e82bfdb3620a39f7d27e933e5a47efef30764ad829e8dfb60
@@ -1,12 +1,19 @@
1
1
  require "tz_lookup_wrapper/version"
2
2
  require "tz_lookup_wrapper/active_support"
3
- require "tz_lookup_wrapper/detect_node"
4
- require 'tz_lookup_wrapper/exception'
5
3
 
6
4
  module TzLookupWrapper
5
+ class TzLookupWrapperException < Exception;end
7
6
 
8
7
  TZ_LOOKUP_PATH="#{File.dirname(__FILE__)}/../vendor/tz-lookup/index.js"
9
-
8
+ NODE_BIN = begin
9
+ if (`nodejs --version` rescue false)
10
+ 'nodejs'
11
+ elsif (`node --version` rescue false)
12
+ 'node'
13
+ else
14
+ raise TzLookupWrapperException.new("Could not find nodejs runtime.");
15
+ end
16
+ end
10
17
 
11
18
  # Lookup a timezone
12
19
  #
@@ -30,7 +37,7 @@ module TzLookupWrapper
30
37
  }
31
38
  HEREDOC
32
39
  result = nil
33
- IO.popen(node_bin, 'r+') do |io|
40
+ IO.popen(NODE_BIN, 'r+') do |io|
34
41
  io.puts(script)
35
42
  io.close_write
36
43
  result = io.gets
@@ -38,13 +45,7 @@ module TzLookupWrapper
38
45
  if $?.success?
39
46
  result
40
47
  else
41
- raise WrapperException.new result || "Empty output"
48
+ raise TzLookupWrapperException.new result || "Empty output"
42
49
  end
43
50
  end
44
-
45
- private
46
-
47
- def self.node_bin
48
- @node_bin ||= TzLookupWrapper::DetectNode.detect
49
- end
50
51
  end
@@ -1,3 +1,3 @@
1
1
  module TzLookupWrapper
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tz_lookup_wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rajitha Perera
@@ -68,10 +68,7 @@ files:
68
68
  - lib/tz_lookup_wrapper.rb
69
69
  - lib/tz_lookup_wrapper.rb~
70
70
  - lib/tz_lookup_wrapper/active_support.rb
71
- - lib/tz_lookup_wrapper/detect_node.rb
72
- - lib/tz_lookup_wrapper/exception.rb
73
71
  - lib/tz_lookup_wrapper/version.rb
74
- - spec/lib/tz_lookup_wrapper/detect_node_spec.rb
75
72
  - spec/lib/tz_lookup_wrapper_spec.rb
76
73
  - spec/spec_helper.rb
77
74
  - tz_lookup_wrapper.gemspec
@@ -102,11 +99,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
99
  version: '0'
103
100
  requirements: []
104
101
  rubyforge_project:
105
- rubygems_version: 2.0.2
102
+ rubygems_version: 2.0.14
106
103
  signing_key:
107
104
  specification_version: 4
108
105
  summary: Ruby wrapper for tz-lookup npm package.
109
106
  test_files:
110
- - spec/lib/tz_lookup_wrapper/detect_node_spec.rb
111
107
  - spec/lib/tz_lookup_wrapper_spec.rb
112
108
  - spec/spec_helper.rb
@@ -1,35 +0,0 @@
1
- module TzLookupWrapper
2
- class DetectNode
3
- MIN_VER = [0, 10, 0]
4
-
5
- def self.detect
6
- node_bins.each do |node|
7
- detected_version = (`#{node} --version`)[1..-1].split(".") rescue "v0.0.0"
8
- if detected_version[0].to_i >= MIN_VER[0] and
9
- detected_version[1].to_i >= MIN_VER[1] and
10
- detected_version[2].to_i >= MIN_VER[2]
11
- return node
12
- end
13
- end
14
- raise TzLookupWrapper::NodeOutdatedException.new MIN_VER
15
- end
16
-
17
-
18
- private
19
-
20
- def self.node_bins
21
- node_binaries = [ 'node', 'nodejs' ]
22
- detected = []
23
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
24
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
25
- exts.each { |ext|
26
- node_binaries.each do |cmd|
27
- bin = File.join(path, "#{cmd}#{ext}")
28
- detected << bin if File.executable?(bin) && !File.directory?(bin)
29
- end
30
- }
31
- end
32
- return detected
33
- end
34
- end
35
- end
@@ -1,11 +0,0 @@
1
- module TzLookupWrapper
2
- class BaseTzLookupWrapperException < Exception;end
3
- class WrapperException < BaseTzLookupWrapperException;end
4
-
5
- class NodeOutdatedException < BaseTzLookupWrapperException
6
- def initialize(min_ver)
7
- super "Cannot find a supported NodeJS installation. Minimum required version (v#{min_ver.join(".") || ""})"
8
- end
9
- end
10
-
11
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe TzLookupWrapper::DetectNode do
4
-
5
- end