decoupage_administratif 0.1.1 → 0.2.0

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: a3e2eef5985080f08a15b607dfbf34639566930a7ede002f3b8c1c216874116e
4
- data.tar.gz: 6d439459098e99748141ec94404670b24c6e93e87eafa1bbcbd571933102fea4
3
+ metadata.gz: 15d8baade56f4081ec11036e1a10269d9a561eaca357835a9d6f81ae798749ec
4
+ data.tar.gz: dc037fd227031b91ed1f9c44035ac1ea5c58b0322ca40f7f81cff54b9327017a
5
5
  SHA512:
6
- metadata.gz: e9409c585489bd09b725dd954df508636f56c3531ccda99fcab273893dd71b067c22fda01e79c06acf0a8f5056c8dee7ab750e8f346f34a0fd2c3dafc53d8807
7
- data.tar.gz: 2452645b05e3dc51333d55e7a2e5350eadd61858231b8ebfb9d3261bad8f1e8890f71f218c2a22eb555b328f4be1ed0817da854d061db8e786006397b13120ca
6
+ metadata.gz: 6203a3495a45bbcde0201432929485e5d6aa5b8270a8afed54936712561b8c890dbea27c6a9763781e7fa1a40a8a0fef6863dbd368371313d024a4e0584850f1
7
+ data.tar.gz: b549a507147fba9e578d1104d521c4f2bea2e3a9d1cf9ab97406d81073b7c2fdf5f1428fa8acc23fa18ad5784bd17099c4a0218f6e39000aed503afe85d05073
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2025-08-29
4
+
5
+ ### Changed
6
+ - **Breaking**: Renamed `territory_intersects_with_insee_codes?` method to `includes_any_commune_code?` for better clarity and consistency with Ruby conventions
7
+ - Method now has a more intuitive name that clearly indicates it checks if a territory includes any of the specified commune codes
8
+
3
9
  ## [0.1.1] - 2025-08-29
4
10
 
5
11
  ### Fixed
@@ -24,7 +30,7 @@
24
30
  - Search territories by INSEE codes
25
31
  - Find complete territories (departments, regions, EPCIs) from commune codes
26
32
  - Support for partial matching and case-insensitive searches
27
- - Territory intersection methods:
33
+ - Territory inclusion methods:
28
34
  - `territory_intersects_with_insee_codes?`: Check if territory contains any of the given INSEE codes
29
35
  - `territory_insee_codes`: Get all INSEE codes for a territory
30
36
  - Flexible data configuration:
data/README.md CHANGED
@@ -97,7 +97,7 @@ La gem propose des méthodes pour vérifier la correspondance entre territoires
97
97
  # Vérifier si un territoire contient au moins une commune d'une liste
98
98
  commune_codes = ['75001', '75002', '69001']
99
99
  departement = DecoupageAdministratif::Departement.find('75')
100
- departement.territory_intersects_with_insee_codes?(commune_codes) # => true
100
+ departement.includes_any_commune_code?(commune_codes) # => true
101
101
 
102
102
  # Obtenir tous les codes INSEE des communes d'un territoire
103
103
  departement.territory_insee_codes # => ["75001", "75002", "75003", ...]
@@ -252,13 +252,13 @@ puts region.departements
252
252
 
253
253
  ### Territory extensions
254
254
 
255
- The gem provides methods to check intersections between territories and INSEE code lists:
255
+ The gem provides methods to check if territories include specific commune codes:
256
256
 
