red-datasets 0.1.8 → 0.1.9

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: deff1c4d13294030c25c06691e272881eb049274decd9e2a958d0486c792ef26
4
- data.tar.gz: e48151e045fbf343291a5f5770409dea7672ff39c75bcc617152b52a39890f31
3
+ metadata.gz: 01ddaa57da3c64de47cfd9eb2ca9ae2ec3cbcb5d35138fdd74f74009f062358f
4
+ data.tar.gz: 431dba2c0e41bc25a4e2716ed20936ee2022c2b04c49683bb7d0d2e2aaa2f99e
5
5
  SHA512:
6
- metadata.gz: 7ae5a39a716bfa719f937c6ff139bd90ccf625e8a7ce72298507506f1a2c6a100e81c1273bf395a40d0ae8f1a13c1b1fb554e123e49dff718607a734ffd6c67b
7
- data.tar.gz: 72e664ba5f2a569a92d9d4237588f92f7398621642486e4c9e6c930bade4c17e4a68d30da14cb277fcd602025f959c42284462bf4370872f9826c9634ff78aca
6
+ metadata.gz: ab12e9783e4a23b81f9bd1be22c31704f9095026cb27185a6fe985e106320982fb999e1cf2348f6b18b509a7f1a6a5b58d405ece5d541e8ddbe43cd08f252a80
7
+ data.tar.gz: 157df5fffd3ba8fd021cdef3933c0a9e99a0fa7f173771e2177d1a86e79788c3250b12453f06084e24afcf624ec3283e702e6bd7595f08e2cf2b5a7dd404065c
data/doc/text/news.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # News
2
2
 
3
+ ## 0.1.9 - 2025-04-08
4
+
5
+ ### Improvements
6
+
7
+ * `Datasets::Penguins`: Changed to use `POST` for downloading data
8
+ from EDI.
9
+
3
10
  ## 0.1.8 - 2025-02-07
4
11
 
5
12
  ### Improvements
@@ -33,8 +33,8 @@ module Datasets
33
33
  @cache_path ||= CachePath.new(@metadata.id)
34
34
  end
35
35
 
36
- def download(output_path, url, *fallback_urls, &block)
37
- downloader = Downloader.new(url, *fallback_urls)
36
+ def download(output_path, url, *fallback_urls, **options, &block)
37
+ downloader = Downloader.new(url, *fallback_urls, **options)
38
38
  downloader.download(output_path, &block)
39
39
  end
40
40
 
@@ -12,9 +12,11 @@ module Datasets
12
12
  class Downloader
13
13
  class TooManyRedirects < Error; end
14
14
 
15
- def initialize(url, *fallback_urls)
15
+ def initialize(url, *fallback_urls, http_method: nil, http_parameters: nil)
16
16
  @url = normalize_url(url)
17
17
  @fallback_urls = fallback_urls.collect { |fallback_url| normalize_url(fallback_url) }
18
+ @http_method = http_method
19
+ @http_parameters = http_parameters
18
20
  end
19
21
 
20
22
  def download(output_path, &block)
@@ -151,7 +153,21 @@ module Datasets
151
153
  http.start do
152
154
  path = url.path
153
155
  path += "?#{url.query}" if url.query
154
- request = Net::HTTP::Get.new(path, headers)
156
+ if @http_method == :post
157
+ # TODO: We may want to add @http_content_type, @http_body
158
+ # and so on.
159
+ if @http_parameters
160
+ body = URI.encode_www_form(@http_parameters)
161
+ content_type = "application/x-www-form-urlencoded"
162
+ headers = {"Content-Type" => content_type}.merge(headers)
163
+ else
164
+ body = ""
165
+ end
166
+ request = Net::HTTP::Post.new(path, headers)
167
+ request.body = body
168
+ else
169
+ request = Net::HTTP::Get.new(path, headers)
170
+ end
155
171
  http.request(request) do |response|
156
172
  case response
157
173
  when Net::HTTPSuccess, Net::HTTPPartialContent
@@ -26,7 +26,9 @@ module Datasets
26
26
  super
27
27
  species = self.class.name.split("::").last.downcase
28
28
  @metadata.id = "palmerpenguins-#{species}"
29
- @metadata.url = self.class::URL
29
+ package_id = http_parameters["packageid"]
30
+ @metadata.url = "https://portal.edirepository.org/nis/mapbrowse" +
31
+ "?packageid=#{package_id}"
30
32
  @metadata.licenses = ["CC0-1.0"]
