strateg 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a1a4f1154969348e908127b469d266e6051e0c9249ea3acda4bf5adf7e409a45
4
+ data.tar.gz: 3800d40d7d2ed7c5b5f9ff0a07336c1334c716fe777add40d243f49232e36501
5
+ SHA512:
6
+ metadata.gz: d836562f52a162b5ff8f65fe9d02763042f35b8ed5b8bdefd3cf723b6df0c27a2750a032aba6b91eced3a557d7e3e0259d78f5ab0f877540cb41a2a7433408a4
7
+ data.tar.gz: dedf38c8edd153922b6424d19cedf8aef5f2395259750ef6f382ee3dd818db8fef5602ed660cf0ca8d99459162ff012e29dd77128737e839c3ccc67b618d994b
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
14
+
15
+ Layout/EndOfLine:
16
+ Enabled: False
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-01-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at jakub.polak.vz@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in strateg.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "httparty"
data/Gemfile.lock ADDED
@@ -0,0 +1,63 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ strateg (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ httparty (0.17.3)
12
+ mime-types (~> 3.0)
13
+ multi_xml (>= 0.5.2)
14
+ mime-types (3.3.1)
15
+ mime-types-data (~> 3.2015)
16
+ mime-types-data (3.2021.0901)
17
+ multi_xml (0.6.0)
18
+ parallel (1.20.1)
19
+ parser (3.0.2.0)
20
+ ast (~> 2.4.1)
21
+ rainbow (3.0.0)
22
+ rake (13.0.6)
23
+ regexp_parser (2.1.1)
24
+ rexml (3.2.5)
25
+ rspec (3.10.0)
26
+ rspec-core (~> 3.10.0)
27
+ rspec-expectations (~> 3.10.0)
28
+ rspec-mocks (~> 3.10.0)
29
+ rspec-core (3.10.1)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-expectations (3.10.1)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-mocks (3.10.2)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.10.0)
37
+ rspec-support (3.10.2)
38
+ rubocop (1.18.4)
39
+ parallel (~> 1.10)
40
+ parser (>= 3.0.0.0)
41
+ rainbow (>= 2.2.2, < 4.0)
42
+ regexp_parser (>= 1.8, < 3.0)
43
+ rexml
44
+ rubocop-ast (>= 1.8.0, < 2.0)
45
+ ruby-progressbar (~> 1.7)
46
+ unicode-display_width (>= 1.4.0, < 3.0)
47
+ rubocop-ast (1.9.1)
48
+ parser (>= 3.0.1.1)
49
+ ruby-progressbar (1.11.0)
50
+ unicode-display_width (2.0.0)
51
+
52
+ PLATFORMS
53
+ x86_64-linux
54
+
55
+ DEPENDENCIES
56
+ httparty
57
+ rake (~> 13.0)
58
+ rspec (~> 3.0)
59
+ rubocop (~> 1.7)
60
+ strateg!
61
+
62
+ BUNDLED WITH
63
+ 2.2.24
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Jakub Polak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,217 @@
1
+ ![STRATEG](https://strateg.stat.gov.pl/strateg_small.png)
2
+
3
+ The STRATEG system is a publicly accessible system, designed to facilitate the process of monitoring the development and evaluating the effects of actions undertaken to strengthen social cohesion. The database contains a comprehensive set of key measures to monitor (mainly annual) development at the national level, as well as at lower levels of territorial division. To ensure international comparability, the database also contains the main indicators for the EU, its member states and regions at NUTS 2 level.
4
+
5
+ The system is also used as a repository of indicators relating to various strategies – starting from the Europe 2020 Strategy of the EU and the Strategy for Responsible Development, through 9 integrated strategies concerning economic efficiency and innovation, transport, energy security and environment, regional development, human capital, social capital, sustainable development of rural areas, agriculture and fishing industry, efficient state and national security. In addition, the system stores information on indicators for regional strategies, Partnership Agreement, National and Regional Operational Programmes, Integrated Territorial Investments Strategies, National Urban Policy as well as Governmental Programme Accessibility Plus.
6
+
7
+ [The Strateg API application](https://strateg.stat.gov.pl/apidocs/?lang=en) was created to extend the availability of the STRATEG system. The API has been prepared in accordance with currently used standards and allows to download the full range of data in JSON format, i.e. data with metadata in both Polish and English versions.
8
+
9
+
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'strateg'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle install
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install strateg
26
+
27
+ ## Usage
28
+
29
+ ### Strategies and programmes
30
+
31
+ #### Gets list of strategies and operational programmes
32
+
33
+ ```ruby
34
+ Strateg.list_of_strategies_and_operational_programmes
35
+ ```
36
+
37
+
38
+
39
+ #### Gets strategies data
40
+
41
+ ```ruby
42
+ Strateg.strategy_data(strategy_id)
43
+ ```
44
+
45
+ | Variables | Data type | Required |
46
+ |---------------|---------------|----------|
47
+ | ```strategy_id``` | ```Integer``` | True |
48
+
49
+
50
+ ### Cohesion policies
51
+ #### Gets cohesion policies list
52
+
53
+ ```ruby
54
+ Strateg.cohesion_policies_list
55
+ ```
56
+
57
+ #### Gets cohesion policy data
58
+
59
+ ```ruby
60
+ Strateg.cohesion_policy_data(cohesion_id)
61
+ ```
62
+
63
+ | Variables | Data type | Required |
64
+ |---------------|---------------|----------|
65
+ | ```cohesion_id``` | ```Integer``` | True |
66
+
67
+ ### Statistics by theme
68
+
69
+
70
+ #### Gets list of thematic areas
71
+
72
+ ```ruby
73
+ Strateg.list_of_thematic_areas
74
+ ```
75
+
76
+ #### Gets data for the thematic area
77
+
78
+ ```ruby
79
+ Strateg.thematic_area_data(area_id)
80
+ ```
81
+
82
+ | Variables | Data type | Required |
83
+ |---------------|---------------|----------|
84
+ | ```area_id``` | ```Integer``` | True |
85
+
86
+ ### Territorial data
87
+
88
+ #### Gets the list of territorial units from the portrait jt
89
+
90
+ ```ruby
91
+ Strateg.list_of_territorial_units
92
+ ```
93
+
94
+ #### Gets territory data
95
+
96
+ ```ruby
97
+ Strateg.territory_data(territory_code)
98
+ ```
99
+
100
+ | Variables | Data type | Required |
101
+ |---------------|---------------|----------|
102
+ | ```territory_code``` | ```Integer``` | True |
103
+
104
+
105
+ ### Indicators
106
+
107
+ #### Gets list of indicators
108
+
109
+ ```ruby
110
+ Strateg.list_of_indicators
111
+ ```
112
+
113
+ #### Gets available indicator's dimensions
114
+
115
+ ```ruby
116
+ Strateg.available_indicators_dimensions(area_id)
117
+ ```
118
+
119
+ | Variables | Data type | Required |
120
+ |---------------|---------------|----------|
121
+ | ```area_id``` | ```Integer``` | True |
122
+
123
+
124
+ #### Gets indicator's dimension data
125
+
126
+ ```ruby
127
+ Strateg.indicators_dimension_data(indicator_id, params = {})
128
+ ```
129
+
130
+ | Variables | Data type | Required |
131
+ |--------------------|---------------|----------|
132
+ | ```indicator_id``` | ```Integer``` | True |
133
+ | ```level_id``` | ```String``` | False |
134
+ | ```place_id``` | ```Integer``` | False |
135
+ | ```section_id``` | ```Integer``` | False |
136
+ | ```sex_id``` | ```Integer``` | False |
137
+
138
+ _**level_id [String]**_
139
+
140
+ territorial level of data
141
+ - 0 - EU total and countries level
142
+ - 2 - Voivodships Level
143
+ - 3 - Regions Level
144
+ - 4 - Subregions Level
145
+ - 5 - Powiats Level
146
+ - 6 - Gminas Level
147
+ - M - National Urban Policy
148
+ - O - Functional areas
149
+ - Z - Integrated Territorial Investments
150
+
151
+ _**place_id [Integer]**_
152
+ - 1 - total
153
+ - 2 - urban
154
+ - 3 - rural
155
+
156
+ _**section_id [Integer]**_
157
+
158
+ id of age group: <1, 39> and <1001, 1003>; 1 means 'total'
159
+
160
+ _**sex_id [Integer]**_
161
+ - 1 - total
162
+ - 2 - female
163
+ - 3 - male
164
+
165
+
166
+ #### Gets real data
167
+
168
+ ```ruby
169
+ Strateg.real_data(dimension_id, indicator_id, params = {})
170
+ ```
171
+
172
+ | Variables | Data type | Required |
173
+ |--------------------|---------------|----------|
174
+ | ```dimension_id``` | ```Integer``` | True |
175
+ | ```indicator_id``` | ```Integer``` | True |
176
+ | ```territory_code``` | ```String``` | False |
177
+ | ```level_id``` | ```String``` | False |
178
+
179
+ ### Indicators metrics
180
+
181
+ #### Gets indicator's metadata
182
+
183
+ ```ruby
184
+ Strateg.indicators_metadata(indicator_id, params = {})
185
+ ```
186
+
187
+ | Variables | Data type | Required |
188
+ |--------------------|---------------|----------|
189
+ | ```indicator_id``` | ```Integer``` | True |
190
+
191
+ ### Strategies and programmes coordinators
192
+
193
+ #### Gets coordinators data
194
+
195
+ ```ruby
196
+ Strateg.indicators_metadata(strategy_id, params = {})
197
+ ```
198
+
199
+ | Variables | Data type | Required |
200
+ |--------------------|---------------|----------|
201
+ | ```strategy_id``` | ```Integer``` | True |
202
+
203
+ ## Development
204
+
205
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
206
+
207
+ ## Contributing
208
+
209
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kupolak/strateg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kupolak/strateg/blob/master/CODE_OF_CONDUCT.md).
210
+
211
+ ## License
212
+
213
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
214
+
215
+ ## Code of Conduct
216
+
217
+ Everyone interacting in the Strateg project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kupolak/strateg/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "core"
4
+ require_relative "request"
5
+
6
+ # STRATEG module for interaction with API
7
+ module Strateg
8
+ VERSION = "0.1.0"
9
+
10
+ module_function
11
+
12
+ # Strategies and programmes
13
+
14
+ # Gets list of strategies and operational programmes
15
+ def list_of_strategies_and_operational_programmes
16
+ Request.new(Core::STRATEGIES_AND_PROGRAMMES).content
17
+ end
18
+
19
+ # Gets strategies data
20
+ # @param [Integer] strategy_id
21
+ def strategy_data(strategy_id)
22
+ Request.new(Core::STRATEGIES_AND_PROGRAMMES + "/#{strategy_id}").content
23
+ end
24
+
25
+ # Gets a description of a strategy
26
+ # @param [Integer] strategy_id
27
+ def strategy_description(strategy_id)
28
+ Request.new(Core::STRATEGIES_AND_PROGRAMMES + "/#{strategy_id}/description").content
29
+ end
30
+
31
+ # Cohesion policies
32
+
33
+ # Gets cohesion policies list
34
+ def cohesion_policies_list
35
+ Request.new(Core::COHESION_POLICY).content
36
+ end
37
+
38
+ # Gets cohesion policy data
39
+ # @param [Integer] cohesion_id
40
+ def cohesion_policy_data(cohesion_id)
41
+ Request.new(Core::COHESION_POLICY + "/#{cohesion_id}").content
42
+ end
43
+
44
+ # Statistics by theme
45
+
46
+ # Gets list of thematic areas
47
+ def list_of_thematic_areas
48
+ Request.new(Core::STATISTICS_BY_THEME).content
49
+ end
50
+
51
+ # Gets data for the thematic area
52
+ # @param [Integer] area_id
53
+ def thematic_area_data(area_id)
54
+ Request.new(Core::STATISTICS_BY_THEME + "/#{area_id}").content
55
+ end
56
+
57
+ # Territorial data
58
+
59
+ # Gets the list of territorial units from the portrait jt
60
+ def list_of_territorial_units
61
+ Request.new(Core::TERRITORIAL_DATA).content
62
+ end
63
+
64
+ # Gets territory data
65
+ # @param [Integer] territory_code
66
+ def territory_data(territory_code)
67
+ Request.new(Core::TERRITORIAL_DATA + "/#{territory_code}").content
68
+ end
69
+
70
+ # Indicators
71
+
72
+ # Gets list of indicators
73
+ def list_of_indicators
74
+ Request.new(Core::INDICATORS).content
75
+ end
76
+
77
+ # Gets available indicator's dimensions
78
+ # @param [Integer] indicator_id
79
+ def available_indicators_dimensions(indicator_id)
80
+ Request.new(Core::INDICATORS + "/#{indicator_id}").content
81
+ end
82
+
83
+ # Gets indicator's dimension data
84
+ # @param [Integer] indicator_id
85
+ # @param [Hash] params
86
+
87
+ # level_id [String]
88
+ # territorial level of data
89
+ # 0 - EU total and countries level
90
+ # 2 - Voivodships Level
91
+ # 3 - Regions Level
92
+ # 4 - Subregions Level
93
+ # 5 - Powiats Level
94
+ # 6 - Gminas Level
95
+ # M - National Urban Policy
96
+ # O - Functional areas
97
+ # Z - Integrated Territorial Investments
98
+
99
+ # place_id [Integer]
100
+ # 1 - total
101
+ # 2 - urban
102
+ # 3 - rural
103
+
104
+ # section_id [Integer]
105
+ # id of age group: <1, 39> and <1001, 1003>; 1 means 'total'
106
+
107
+ # sex_id [Integer]
108
+ # 1 - total
109
+ # 2 - female
110
+ # 3 - male
111
+
112
+ def indicators_dimension_data(indicator_id, params = {})
113
+ Request.new(Core::INDICATORS + "/#{indicator_id}/dimensions", params).content
114
+ end
115
+
116
+ # Gets real data
117
+ # @param [Integer] dimension_id
118
+ # @param [Integer] indicator_id
119
+ # @param [Hash] params
120
+
121
+ # territory_code [String]
122
+ # level_id [String]
123
+
124
+ def real_data(dimension_id, indicator_id, params = {})
125
+ Request.new(Core::INDICATORS + "/#{indicator_id}/dimensions/#{dimension_id}", params).content
126
+ end
127
+
128
+ # Indicators metrics
129
+
130
+ # Gets indicator's metadata
131
+ # @param [Integer] indicator_id
132
+ def indicators_metadata(indicator_id)
133
+ Request.new(Core::INDICATORS_METRICS + "/#{indicator_id}").content
134
+ end
135
+
136
+ # Strategies and programmes coordinators
137
+
138
+ # Gets coordinators data
139
+ # @param [Integer] strategy_id
140
+ def coordinators_data(strategy_id)
141
+ Request.new(Core::STRATEGIES_AND_PROGRAMS_COORDINATORS + "/#{strategy_id}").content
142
+ end
143
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Core
4
+ STRATEG_BASE_URL = "https://strateg.stat.gov.pl/api"
5
+
6
+ STRATEGIES_AND_PROGRAMMES = "#{STRATEG_BASE_URL}/strategies-programmes"
7
+ COHESION_POLICY = "#{STRATEG_BASE_URL}/cohesion-policy"
8
+ STATISTICS_BY_THEME = "#{STRATEG_BASE_URL}/statistics-by-theme"
9
+ TERRITORIAL_DATA = "#{STRATEG_BASE_URL}/territorial-data"
10
+ INDICATORS = "#{STRATEG_BASE_URL}/indicators"
11
+ INDICATORS_METRICS = "#{STRATEG_BASE_URL}/metrics"
12
+ STRATEGIES_AND_PROGRAMS_COORDINATORS = "#{STRATEG_BASE_URL}/coordinators"
13
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "httparty"
4
+
5
+ # Request class for handling API requests
6
+ class Request
7
+ def initialize(url, params = {}, headers = {})
8
+ @url = url
9
+ @params = params
10
+ @headers = headers
11
+ @lang = "en"
12
+
13
+ @response = send_request(url, params, headers)
14
+ end
15
+
16
+ def content
17
+ @response.parsed_response
18
+ end
19
+
20
+ def content_type
21
+ @response.content_type
22
+ end
23
+
24
+ def status_code
25
+ @response.code
26
+ end
27
+
28
+ private
29
+
30
+ def params_to_string(params)
31
+ params.to_a.map { |k, v| "#{k}=#{v}" }.join("&")
32
+ end
33
+
34
+ def send_request(url, params, headers)
35
+ url += "?lang=#{@lang}"
36
+ "#{url}?#{params_to_string(params)}" if params
37
+ HTTParty.get(url, headers)
38
+ end
39
+ end
data/lib/strateg.rb ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "strateg/core"
4
+ require_relative "strateg/request"
5
+ require_relative "strateg/api"
data/strateg.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "strateg"
5
+ spec.version = "0.1.0"
6
+ spec.authors = ["Jakub Polak"]
7
+ spec.email = ["jakub.polak.vz@gmail.com"]
8
+
9
+ spec.summary = "Ruby gem for STRATEG API"
10
+ spec.description = "The STRATEG API allows to view and download for further processing the full range of data and metadata contained in the STRATEG system. The data is made available through REST API in JSON format."
11
+ spec.homepage = "https://github.com/kupolak/strateg"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = ">= 2.7.0"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/kupolak/strateg"
17
+ spec.metadata["changelog_uri"] = "https://github.com/kupolak/strateg/blob/main/CHANGELOG.md"
18
+
19
+ # Specify which files should be added to the gem when it is released.
20
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ # Uncomment to register a new dependency of your gem
29
+ # spec.add_dependency "example-gem", "~> 1.0"
30
+
31
+ # For more information and examples about making a new gem, checkout our
32
+ # guide at: https://bundler.io/guides/creating_gem.html
33
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strateg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jakub Polak
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-01-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The STRATEG API allows to view and download for further processing the
14
+ full range of data and metadata contained in the STRATEG system. The data is made
15
+ available through REST API in JSON format.
16
+ email:
17
+ - jakub.polak.vz@gmail.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - ".gitignore"
23
+ - ".rspec"
24
+ - ".rubocop.yml"
25
+ - CHANGELOG.md
26
+ - CODE_OF_CONDUCT.md
27
+ - Gemfile
28
+ - Gemfile.lock
29
+ - LICENSE.txt
30
+ - README.md
31
+ - Rakefile
32
+ - lib/strateg.rb
33
+ - lib/strateg/api.rb
34
+ - lib/strateg/core.rb
35
+ - lib/strateg/request.rb
36
+ - strateg.gemspec
37
+ homepage: https://github.com/kupolak/strateg
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ homepage_uri: https://github.com/kupolak/strateg
42
+ source_code_uri: https://github.com/kupolak/strateg
43
+ changelog_uri: https://github.com/kupolak/strateg/blob/main/CHANGELOG.md
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.7.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.2.17
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Ruby gem for STRATEG API
63
+ test_files: []