equilibrium 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.
@@ -4,10 +4,6 @@ module Equilibrium
4
4
  class TagSorter
5
5
  # Sort tags in descending version order: latest first, then major versions (descending), then minor versions (descending)
6
6
  def self.sort_descending(tags_hash)
7
- new.sort_descending(tags_hash)
8
- end
9
-
10
- def sort_descending(tags_hash)
11
7
  return {} if tags_hash.nil? || tags_hash.empty?
12
8
 
13
9
  sorted = {}
@@ -20,10 +16,10 @@ module Equilibrium
20
16
  # Sort other tags by version (descending)
21
17
  other_tags = tags_hash.keys.reject { |k| k == "latest" }
22
18
  sorted_tags = other_tags.sort_by do |tag|
23
- if major_version?(tag)
19
+ if tag.match?(/^[0-9]+$/)
24
20
  # Major version: sort by numeric value (descending)
25
21
  [-tag.to_i]
26
- elsif minor_version?(tag)
22
+ elsif tag.match?(/^[0-9]+\.[0-9]+$/)
27
23
  # Minor version: sort by version (descending)
28
24
  parts = tag.split(".").map(&:to_i)
29
25
  [-parts[0], -parts[1]]
@@ -39,15 +35,5 @@ module Equilibrium
39
35
 
40
36
  sorted
41
37
  end
42
-
43
- private
44
-
45
- def major_version?(tag)
46
- tag.match?(/^[0-9]+$/)
47
- end
48
-
49
- def minor_version?(tag)
50
- tag.match?(/^[0-9]+\.[0-9]+$/)
51
- end
52
38
  end
53
39
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "repository_tags_service"
4
+ require_relative "tag_data_builder"
5
+
6
+ module Equilibrium
7
+ class TagsOperationService
8
+ def self.generate_expected_output(repository_url)
9
+ tag_data = RepositoryTagsService.generate_expected_tags(repository_url)
10
+ repository_name = repository_url.split("/").last
11
+
12
+ TagDataBuilder.build_output(
13
+ repository_url,
14
+ repository_name,
15
+ tag_data["digests"],
16
+ tag_data["canonical_versions"]
17
+ )
18
+ end
19
+
20
+ def self.generate_actual_output(repository_url)
21
+ tag_data = RepositoryTagsService.generate_actual_tags(repository_url)
22
+ repository_name = repository_url.split("/").last
23
+
24
+ TagDataBuilder.build_output(
25
+ repository_url,
26
+ repository_name,
27
+ tag_data["digests"],
28
+ tag_data["canonical_versions"]
29
+ )
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Equilibrium
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/equilibrium.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "equilibrium/version"
4
- require_relative "equilibrium/semantic_version"
5
4
  require_relative "equilibrium/registry_client"
6
5
  require_relative "equilibrium/tag_processor"
7
6
  require_relative "equilibrium/tag_sorter"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equilibrium
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
  - Tony Hsu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-06 00:00:00.000000000 Z
11
+ date: 2025-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -71,18 +71,30 @@ files:
71
71
  - exe/equilibrium
72
72
  - lib/equilibrium.rb
73
73
  - lib/equilibrium/analyzer.rb
74
+ - lib/equilibrium/canonical_version_mapper.rb
74
75
  - lib/equilibrium/catalog_builder.rb
75
76
  - lib/equilibrium/cli.rb
77
+ - lib/equilibrium/commands/actual_command.rb
78
+ - lib/equilibrium/commands/analyze_command.rb
79
+ - lib/equilibrium/commands/catalog_command.rb
80
+ - lib/equilibrium/commands/expected_command.rb
81
+ - lib/equilibrium/commands/uncatalog_command.rb
82
+ - lib/equilibrium/commands/version_command.rb
83
+ - lib/equilibrium/mixins/error_handling.rb
84
+ - lib/equilibrium/mixins/input_output.rb
76
85
  - lib/equilibrium/registry_client.rb
86
+ - lib/equilibrium/repository_tags_service.rb
87
+ - lib/equilibrium/repository_url_validator.rb
77
88
  - lib/equilibrium/schema_validator.rb
78
89
  - lib/equilibrium/schemas/analyzer_output.rb
79
90
  - lib/equilibrium/schemas/catalog.rb
80
91
  - lib/equilibrium/schemas/expected_actual.rb
81
92
  - lib/equilibrium/schemas/registry_api.rb
82
- - lib/equilibrium/semantic_version.rb
83
93
  - lib/equilibrium/summary_formatter.rb
94
+ - lib/equilibrium/tag_data_builder.rb
84
95
  - lib/equilibrium/tag_processor.rb
85
96
  - lib/equilibrium/tag_sorter.rb
97
+ - lib/equilibrium/tags_operation_service.rb
86
98
  - lib/equilibrium/version.rb
87
99
  - tmp/.gitkeep
88
100
  homepage: https://github.com/TonyCTHsu/equilibrium
@@ -91,8 +103,8 @@ licenses:
91
103
  metadata:
92
104
  homepage_uri: https://github.com/TonyCTHsu/equilibrium
93
105
  source_code_uri: https://github.com/TonyCTHsu/equilibrium
94
- changelog_uri: https://github.com/TonyCTHsu/equilibrium/blob/master/CHANGELOG.md
95
- github_repo: ssh://github.com/TonyCTHsu/tobee
106
+ changelog_uri: https://github.com/TonyCTHsu/equilibrium/blob/v0.2.0/CHANGELOG.md
107
+ github_repo: ssh://github.com/TonyCTHsu/equilibrium
96
108
  post_install_message:
97
109
  rdoc_options: []
98
110
  require_paths:
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Equilibrium
4
- module SemanticVersion
5
- # Strictly validate MAJOR.MINOR.PATCH format where:
6
- # - MAJOR, MINOR, PATCH are non-negative integers
7
- # - No leading zeros (except for '0' itself)
8
- # - No prefixes (like 'v1.2.3', 'release-1.2.3')
9
- # - No suffixes (like '1.2.3-alpha', '1.2.3+build')
10
- # - No prereleases (like '1.2.3-rc.1', '1.2.3-beta.2')
11
- def self.valid?(tag)
12
- # Strict regex: each component must be either '0' or a number without leading zeros
13
- return false unless tag.match?(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/)
14
-
15
- # Additional validation: ensure it's a valid Gem::Version
16
- begin
17
- Gem::Version.new(tag)
18
- true
19
- rescue ArgumentError
20
- false
21
- end
22
- end
23
- end
24
- end