31
33
  @data_path = cache_dir_path + "#{species}.csv"
32
34
  end
@@ -46,7 +48,10 @@ module Datasets
46
48
  end
47
49
 
48
50
  private def open_data
49
- download(data_path, metadata.url)
51
+ download(data_path,
52
+ "https://portal.edirepository.org/nis/dataviewer",
53
+ http_method: :post,
54
+ http_parameters: http_parameters)
50
55
  CSV.open(data_path, headers: :first_row, converters: :all) do |csv|
51
56
  yield csv
52
57
  end
@@ -56,19 +61,37 @@ module Datasets
56
61
  # Adelie penguin data from: https://doi.org/10.6073/pasta/abc50eed9138b75f54eaada0841b9b86
57
62
  class Adelie < SpeciesBase
58
63
  DOI = "doi.org/10.6073/pasta/abc50eed9138b75f54eaada0841b9b86".freeze
59
- URL = "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.219.3&entityid=002f3893385f710df69eeebe893144ff".freeze
64
+
65
+ private def http_parameters
66
+ {
67
+ "packageid" => "knb-lter-pal.219.3",
68
+ "entityid" => "002f3893385f710df69eeebe893144ff",
69
+ }
70
+ end
60
71
  end
61
72
 
62
73
  # Chinstrap penguin data from: https://doi.org/10.6073/pasta/409c808f8fc9899d02401bdb04580af7
63
74
  class Chinstrap < SpeciesBase
64
75
  DOI = "doi.org/10.6073/pasta/409c808f8fc9899d02401bdb04580af7".freeze
65
- URL = "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.221.2&entityid=fe853aa8f7a59aa84cdd3197619ef462".freeze
76
+
77
+ private def http_parameters
78
+ {
79
+ "packageid" => "knb-lter-pal.221.2",
80
+ "entityid" => "fe853aa8f7a59aa84cdd3197619ef462",
81
+ }
82
+ end
66
83
  end
67
84
 
68
85
  # Gentoo penguin data from: https://doi.org/10.6073/pasta/2b1cff60f81640f182433d23e68541ce
69
86
  class Gentoo < SpeciesBase
70
87
  DOI = "doi.org/10.6073/pasta/2b1cff60f81640f182433d23e68541ce".freeze
71
- URL = "https://portal.edirepository.org/nis/dataviewer?packageid=knb-lter-pal.220.3&entityid=e03b43c924f226486f2f0ab6709d2381".freeze
88
+
89
+ private def http_parameters
90
+ {
91
+ "packageid" => "knb-lter-pal.220.3",
92
+ "entityid" => "e03b43c924f226486f2f0ab6709d2381",
93
+ }
94
+ end
72
95
  end
73
96
  end
74
97
 
@@ -1,3 +1,3 @@
1
1
  module Datasets
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -14,7 +14,7 @@ class CLDRPluralsTest < Test::Unit::TestCase
14
14
  test("#each") do
15
15
  locales = @dataset.each.to_a
