inat-channel 0.9.0 → 0.9.2.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: af5a4910d9c67e726bc96582469fb905101392ab37612bff1795e8165d31f53a
4
- data.tar.gz: ea75e7e0b0c406666ff502536e6cb9554db7a55ae778c7feec98964110c259a5
3
+ metadata.gz: 964ecc2ce62a014b72d67591c6f62a6b0ff5767adf4b1c04adadcc3c469e8a28
4
+ data.tar.gz: f97cded760837e12f0205bd12a2ffcbe5da90eecb229287ebdf2713aec7c658e
5
5
  SHA512:
6
- metadata.gz: d013cf9b14e8bf324ffa054b3f0a550fa8fe19259d619f227c82f7599e848ab983488c9749eb7a849ef4c75721a27378f00e74e90220bfeb5db8a6d99a345e9d
7
- data.tar.gz: f95460b1c54e594e82d638a9e4291024c0f53992a977330f16a6ca864e060b6c6bc52a890bc18fc3e1846c2dca9feaed75cffb3ef2ea4992b2e6f87709f14f2e
6
+ metadata.gz: f191492900162b0be24425d2d898b646e01362ea616a514f69643443a0d452d7e95df8d7b286d7281460b53850006662ebe8e80b9bbb6f86abbf3114a06ed8bf
7
+ data.tar.gz: 11af8f6c64a1916756ba3b5d27a3aa01b96be420b38788e13004e38bd6a9d80288a015a43e7759dc4b0fbcdb0feadf5ec5f79325157da96d7f9fe7c600bcd6fb
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  # inat-channel — automatic posting of observations
5
5
 