257
257
  ```ruby
258
- # Check if a territory intersects with municipality INSEE codes
258
+ # Check if a territory includes any of the specified municipality codes
259
259
  commune_codes = ['75001', '75002', '69001']
260
260
  departement = DecoupageAdministratif::Departement.find('75')
261
- departement.territory_intersects_with_insee_codes?(commune_codes) # => true
261
+ departement.includes_any_commune_code?(commune_codes) # => true
262
262
 
263
263
  # Get all INSEE codes of municipalities in a territory
264
264
  departement.territory_insee_codes # => ["75001", "75002", "75003", ...]
@@ -2,11 +2,11 @@
2
2
 
3
3
  module DecoupageAdministratif
4
4
  module TerritoryExtensions
5
- # Check if this territory intersects with a list of commune INSEE codes
5
+ # Check if this territory includes any of the specified commune codes
6
6
  # @param commune_insee_codes [Array<String>] array of commune INSEE codes to check against
7
- # @return [Boolean] true if territory intersects with any of the provided codes
8
- def territory_intersects_with_insee_codes?(commune_insee_codes)
9
- territory_strategy.intersects_with_insee_codes?(commune_insee_codes)
7
+ # @return [Boolean] true if territory includes any of the provided commune codes
8
+ def includes_any_commune_code?(commune_insee_codes)
9
+ territory_strategy.includes_any_commune_code?(commune_insee_codes)
10
10
  end
11
11
 
12
12
  # Get commune INSEE codes for this territory
@@ -7,10 +7,10 @@ module DecoupageAdministratif
7
7
  @territory = territory
8
8
  end
9
9
 
10
- def intersects_with_insee_codes?(commune_insee_codes)
10
+ def includes_any_commune_code?(commune_insee_codes)
11
11
  return false if commune_insee_codes.empty?
12
12
 
13
- perform_intersection(commune_insee_codes)
13
+ check_inclusion(commune_insee_codes)
14
14
  end
15
15
 
16
16
  def insee_codes
@@ -21,7 +21,7 @@ module DecoupageAdministratif
21
21
 
22
22
  attr_reader :territory
23
23
 
24
- def perform_intersection(commune_insee_codes)
24
+ def check_inclusion(commune_insee_codes)
25
25
  raise NotImplementedError, "Must be implemented by subclass"
26
26
  end
27
27
 
@@ -33,7 +33,7 @@ module DecoupageAdministratif
33
33
  class CommuneStrategy < Base
34
34
  private
35
35
 
36
- def perform_intersection(commune_insee_codes)
36
+ def check_inclusion(commune_insee_codes)
37
37
  commune_insee_codes.include?(territory.code)
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ module DecoupageAdministratif
45
45
  class DepartementStrategy < Base
46
46
  private
47
47
 
48
- def perform_intersection(commune_insee_codes)
48
+ def check_inclusion(commune_insee_codes)
49
49
  departement_prefix = territory.code.length == 2 ? territory.code : territory.code[0..1]
50
50
  commune_insee_codes.any? { |commune_code| commune_code.start_with?(departement_prefix) }
51
51
  end
@@ -58,7 +58,7 @@ module DecoupageAdministratif
58
58
  class RegionStrategy < Base
59
59
  private
60
60
 
61
- def perform_intersection(commune_insee_codes)
61
+ def check_inclusion(commune_insee_codes)
62
62
  departement_codes = territory.departements.map(&:code)
63
63
  commune_insee_codes.any? do |commune_code|
64
64
  dept_code = commune_code.length >= 3 && commune_code[0..1].to_i >= 96 ? commune_code[0..2] : commune_code[0..1]
@@ -74,7 +74,7 @@ module DecoupageAdministratif
74
74
  class EpciStrategy < Base
75
75
  private
76
76
 
77
- def perform_intersection(commune_insee_codes)
77
+ def check_inclusion(commune_insee_codes)
78
78
  epci_commune_codes = territory.membres.map { |membre| membre[:code] || membre["code"] }
79
79
  (epci_commune_codes & commune_insee_codes).any?
80
80
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DecoupageAdministratif
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  DATA_VERSION = "5.2.0"
6
6
  DATA_SOURCE = "@etalab/decoupage-administratif"
7
7
  end
@@ -1,6 +1,6 @@
1
1
  module DecoupageAdministratif
2
2
  module TerritoryExtensions
3
- def territory_intersects_with_insee_codes?: (Array[String] commune_insee_codes) -> bool
3
+ def includes_any_commune_code?: (Array[String] commune_insee_codes) -> bool
4
4
 
5
5
  def territory_insee_codes: () -> Array[String]
6
6
 
@@ -3,7 +3,7 @@ module DecoupageAdministratif
3
3
  class Base
4
4
  def initialize: (untyped territory) -> void
5
5
 
6
- def intersects_with_insee_codes?: (Array[String] commune_insee_codes) -> bool
6
+ def includes_any_commune_code?: (Array[String] commune_insee_codes) -> bool
7
7
 
8
8
  def insee_codes: () -> Array[String]
9
9
 
@@ -11,7 +11,7 @@ module DecoupageAdministratif
11
11
 
12
12
  attr_reader territory: untyped
13
13
 
14
- def perform_intersection: (Array[String] commune_insee_codes) -> bool
14
+ def check_inclusion: (Array[String] commune_insee_codes) -> bool
15
15
 
16
16
  def calculate_insee_codes: () -> Array[String]
17
17
  end
@@ -19,7 +19,7 @@ module DecoupageAdministratif
19
19
  class CommuneStrategy < Base
20
20
  private
21
21
 
22
- def perform_intersection: (Array[String] commune_insee_codes) -> bool
22
+ def check_inclusion: (Array[String] commune_insee_codes) -> bool
23
23
 
24
24
  def calculate_insee_codes: () -> Array[String]
25
25
  end
@@ -27,7 +27,7 @@ module DecoupageAdministratif
27
27
  class DepartementStrategy < Base
28
28
  private
29
29
 
30
- def perform_intersection: (Array[String] commune_insee_codes) -> bool
30
+ def check_inclusion: (Array[String] commune_insee_codes) -> bool
31
31
 
32
32
  def calculate_insee_codes: () -> Array[String]
33
33
  end
@@ -35,7 +35,7 @@ module DecoupageAdministratif
35
35
  class RegionStrategy < Base
36
36
  private
37
37
 
38
- def perform_intersection: (Array[String] commune_insee_codes) -> bool
38
+ def check_inclusion: (Array[String] commune_insee_codes) -> bool
39
39
 
40
40
  def calculate_insee_codes: () -> Array[String]
41
41
  end
@@ -43,7 +43,7 @@ module DecoupageAdministratif
43
43
  class EpciStrategy < Base
44
44
  private
45
45
 
46
- def perform_intersection: (Array[String] commune_insee_codes) -> bool
46
+ def check_inclusion: (Array[String] commune_insee_codes) -> bool
47
47
 
48
48
  def calculate_insee_codes: () -> Array[String]
49
49
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decoupage_administratif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucien Mollard