meteo_pl 2.0.2 → 2.0.3

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
- SHA1:
3
- metadata.gz: e8f5c7a1b5099be45a9390ba4b5b2112650ee4b5
4
- data.tar.gz: 4150a1eb57ee22d1e6bf5eafb7382f5a6da70f56
2
+ SHA256:
3
+ metadata.gz: 3f0af1121139a606c58aa303fae1ea1f5d5fdf8b4a9bf41981f0e1fa4b27d9c4
4
+ data.tar.gz: 6c7770bca0c36d7c9c433ba668365f97eb6c590619d29f62757ef39b7cfe7adf
5
5
  SHA512:
6
- metadata.gz: 7d7ad37d42803a4d5468af014f5af1ac29cac53fff851d7024a79cc65b5453426b02a6ae15259876e5ee3d0430d00e1f78c62b7f634c9f404d2da8b8ff72edf7
7
- data.tar.gz: ea83a301f670ae8a795f8fc9c7e6b2c7a4a72c836ced67b46fd35d98ab7fac1aaa95e6acc6eea7eb381802b05cb84a9497992b85dab9e8b459c067cff677be9b
6
+ metadata.gz: 98562aff6d31337ec1c1d05a69ec675a8f016afc02059f8fb2cc8be4b41c829434aa31f4f734c0d8ca6cdb1300a95033d050eb0723af8e54c0bdf12fb644d2ad
7
+ data.tar.gz: 15ab3440eeb8292991fc893a2d580d2c4b3919b5c8c3e1f74667169f36cdb8c311594a57192d47ff68a006627bfa8cbb69eed734a73670016134841b90b4301d
data/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  [![Gem Version](https://img.shields.io/gem/v/meteo_pl.svg?style=flat-square&label=version)](https://rubygems.org/gems/meteo_pl)
4
4
  [![Build Status](https://img.shields.io/travis/kotu-pl/meteo_pl/master.svg?style=flat-square&label=build)](https://travis-ci.org/kotu-pl/meteo_pl)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/6cf15b1ae0a9ed1d8a2c/maintainability)](https://codeclimate.com/github/kotu-pl/meteo_pl/maintainability)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/720f2172fb5523c968f5/maintainability)](https://codeclimate.com/github/kotu-pl/meteo_pl/maintainability)
6
6
 
7
7
  This gem fetches and manipulates on weather forecast graphs from http://www.meteo.pl service.
8
8
  It allows to fetch coamps and um diagrams separately and open open them in your default image viewer.
9
9
 
10
+ **Architecture**
11
+
12
+ *lib/meteo_pl/exec* directory contains usage examples (as MeteoPl::Exec::Shell class),
13
+ you should use provided compontents to prepare similar classi (or script) that meets your requirements.
14
+
10
15
  **Usage example:**
11
16
 
12
17
  Install gem in system-wide context, than create executable `meteo` named script:
@@ -16,15 +21,7 @@ Install gem in system-wide context, than create executable `meteo` named script:
16
21
 
17
22
  require 'meteo_pl'
18
23
 
19
- command_line = MeteoPl::Utility::Command.new(ARGV)
20
-
21
- if command_line.call
22
- MeteoPl::Utility::Forecast.for(
23
- command_line.location,
24
- timeout: command_line.options[:timeout],
25
- period: command_line.options[:period]
26
- )
27
- end
24
+ MeteoPl::Exec::Shell.call
28
25
  ```
29
26
 
30
27
  Than you'll be able to generate the weather forecast diagram from your command line:
@@ -42,6 +39,7 @@ To check all available options just run a script w/o arguments or with -h flag.
42
39
 
43
40
  ### Versions
44
41
 
42
+ * 2.0.3 Adding *Exec* namespece containing example classes
45
43
  * 2.0.2 Increased code quality
46
44
  * 2.0.1 Minor code improvements, add TravisCI
47
45
  * 2.0.0 Gem has been written from scratch, all external dependencies removed
@@ -0,0 +1,29 @@
1
+ module MeteoPl
2
+ module Exec
3
+ module Shell
4
+ def call
5
+ command_line = MeteoPl::Utility::Command.new(ARGV)
6
+ return unless command_line.call
7
+
8
+ location = command_line.location,
9
+ timeout = command_line.options[:timeout]
10
+ period = command_line.options[:period]
11
+
12
+ http_fetcher = Net::Http.new(timeout)
13
+ graph = Utility::MobileMeteoGraph.new(
14
+ http_fetcher, location, period
15
+ )
16
+
17
+ unless graph.uri
18
+ puts 'Graph for given location does not exists'
19
+ return
20
+ end
21
+
22
+ Utility::Presenter.new(
23
+ http_fetcher, IO::FileHandler.new, IO::ImageOpener.new, graph
24
+ ).show
25
+ end
26
+ module_function :call
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module MeteoPl
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
data/lib/meteo_pl.rb CHANGED
@@ -4,4 +4,4 @@ require 'meteo_pl/net/http'
4
4
  require 'meteo_pl/utility/command'
5
5
  require 'meteo_pl/utility/graph'
6
6
  require 'meteo_pl/utility/presenter'
7
- require 'meteo_pl/utility/forecast'
7
+ require 'meteo_pl/exec/shell'
@@ -1,4 +1,4 @@
1
- describe MeteoPl::Utility::Forecast do
1
+ describe MeteoPl::Exec::Shell do
2
2
  describe 'proper output' do
3
3
  context 'returns error message if location does not exist' do
4
4
  # request mock instead
@@ -14,7 +14,7 @@ describe MeteoPl::Utility::Forecast do
14
14
  )
15
15
  expect_any_instance_of(MeteoPl::Utility::Presenter).not_to receive(:show)
16
16
 
17
- described_class.for('Warszawa', timeout: 2, period: 60)
17
+ described_class.call
18
18
  end
19
19
  end
20
20
 
@@ -30,7 +30,7 @@ describe MeteoPl::Utility::Forecast do
30
30
  expect($stdout).not_to receive(:puts)
31
31
  expect_any_instance_of(MeteoPl::Utility::Presenter).to receive(:show)
32
32
 
33
- described_class.for('Warszawa', timeout: 2, period: 60)
33
+ described_class.call
34
34
  end
35
35
  end
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meteo_pl
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Kot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-07 00:00:00.000000000 Z
11
+ date: 2018-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -67,15 +67,16 @@ files:
67
67
  - README.md
68
68
  - Rakefile
69
69
  - lib/meteo_pl.rb
70
+ - lib/meteo_pl/exec/shell.rb
70
71
  - lib/meteo_pl/io/file_handler.rb
71
72
  - lib/meteo_pl/io/image_opener.rb
72
73
  - lib/meteo_pl/net/http.rb
73
74
  - lib/meteo_pl/utility/command.rb
74
- - lib/meteo_pl/utility/forecast.rb
75
75
  - lib/meteo_pl/utility/graph.rb
76
76
  - lib/meteo_pl/utility/presenter.rb
77
77
  - lib/meteo_pl/version.rb
78
78
  - meteo_pl.gemspec
79
+ - spec/exec/shell_spec.rb
79
80
  - spec/io/file_handler_spec.rb
80
81
  - spec/io/image_opener_spec.rb
81
82
  - spec/net/http_spec.rb
@@ -83,7 +84,6 @@ files:
83
84
  - spec/support/1px.png
84
85
  - spec/support/shared_helper.rb
85
86
  - spec/utility/command_spec.rb
86
- - spec/utility/forecast_spec.rb
87
87
  - spec/utility/graph_spec.rb
88
88
  - spec/utility/presenter_spec.rb
89
89
  homepage: http://github.com/kotu-pl/meteo_pl
@@ -106,11 +106,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.6.11
109
+ rubygems_version: 2.7.3
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Weather forecast from http://www.meteo.pl
113
113
  test_files:
114
+ - spec/exec/shell_spec.rb
114
115
  - spec/io/file_handler_spec.rb
115
116
  - spec/io/image_opener_spec.rb
116
117
  - spec/net/http_spec.rb
@@ -118,6 +119,5 @@ test_files:
118
119
  - spec/support/1px.png
119
120
  - spec/support/shared_helper.rb
120
121
  - spec/utility/command_spec.rb
121
- - spec/utility/forecast_spec.rb
122
122
  - spec/utility/graph_spec.rb
123
123
  - spec/utility/presenter_spec.rb
@@ -1,22 +0,0 @@
1
- module MeteoPl
2
- module Utility
3
- module Forecast
4
- def for(location, timeout:, period:)
5
- http_fetcher = Net::Http.new(timeout)
6
- graph = MobileMeteoGraph.new(
7
- http_fetcher, location, period
8
- )
9
-
10
- unless graph.uri
11
- puts 'Graph for given location does not exists'
12
- return
13
- end
14
-
15
- Presenter.new(
16
- http_fetcher, IO::FileHandler.new, IO::ImageOpener.new, graph
17
- ).show
18
- end
19
- module_function :for
20
- end
21
- end
22
- end