6
6
  [![GitHub License](https://img.shields.io/github/license/inat-get/inat-channel)](LICENSE)
7
- [![Gem Version](https://badge.fury.io/rb/inat-channel.svg?icon=si%3Arubygems&d=6)](https://badge.fury.io/rb/inat-channel)
7
+ [![Gem Version](https://badge.fury.io/rb/inat-channel.svg?icon=si%3Arubygems&d=9)](https://badge.fury.io/rb/inat-channel)
8
8
  [![Ruby](https://github.com/inat-get/inat-channel/actions/workflows/ruby.yml/badge.svg)](https://github.com/inat-get/inat-channel/actions/workflows/ruby.yml)
9
9
  ![Coverage](coverage-badge.svg)
10
10
 
data/bin/inat-channel CHANGED
@@ -13,9 +13,9 @@ if uuid
13
13
  obs = load_observation(uuid)
14
14
  if obs
15
15
  msg_id = send_observation(obs)
16
- IC::confirm_sending! msg_id
16
+ confirm_sending! msg_id
17
17
  else
18
- IC::revert_sending!
18
+ revert_sending!
19
19
  logger.warn "Failed to load #{uuid} — returning to pool"
20
20
  notify_admin "Failed to load #{uuid} — returning to pool"
21
21
  end
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'faraday'
4
4
  require 'faraday/retry'
5
5
 
6
+ require_relative 'facade'
6
7
  require_relative 'config'
7
8
  require_relative 'logger'
8
9
 
@@ -23,7 +24,7 @@ module INatChannel
23
24
  private_constant :PER_PAGE, :PAGE_DELAY, :API_ENDPOINT, :LIST_FIELDS, :SINGLE_FIELDS
24
25
 
25
26
  def load_news
26
- load_list(**IC::CONFIG[:base_query], created_d1: (Date.today - IC::CONFIG.dig(:days_back, :fresh)).to_s)
27
+ load_list(**IC::CONFIG[:base_query], updated_since: (Date.today - IC::CONFIG.dig(:days_back, :fresh)).to_s)
27
28
  end
28
29
 
29
30
  def load_list **query
@@ -114,19 +115,10 @@ end
114
115
 
115
116
  module IC
116
117
 
117
- def load_news
118
- INatChannel::API::load_news
119
- end
120
-
121
- def load_observation uuid
122
- INatChannel::API::load_observation uuid
123
- end
124
-
125
- def load_list **query
126
- INatChannel::API::load_list(**query)
127
- end
118
+ self >> INatChannel::API
128
119
 
129
- module_function :load_news, :load_observation
120
+ encapsulate INatChannel::API, :load_news, :load_observation
121
+ shadow_encapsulate INatChannel::API, :load_list
130
122
 
131
123
  end
132
124
 
@@ -2,6 +2,7 @@ require 'optparse'
2
2
  require 'yaml'
3
3
  require 'logger'
4
4
 
5
+ require_relative 'facade'
5
6
  require_relative 'version'
6
7
 
7
8
  module INatChannel
@@ -86,7 +87,7 @@ module INatChannel
86
87
  cfg[:data_files][:used] ||= "#{ cfg[:data_files][:root] }/#{ basename }_used.json"
87
88
 
88
89
  cfg[:lock_file] ||= {}
89
- cfg[:lock_file][:path] ||= "#{ cfg[:data_files][:root] }/#{ basename }__bot.json"
90
+ cfg[:lock_file][:path] ||= "#{ cfg[:data_files][:root] }/#{ basename }__bot.lock"
90
91
  cfg[:lock_file][:ttl] ||= 300 # 5 min
91
92
 
92
93
  cfg[:days_back][:pool] ||= 3 * cfg.dig(:days_back, :fresh)
@@ -121,13 +122,16 @@ module INatChannel
121
122
 
122
123
  end
123
124
 
125
+ CONFIG = self.config
126
+
124
127
  end
125
128
 
126
129
  end
127
130
 
128
131
  module IC
129
132
 
130
- CONFIG = INatChannel::Config::config
133
+ self >> INatChannel::Config
131
134
 
132
- end
135
+ encapsulate INatChannel::Config, :CONFIG
133
136
 
137
+ end
@@ -4,6 +4,7 @@ require 'json'
4
4
  require 'fileutils'
5
5
  require 'set'
6
6
 
7
+ require_relative 'facade'
7
8
  require_relative 'config'
8
9
  require_relative 'logger'
9
10
  require_relative 'lock'
@@ -304,22 +305,8 @@ end
304
305
 
305
306
  module IC
306
307
 
307
- def select_uuid fresh
308
- INatChannel::Storage::select_uuid fresh
309
- end
310
-
311
- def save_data
312
- INatChannel::Storage::save
313
- end
314
-
315
- def confirm_sending! msg_id
316
- INatChannel::Storage::confirm! msg_id
317
- end
318
-
319
- def revert_sending!
320
- INatChannel::Storage::revert!
321
- end
308
+ self >> INatChannel::Storage
322
309
 
323
- module_function :select_uuid, :save_data, :confirm_sending!, :revert_sending!
310
+ encapsulate INatChannel::Storage, :select_uuid, :save => :save_data, :confirm! => :confirm_sending!, :revert! => :revert_sending!
324
311
 
325
312
  end
@@ -2,6 +2,7 @@ require 'date'
2
2
  require 'time'
3
3
  require 'set'
4
4
 
5
+ require_relative 'facade'
5
6
  require_relative 'data_types'
6
7
 
7
8
  module INatChannel
@@ -99,10 +100,8 @@ end
99
100
 
100
101
  module IC
101
102
 
102
- def convert_observation source
103
- INatChannel::DataConvert::convert_observation source
104
- end
103
+ self >> INatChannel::DataConvert
105
104
 
106
- module_function :convert_observation
105
+ shadow_encapsulate INatChannel::DataConvert, :convert_observation
107
106
 
108
107
  end
@@ -0,0 +1,5 @@
1
+ require 'is-dsl'
2
+
3
+ module IC
4
+ extend IS::DSL
5
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'facade'
2
+
1
3
  module INatChannel
2
4
  module Icons
3
5
  TAXA_ICONS = {
@@ -115,21 +117,8 @@ end
115
117
 
116
118
  module IC
117
119
 
118
- TAXA_ICONS = INatChannel::Icons::TAXA_ICONS
119
- ICONS = INatChannel::Icons::ICONS
120
-
121
- def taxon_icon taxon
122
- INatChannel::Icons::taxon_icon taxon
123
- end
124
-
125
- def ancestors_icon ancestor_ids
126
- INatChannel::Icons::ancestors_icon ancestor_ids
127
- end
128
-
129
- def clock_icon time
130
- INatChannel::Icons::clock_icon time
131
- end
120
+ self >> INatChannel::Icons
132
121
 
133
- module_function :taxon_icon, :ancestors_icon, :clock_icon
122
+ shadow_encapsulate INatChannel::Icons, :ICONS, :TAXA_ICONS, :taxon_icon, :ancestors_icon, :clock_icon
134
123
 
135
124
  end
@@ -1,3 +1,4 @@
1
+ require_relative 'facade'
1
2
  require_relative 'config'
2
3
 
3
4
  module INatChannel
@@ -26,11 +27,9 @@ end
26
27
 
27
28
  module IC
28
29
 
29
- def logger
30
- INatChannel::Logger::logger
31
- end
30
+ self >> INatChannel::Logger
32
31
 
33
- module_function :logger
32
+ encapsulate INatChannel::Logger, :logger
34
33
 
35
34
  end
36
35
 
@@ -1,6 +1,7 @@
1
1
  require 'set'
2
2
  require 'sanitize'
3
3
 
4
+ require_relative 'facade'
4
5
  require_relative 'config'
5
6
  require_relative 'icons'
6
7
  require_relative 'template'
@@ -33,15 +34,9 @@ end
33
34
 
34
35
  module IC
35
36
 
36
- def make_message observation
37
- INatChannel::Message::make_message observation
38
- end
39
-
40
- def list_photos observation
41
- INatChannel::Message::list_photos observation
42
- end
37
+ self >> INatChannel::Message
43
38
 
44
- module_function :make_message, :list_photos
39
+ shadow_encapsulate INatChannel::Message, :make_message, :list_photos
45
40
 
46
41
  end
47
42
 
@@ -1,3 +1,4 @@
1
+ require_relative 'facade'
1
2
  require_relative 'config'
2
3
  require_relative 'logger'
3
4
  require_relative 'message'
@@ -93,15 +94,8 @@ end
93
94
 
94
95
  module IC
95
96
 
96
- def send_observation observation
97
- INatChannel::Telegram::send_observation observation
98
- end
99
-
100
- def notify_admin text
101
- INatChannel::Telegram::notify_admin text
102
- end
97
+ self >> INatChannel::Telegram
103
98
 
104
- module_function :send_observation, :notify_admin
99
+ encapsulate INatChannel::Telegram, :send_observation, :notify_admin
105
100
 
106
101
  end
107
-
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
  require 'erb'
3
3
 
4
+ require_relative 'facade'
4
5
  require_relative 'data_types'
5
6
  require_relative 'data_convert'
6
7
 
@@ -95,12 +96,8 @@ end
95
96
 
96
97
  module IC
97
98
 
98
- def load_template path
99
- INatChannel::Template::load path
100
- end
99
+ self >> INatChannel::Template
101
100
 
102
- def default_template
103
- INatChannel::Template::default
104
- end
101
+ shadow_encapsulate INatChannel::Template, :load => :load_template, :default => :default_template
105
102
 
106
103
  end
@@ -1,11 +1,11 @@
1
1
  module INatChannel
2
2
 
3
- VERSION = '0.9.0'
3
+ VERSION = '0.9.2.2'
4
4
 
5
5
  end
6
6
 
7
7
  module IC
8
-
8
+
9
9
  VERSION = INatChannel::VERSION
10
10
 
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inat-channel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Shikhalev
@@ -51,6 +51,20 @@ dependencies:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '7.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: is-dsl
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.8'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.8'
54
68
  - !ruby/object:Gem::Dependency
55
69
  name: rspec
56
70
  requirement: !ruby/object:Gem::Requirement
@@ -125,6 +139,7 @@ files:
125
139
  - lib/inat-channel/data.rb
126
140
  - lib/inat-channel/data_convert.rb
127
141
  - lib/inat-channel/data_types.rb
142
+ - lib/inat-channel/facade.rb
128
143
  - lib/inat-channel/icons.rb
129
144
  - lib/inat-channel/lock.rb
130
145
  - lib/inat-channel/logger.rb