16
16
  assert_equal([
17
- 222,
17
+ 220,
18
18
  locale("bm",
19
19
  [
20
20
  rule("other",
@@ -75,9 +75,9 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
75
75
  record(Date.parse("2024-01-26"),
76
76
  "自由民主党",
77
77
  "自民",
78
- Date.parse("2024-08-30"),
79
- 114,
80
- 23,
78
+ Date.parse("2024-05-25"),
79
+ 115,
80
+ 24,
81
81
  Date.parse("2025-07-28"),
82
82
  19,
83
83
  5,
@@ -88,14 +88,14 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
88
88
  Date.parse("2028-07-25"),
89
89
  18,
90
90
  5,
91
- 44,
92
- 7,
93
- 62,
94
- 12),
91
+ 45,
92
+ 8,
93
+ 63,
94
+ 13),
95
95
  record(Date.parse("2024-01-26"),
96
96
  "各派に属しない議員",
97
97
  "無所属",
98
- Date.parse("2024-08-30"),
98
+ Date.parse("2024-05-25"),
99
99
  12,
100
100
  4,
101
101
  Date.parse("2025-07-28"),
@@ -133,7 +133,7 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
133
133
  test("#each") do
134
134
  records = @dataset.each.to_a
135
135
  assert_equal([
136
- 245,
136
+ 247,
137
137
  record("足立 敏之",
138
138
  nil,
139
139
  "https://www.sangiin.go.jp/japanese/joho1/kousei/giin/profile/7016001.htm",
@@ -145,7 +145,7 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
145
145
  [2016, 2022],
146
146
  2,
147
147
  "財政金融委員会(長)",
148
- Date.parse("2024-08-30"),
148
+ Date.parse("2024-05-25"),
149
149
  "昭和29年5月20日兵庫県西宮市生まれ。(本籍地・京都府福知山市)昭和48年和歌山県立桐蔭高等学校卒業、昭和52年京都大学工学部土木工学科卒業、昭和54年京都大学大学院工学研究科修士課程修了、同年建設省入省後、兵庫県庁、東北及び関東地方整備局、河川局河川計画課河川事業調整官、内閣官房(安全保障・危機管理担当)等を経て、平成15年近畿地方整備局企画部長、平成18年河川局河川計画課長、平成21年四国地方整備局長、平成23年中部地方整備局長、平成24年水管理・国土保全局長、平成25年技監、平成26年国土交通省を退職。平成28年第24回参議院議員通常選挙で初当選○参議院予算委員会理事、災害対策特別委員会理事○著書「激甚化する水害」「いいね!建設産業本当の魅力」(日経BP社)",
150
150
  Date.parse("2022-11-30")),
151
151
  record("渡辺 猛之",
@@ -159,7 +159,7 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
159
159
  [2010, 2016, 2022],
160
160
  3,
161
161
  "経済産業委員会、議院運営委員会(理)",
162
- Date.parse("2024-08-30"),
162
+ Date.parse("2024-05-25"),
163
163
  "昭和43年4月18日生、岐阜県加茂郡八百津町出身。岐阜県立加茂高等学校、名古屋大学経済学部卒業。平成4年、財団法人松下政経塾入塾(第13期生)。平成7年、同塾卒業後、26歳で岐阜県議会議員に初当選。以後通算4期当選。在任中は、自民党岐阜県連副幹事長、岐阜県商工会青年部連合会会長、岐阜県商工政治連盟会長、県監査委員、県政自民クラブ幹事長を歴任。平成22年7月、参議院議員初当選○農林水産委員長、政治倫理の確立及び選挙制度に関する特別委員長、参議院自民党筆頭副幹事長、国土交通副大臣兼内閣府副大臣兼復興副大臣を歴任○現在議院運営委員会筆頭理事。環境委員",
164
164
  Date.parse("2022-11-30")),
165
165
  ],
@@ -183,7 +183,7 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
183
183
  test("#each") do
184
184
  records = @dataset.each.to_a
185
185
  assert_equal([
186
- 7833,
186
+ 7739,
187
187
  record(1,
188
188
  1,
189
189
  "食生活安定に関する質問主意書",
@@ -199,19 +199,19 @@ class HouseOfCouncillorTest < Test::Unit::TestCase
199
199
  Date.parse("1947-06-28"),
200
200
  nil),
201
201
  record(213,
202
- 239,
203
- "地方自治法第二百五十二条の二十六の五に定める各大臣の「生命等の保護の措置に関する指示」と地方自治の本旨等との関係に関する質問主意書",
204
- "小西 洋之",
202
+ 145,
203
+ "地方自治体職員の国籍に関する質問主意書",
204
+ "神谷 宗幣",
205
205
  1,
206
- "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/syuh/s213239.htm",
207
- "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/touh/t213239.htm",
208
- "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/syup/s213239.pdf",
209
- "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/toup/t213239.pdf",
210
- "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/meisai/m213239.htm",
211
- Date.parse("2024-06-21"),
212
- Date.parse("2024-06-21"),
213
- Date.parse("2024-07-02"),
214
- "6月25日内閣から通知書受領(7月2日まで答弁延期)"),
206
+ nil,
207
+ nil,
208
+ nil,
209
+ nil,
210
+ "https://www.sangiin.go.jp/japanese/joho1/kousei/syuisyo/213/meisai/m213145.htm",
211
+ Date.parse("2024-05-23"),
212
+ nil,
213
+ nil,
214
+ nil),
215
215
  ],
216
216
  [
217
217
  records.size,
@@ -48,7 +48,7 @@ class RdatasetTest < Test::Unit::TestCase
48
48
  test("without package_name") do
49
49
  records = @dataset.each.to_a
50
50
  assert_equal([
51
- 2337,
51
+ 2293,
52
52
  {
53
53
  package: "AER",
54
54
  dataset: "Affairs",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-datasets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomisuker
8
8
  - Kouhei Sutou
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-07 00:00:00.000000000 Z
11
+ date: 2025-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv