darksky-ruby 1.0.0 → 1.0.2

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
  SHA256:
3
- metadata.gz: cbc838749139b38df86429dd389d8758c5202fd9c77cf4ee7c8c3dc195e79ab3
4
- data.tar.gz: 0ef99dc1e4d4d3dccf3b206118da701b2655a89e05576fee1f6ddd3e366cf809
3
+ metadata.gz: bda3555290bd5cd17faed15701acb32e32469be470899b6dcd1902a1dd756d63
4
+ data.tar.gz: 211b506483df5a9b6810e793643d4ffaced59f0898092ca258834588cdf5011b
5
5
  SHA512:
6
- metadata.gz: 18eb161d289183c5b59dcef356665988db7e2f34d1d6a77d32a74f951b565f1960a5c65e6e95a9480b57622452a9fea8b2d1cdabbc8b34eb5eab6ad7518915fc
7
- data.tar.gz: 2e7f16e29f5e1f566a55cabfb2fb58652cf02f66b4960eb9858b97efe76fe860c7d4fd1d0563f4d844ec14518de3b2be99640100197dc7c09b59b8f34925fb09
6
+ metadata.gz: d425a8595355a1e6feea7b54fa74c31c7a2d82ec4ecfd5803f11168c34c876382ec3e82771a6725719c2d23fdbfadbf16cf4ab090974a508f09656f396a1bd3f
7
+ data.tar.gz: 9d8d5b360584269b5b677b8d55a3eddcd8439d961d721efcc06b65df9ce2c6117f3c70c16453f463748acc6de9640c8d40ff2012817f2ab0d65cecac1f8b38c8
data/.codeclimate.yml ADDED
@@ -0,0 +1,5 @@
1
+ exclude_patterns:
2
+ - "lib/darksky-ruby/optimist.rb"
3
+ plugins:
4
+ rubocop:
5
+ enabled: true
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # darksky-ruby
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/kajiki.svg)](http://badge.fury.io/rb/kajiki)
3
+ [![Gem Version](https://badge.fury.io/rb/darksky-ruby.svg)](http://badge.fury.io/rb/darksky-ruby) [![Maintainability](https://api.codeclimate.com/v1/badges/2806310071f132379085/maintainability)](https://codeclimate.com/github/kenjij/darksky-ruby/maintainability)
4
4
 
5
5
  Pure simple Ruby based [Dark Sky API](https://darksky.net/dev/) gem
6
6
 
data/bin/darksky CHANGED
@@ -2,9 +2,8 @@
2
2
  require 'darksky-ruby/optimist'
3
3
  require 'darksky-ruby'
4
4
 
5
-
6
5
  opts = Optimist::options do
7
- banner "darksky [options] <LAT,LON>"
6
+ banner 'darksky [options] <LAT,LON>'
8
7
  opt :key, 'API secret key', type: :string
9
8
  opt :loc, 'Location (latitude,longtitude)', type: :string
10
9
  opt :log, 'Log file', type: :string
data/darksky-ruby.gemspec CHANGED
@@ -1,10 +1,9 @@
1
1
  $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
2
2
  require 'darksky-ruby'
3
3
 
4
-
5
4
  Gem::Specification.new do |s|
6
5
  s.name = 'darksky-ruby'
7
- s.version = '1.0.0'
6
+ s.version = DarkSkyAPI::VERSION
8
7
  s.authors = ['Ken J.']
9
8
  s.email = ['kenjij@gmail.com']
10
9
  s.summary = %q{Pure simple Ruby based Dark Sky API gem}
@@ -1,9 +1,15 @@
1
+ # darksky-ruby - Pure simple Ruby based Dark Sky API gem
2
+ # Copyright (c) 2019 Ken J.
3
+
1
4
  require 'json'
2
5
 
3
6
  class DarkSkyAPI
7
+ VERSION = '1.0.2'
4
8
  DARKSKY_URL = 'https://api.darksky.net/'
5
9
  DARKSKY_PATH_TEMPLATE = '/forecast/%{key}/%{loc}'
6
- DARKSKY_BLOCK_NAMES = [:currently, :minutely, :hourly, :daily, :alerts, :flags]
10
+ DARKSKY_BLOCK_NAMES = [
11
+ :currently, :minutely, :hourly, :daily, :alerts, :flags
12
+ ]
7
13
 
8
14
  attr_accessor :key, :latitude, :longitude, :location, :time, :options
9
15
 
@@ -24,12 +30,12 @@ class DarkSkyAPI
24
30
  forecast(lat: lat, lon: lon, loc: loc, ts: ts)
25
31
  end
26
32
 
27
- def blocks()
33
+ def blocks
28
34
  exc = options[:exclude]
29
- exc.nil? ? exc = [] : exc = exc.split(',').map{ |n| n.to_sym }
35
+ exc = (exc.nil? ? [] : exc.split(',').map { |n| n.to_sym })
30
36
  h = {}
31
37
  DARKSKY_BLOCK_NAMES.each { |n| h[n] = !exc.include?(n) }
32
- return h
38
+ h
33
39
  end
34
40
 
35
41
  def blocks=(h)
@@ -47,28 +53,26 @@ class DarkSkyAPI
47
53
  def request(loc, ts)
48
54
  path = DARKSKY_PATH_TEMPLATE % {key: key, loc: loc}
49
55
  path += ",#{ts}" if ts
50
- options.empty? ? o = nil : o = options
56
+ o = (options.empty? ? nil : options)
51
57
  data = http.get(path: path, params: o)
52
- return handle_response_data(data)
58
+ handle_response_data(data)
53
59
  end
54
60
 
55
61
  def http
56
- unless @http
57
- @http = Neko::HTTP.new(DARKSKY_URL)
58
- end
59
- return @http
62
+ @http ||= Neko::HTTP.new(DARKSKY_URL)
60
63
  end
61
64
 
62
65
  def format_path(path)
63
66
  path = '/' + path unless path.start_with?('/')
64
- return path + '.json'
67
+ path + '.json'
65
68
  end
66
69
 
67
70
  def handle_response_data(data)
68
71
  if data[:code] != 200
69
- Neko.logger.error("HTTP response error: #{data[:code]}\n#{data[:message]}")
72
+ msg = "HTTP response error: #{data[:code]}\n#{data[:message]}"
73
+ Neko.logger.error(msg)
70
74
  return nil
71
75
  end
72
- return JSON.parse(data[:body], {symbolize_names: true})
76
+ JSON.parse(data[:body], symbolize_names: true)
73
77
  end
74
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darksky-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken J.
@@ -18,6 +18,7 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".codeclimate.yml"
21
22
  - LICENSE
22
23
  - README.md
23
24
  - bin/darksky
@@ -45,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
48
  requirements: []
48
- rubygems_version: 3.0.6
49
+ rubygems_version: 3.0.4
49
50
  signing_key:
50
51
  specification_version: 4
51
52
  summary: Pure simple Ruby based Dark Sky API gem