decoupage_administratif 0.1.0 → 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 +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +6 -4
- data/lib/decoupage_administratif/territory_extensions.rb +4 -4
- data/lib/decoupage_administratif/territory_strategies.rb +7 -7
- data/lib/decoupage_administratif/version.rb +1 -1
- data/sig/decoupage_administratif/territory_extensions.rbs +1 -1
- data/sig/decoupage_administratif/territory_strategies.rbs +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15d8baade56f4081ec11036e1a10269d9a561eaca357835a9d6f81ae798749ec
|
4
|
+
data.tar.gz: dc037fd227031b91ed1f9c44035ac1ea5c58b0322ca40f7f81cff54b9327017a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6203a3495a45bbcde0201432929485e5d6aa5b8270a8afed54936712561b8c890dbea27c6a9763781e7fa1a40a8a0fef6863dbd368371313d024a4e0584850f1
|
7
|
+
data.tar.gz: b549a507147fba9e578d1104d521c4f2bea2e3a9d1cf9ab97406d81073b7c2fdf5f1428fa8acc23fa18ad5784bd17099c4a0218f6e39000aed503afe85d05073
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
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
|
+
|
9
|
+
## [0.1.1] - 2025-08-29
|
10
|
+
|
11
|
+
### Fixed
|
12
|
+
- Include territory_extensions.rb and territory_strategies.rb files in the gem package
|
13
|
+
- Fix NoMethodError for `territory_intersects_with_insee_codes?` method in production environments
|
14
|
+
|
3
15
|
## [0.1.0] - 2025-08-26
|
4
16
|
|
5
17
|
### Added
|
@@ -18,7 +30,7 @@
|
|
18
30
|
- Search territories by INSEE codes
|
19
31
|
- Find complete territories (departments, regions, EPCIs) from commune codes
|
20
32
|
- Support for partial matching and case-insensitive searches
|
21
|
-
- Territory
|
33
|
+
- Territory inclusion methods:
|
22
34
|
- `territory_intersects_with_insee_codes?`: Check if territory contains any of the given INSEE codes
|
23
35
|
- `territory_insee_codes`: Get all INSEE codes for a territory
|
24
36
|
- Flexible data configuration:
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://badge.fury.io/rb/decoupage_administratif)
|
2
|
+
|
1
3
|
# DecoupageAdministratif
|
2
4
|
English version below
|
3
5
|
|
@@ -95,7 +97,7 @@ La gem propose des méthodes pour vérifier la correspondance entre territoires
|
|
95
97
|
# Vérifier si un territoire contient au moins une commune d'une liste
|
96
98
|
commune_codes = ['75001', '75002', '69001']
|
97
99
|
departement = DecoupageAdministratif::Departement.find('75')
|
98
|
-
departement.
|
100
|
+
departement.includes_any_commune_code?(commune_codes) # => true
|
99
101
|
|
100
102
|
# Obtenir tous les codes INSEE des communes d'un territoire
|
101
103
|
departement.territory_insee_codes # => ["75001", "75002", "75003", ...]
|
@@ -250,13 +252,13 @@ puts region.departements
|
|
250
252
|
|
251
253
|
### Territory extensions
|
252
254
|
|
253
|
-
The gem provides methods to check
|
255
|
+
The gem provides methods to check if territories include specific commune codes:
|
254
256
|
|
255
257
|
```ruby
|
256
|
-
# Check if a territory
|
258
|
+
# Check if a territory includes any of the specified municipality codes
|
257
259
|
commune_codes = ['75001', '75002', '69001']
|
258
260
|
departement = DecoupageAdministratif::Departement.find('75')
|
259
|
-
departement.
|
261
|
+
departement.includes_any_commune_code?(commune_codes) # => true
|
260
262
|
|
261
263
|
# Get all INSEE codes of municipalities in a territory
|
262
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
|
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
|
8
|
-
def
|
9
|
-
territory_strategy.
|
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
|
10
|
+
def includes_any_commune_code?(commune_insee_codes)
|
11
11
|
return false if commune_insee_codes.empty?
|
12
12
|
|
13
|
-
|
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
|
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
|
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
|
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
|
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
|
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,6 +1,6 @@
|
|
1
1
|
module DecoupageAdministratif
|
2
2
|
module TerritoryExtensions
|
3
|
-
def
|
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
|
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
|
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
|
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
|
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
|
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
|
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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decoupage_administratif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucien Mollard
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-08-
|
11
|
+
date: 2025-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|