fixversion 0.0.1 → 0.0.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: 33771156c04d0c86112fddeb97e8775ec5fa4f6e9d045c54b94a742cced86f9b
4
- data.tar.gz: 7ed7307479c1f7a7fc6d6a8583497909d998c00dba1c9d1f6eda11c7478c8136
3
+ metadata.gz: 3a9c814c07ea075320a06cd3330a1e6bdbe5eed8554dc8f3334c3bdc3c9ac14f
4
+ data.tar.gz: 96672443da041d2228634abf6e63dead6d976230996c209099728270d737574c
5
5
  SHA512:
6
- metadata.gz: eaa1f505dddd91bfdcbaf05e507b9aa7a45d8ed7df6fb5909fc0119e4b0aa6bc9eb3b5ea4ae9679a7ab99fdc2fb32c9271661e61038e3c74692422c9dc8d9f80
7
- data.tar.gz: 3fd4ddf9880657b47e17f009b59f9377fbdfaff33f4b7bd0046d3775ef2ba0e349789e07e2b4a394f451f6c9489da74430d438c2abe8eb063438d4c05d1d0c58
6
+ metadata.gz: b5cdf694e6544974234100437ee2b8ef0fbfacca5eada615fe651014de63d5e246792e5db32543e3071555be4d23373745990c182b1748d0548df7d8a5d3cdd5
7
+ data.tar.gz: d4eb2415eb31492a36a85438bdc3ce8ee6e6000065e2b2e62ad611d695725906caa83f25babf6f53cce419ebfbc152d9ab8e0cb2ea8892b1f11da1bafb1ff13d
checksums.yaml.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -16,11 +16,34 @@ toc::[]
16
16
 
17
17
  == Setup
18
18
 
19
- To set up the project, run:
19
+ To install _with_ security, run:
20
20
 
21
21
  [source,bash]
22
22
  ----
23
- bin/setup
23
+ # 💡 Skip this line if you already have the public certificate installed.
24
+ gem cert --add <(curl --compressed --location /gems.pem)
25
+ gem install fixversion --trust-policy HighSecurity
26
+ ----
27
+
28
+ To install _without_ security, run:
29
+
30
+ [source,bash]
31
+ ----
32
+ gem install fixversion
33
+ ----
34
+
35
+ You can also add the gem directly to your project:
36
+
37
+ [source,bash]
38
+ ----
39
+ bundle add fixversion
40
+ ----
41
+
42
+ Once the gem is installed, you only need to require it:
43
+
44
+ [source,ruby]
45
+ ----
46
+ require "fixversion"
24
47
  ----
25
48
 
26
49
  == Usage
@@ -49,7 +72,7 @@ To test, run:
49
72
 
50
73
  [source,bash]
51
74
  ----
52
- bundle exec rake
75
+ bin/rake
53
76
  ----
54
77
 
55
78
  == link:[License]
@@ -64,5 +87,5 @@ bundle exec rake
64
87
 
65
88
  == Credits
66
89
 
67
- * Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
90
+ * Built with link:https://alchemists.io/projects/gemsmith[Gemsmith].
68
91
  * Engineered by link:[Chris Aga].
data/exe/fixversion CHANGED
@@ -3,4 +3,4 @@
3
3
 
4
4
  require "fixversion"
5
5
 
6
- Fixversion::CLI::Shell.new.call ARGV
6
+ Fixversion::CLI::Shell.new.call
data/fixversion.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "fixversion"
5
- spec.version = "0.0.1"
5
+ spec.version = "0.0.2"
6
6
  spec.authors = ["Chris Aga"]
7
7
  spec.email = ["chrisaga.dev@gmail.com"]
8
8
  spec.homepage = ""
@@ -14,12 +14,16 @@ Gem::Specification.new do |spec|
14
14
  spec.signing_key = Gem.default_key_path
15
15
  spec.cert_chain = [Gem.default_cert_path]
16
16
 
17
- spec.required_ruby_version = "~> 3.1"
17
+ spec.required_ruby_version = "~> 3.2"
18
+ spec.add_dependency "cogger", "~> 0.12"
18
19
  spec.add_dependency "dry-container", "~> 0.11"
19
- spec.add_dependency "infusible", "~> 0.2"
20
- spec.add_dependency "refinements", "~> 9.7"
21
- spec.add_dependency "runcom", "~> 8.7"
22
- spec.add_dependency "spek", "~> 0.6"
20
+ spec.add_dependency "dry-monads", "~> 1.6"
21
+ spec.add_dependency "etcher", "~> 0.2"
22
+ spec.add_dependency "infusible", "~> 2.2"
23
+ spec.add_dependency "refinements", "~> 11.0"
24
+ spec.add_dependency "runcom", "~> 10.0"
25
+ spec.add_dependency "sod", "~> 0.0"
26
+ spec.add_dependency "spek", "~> 2.0"
23
27
  spec.add_dependency "zeitwerk", "~> 2.6"
24
28
 
25
29
  spec.bindir = "exe"
@@ -0,0 +1,92 @@
1
+ require 'active_support/all'
2
+
3
+ module Fixversion
4
+ class Base
5
+
6
+ CUTOFFS = {
7
+ 'wednesday': {
8
+ cutoff: '11:00 am MST',
9
+ release: 'thursday'
10
+ },
11
+ 'friday': {
12
+ cutoff: '11:00 am MST',
13
+ release: 'tuesday'
14
+ }
15
+ }.with_indifferent_access
16
+
17
+ attr_accessor :date
18
+
19
+ def initialize(date)
20
+ @date = date
21
+ end
22
+
23
+ def cutoff_days
24
+ CUTOFFS.keys
25
+ end
26
+
27
+ def day_of_week
28
+ date.strftime("%A").downcase
29
+ end
30
+
31
+ def cutoff_day?
32
+ CUTOFFS.keys.include?(day_of_week)
33
+ end
34
+
35
+ def fix_version
36
+ next_release_day.strftime('%Y.%m.%d')
37
+ end
38
+
39
+ def cutoff_index
40
+ CUTOFFS.keys.index(cutoff)
41
+ end
42
+
43
+ def cutoff_time_string
44
+ '11:00 am MST'
45
+ end
46
+
47
+ def cutoff_time
48
+ base = Time.parse(cutoff_time_string).to_datetime
49
+ updated = base.change(
50
+ day: date.day,
51
+ month: date.month,
52
+ year: date.year
53
+ )
54
+ end
55
+
56
+ def before_cutoff_time?
57
+ date < cutoff_time
58
+ end
59
+
60
+ def days_of_week_names = Date::DAYNAMES.map(&:downcase)
61
+
62
+ def next_cutoff
63
+ CUTOFFS[next_cutoff_dow]
64
+ end
65
+
66
+ def dow_before_cutoff_time
67
+ return day_of_week if cutoff_day?
68
+
69
+ dow_index = days_of_week_names.index(day_of_week)
70
+ rotated = days_of_week_names.rotate(dow_index)
71
+ rotated.detect { |dow| CUTOFFS.keys.include?(dow) }
72
+ end
73
+
74
+ def dow_after_cutoff_time
75
+ dow_index = days_of_week_names.index(day_of_week)
76
+ rotated = days_of_week_names.rotate(dow_index + 1)
77
+ rotated.detect { |dow| CUTOFFS.keys.include?(dow) }
78
+ end
79
+
80
+ def next_cutoff_dow
81
+ return dow_before_cutoff_time if before_cutoff_time?
82
+
83
+ dow_after_cutoff_time
84
+ end
85
+
86
+ def next_release_day
87
+ next_release_dow = next_cutoff['release']
88
+ date.next_occurring(next_release_dow.to_sym)
89
+ end
90
+
91
+ end
92
+ end
@@ -1,33 +1,61 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "sod"
4
+
3
5
  module Fixversion
4
6
  module CLI
5
7
  # The main Command Line Interface (CLI) object.
6
8
  class Shell
7
- include Actions::Import[:config, :specification, :logger]
9
+ include Import[:defaults_path, :xdg_config, :specification]
8
10
 
9
- def initialize parser: Parser.new, **dependencies
10
- super(**dependencies)
11
- @parser = parser
11
+ def initialize(context: Sod::Context, dsl: Sod, **)
12
+ super(**)
13
+ @context = context
14
+ @dsl = dsl
12
15
  end
13
16
 
14
- def call arguments = []
15
- perform parser.call(arguments)
16
- rescue OptionParser::ParseError => error
17
- logger.error { error.message }
18
- end
17
+ def call(...) = cli.call(...)
19
18
 
20
19
  private
21
20
 
22
- attr_reader :parser
21
+ attr_reader :context, :dsl
22
+
23
+ # --------------------------------------------------
24
+
25
+ class Next < Sod::Action
26
+ include Sod::Import[:logger]
27
+
28
+ description "Get next fix version!"
29
+
30
+ on "--next"
31
+
32
+ def call(*)
33
+ in_time_zone = Fixversion::InTimeZone.new
34
+ logger.info { "Next fix version is:" }
35
+ logger.info { in_time_zone.fetch }
36
+ end
37
+ end
38
+
39
+ # --------------------------------------------------
40
+
41
+
42
+ def cli
43
+ context = build_context
23
44
 
24
- def perform configuration
25
- case configuration
26
- in action_config: Symbol => action then config.call action
27
- in action_version: true then logger.info { specification.labeled_version }
28
- else logger.any { parser.to_s }
45
+ dsl.new :fixversion, banner: specification.banner do
46
+ on "fetch", "Fetch fix version" do
47
+ on Next
48
+ end
49
+
50
+ on(Sod::Prefabs::Commands::Config, context:)
51
+ on(Sod::Prefabs::Actions::Version, context:)
52
+ on Sod::Prefabs::Actions::Help, self
29
53
  end
30
54
  end
55
+
56
+ def build_context
57
+ context[defaults_path:, xdg_config:, version_label: specification.labeled_version]
58
+ end
31
59
  end
32
60
  end
33
61
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/schema"
4
+
5
+ Dry::Schema.load_extensions :monads
6
+
7
+ module Fixversion
8
+ module Configuration
9
+ Contract = Dry::Schema.Params
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fixversion
4
+ module Configuration
5
+ # Defines the configuration model for use throughout the gem.
6
+ Model = Data.define
7
+ end
8
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "cogger"
4
4
  require "dry/container"
5
+ require "etcher"
6
+ require "runcom"
5
7
  require "spek"
6
8
 
7
9
  module Fixversion
@@ -9,9 +11,23 @@ module Fixversion
9
11
  module Container
10
12
  extend Dry::Container::Mixin
11
13
 
12
- register(:configuration) { Configuration::Loader.call }
13
- register(:specification) { Spek::Loader.call "#{__dir__}/../../fixversion.gemspec" }
14
- register(:kernel) { Kernel }
15
- register(:logger) { Cogger::Client.new }
14
+ register :configuration, memoize: true do
15
+ self[:defaults].add_loader(Etcher::Loaders::YAML.new(self[:xdg_config].active))
16
+ .then { |registry| Etcher.call registry }
17
+ end
18
+
19
+ register :defaults, memoize: true do
20
+ Etcher::Registry.new(contract: Configuration::Contract, model: Configuration::Model)
21
+ .add_loader(Etcher::Loaders::YAML.new(self[:defaults_path]))
22
+ end
23
+
24
+ register :specification, memoize: true do
25
+ Spek::Loader.call "#{__dir__}/../../fixversion.gemspec"
26
+ end
27
+
28
+ register(:defaults_path, memoize: true) { Pathname(__dir__).join("configuration/defaults.yml") }
29
+ register(:xdg_config, memoize: true) { Runcom::Config.new "fixversion/configuration.yml" }
30
+ register(:logger, memoize: true) { Cogger.new id: "fixversion" }
31
+ register :kernel, Kernel
16
32
  end
17
33
  end
@@ -0,0 +1,27 @@
1
+ require 'active_support/all'
2
+
3
+ module Fixversion
4
+ class InTimeZone
5
+
6
+ attr_accessor :today
7
+
8
+ def initialize(today = time_current_default)
9
+ @today = today
10
+ end
11
+
12
+ def fetch
13
+ base = Base.new(today)
14
+ # debugger;
15
+
16
+ base.fix_version
17
+ end
18
+
19
+ def time_current_default
20
+ DateTime.current.in_time_zone("Mountain Time (US & Canada)").to_datetime
21
+ end
22
+
23
+ def time_zones = ActiveSupport::TimeZone.all.map(&:name)
24
+
25
+
26
+ end
27
+ end
data/lib/fixversion.rb CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  require "zeitwerk"
4
4
 
5
- Zeitwerk::Loader.for_gem.then do |loader|
5
+ Zeitwerk::Loader.new.then do |loader|
6
6
  loader.inflector.inflect "cli" => "CLI"
7
+ loader.tag = File.basename __FILE__, ".rb"
8
+ loader.push_dir __dir__
7
9
  loader.setup
8
10
  end
9
11
 
10
12
  # Main namespace.
11
13
  module Fixversion
14
+ def self.loader registry = Zeitwerk::Registry
15
+ @loader ||= registry.loaders.find { |loader| loader.tag == File.basename(__FILE__, ".rb") }
16
+ end
12
17
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Aga
@@ -38,6 +38,20 @@ cert_chain:
38
38
  -----END CERTIFICATE-----
39
39
  date: 2024-04-20 00:00:00.000000000 Z
40
40
  dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: cogger
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.12'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.12'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: dry-container
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +67,21 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0.11'
55
69
  - !ruby/object:Gem::Dependency
56
- name: infusible
70
+ name: dry-monads
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.6'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: etcher
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
@@ -66,48 +94,76 @@ dependencies:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: infusible
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.2'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: refinements
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
115
  - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: '9.7'
117
+ version: '11.0'
76
118
  type: :runtime
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
122
  - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: '9.7'
124
+ version: '11.0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: runcom
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
129
  - - "~>"
88
130
  - !ruby/object:Gem::Version
89
- version: '8.7'
131
+ version: '10.0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: sod
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.0'
90
146
  type: :runtime
91
147
  prerelease: false
92
148
  version_requirements: !ruby/object:Gem::Requirement
93
149
  requirements:
94
150
  - - "~>"
95
151
  - !ruby/object:Gem::Version
96
- version: '8.7'
152
+ version: '0.0'
97
153
  - !ruby/object:Gem::Dependency
98
154
  name: spek
99
155
  requirement: !ruby/object:Gem::Requirement
100
156
  requirements:
101
157
  - - "~>"
102
158
  - !ruby/object:Gem::Version
103
- version: '0.6'
159
+ version: '2.0'
104
160
  type: :runtime
105
161
  prerelease: false
106
162
  version_requirements: !ruby/object:Gem::Requirement
107
163
  requirements:
108
164
  - - "~>"
109
165
  - !ruby/object:Gem::Version
110
- version: '0.6'
166
+ version: '2.0'
111
167
  - !ruby/object:Gem::Dependency
112
168
  name: zeitwerk
113
169
  requirement: !ruby/object:Gem::Requirement
@@ -137,19 +193,14 @@ files:
137
193
  - exe/fixversion
138
194
  - fixversion.gemspec
139
195
  - lib/fixversion.rb
140
- - lib/fixversion/cli/actions/config.rb
141
- - lib/fixversion/cli/actions/container.rb
142
- - lib/fixversion/cli/actions/import.rb
143
- - lib/fixversion/cli/parser.rb
144
- - lib/fixversion/cli/parsers/core.rb
196
+ - lib/fixversion/base.rb
145
197
  - lib/fixversion/cli/shell.rb
146
- - lib/fixversion/configuration/content.rb
198
+ - lib/fixversion/configuration/contract.rb
147
199
  - lib/fixversion/configuration/defaults.yml
148
- - lib/fixversion/configuration/loader.rb
200
+ - lib/fixversion/configuration/model.rb
149
201
  - lib/fixversion/container.rb
150
202
  - lib/fixversion/import.rb
151
- - lib/fixversion/inner/base.rb
152
- - lib/fixversion/inner/in_time_zone.rb
203
+ - lib/fixversion/in_time_zone.rb
153
204
  homepage: ''
154
205
  licenses:
155
206
  - Hippocratic-2.1
@@ -164,14 +215,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
215
  requirements:
165
216
  - - "~>"
166
217
  - !ruby/object:Gem::Version
167
- version: '3.1'
218
+ version: '3.2'
168
219
  required_rubygems_version: !ruby/object:Gem::Requirement
169
220
  requirements:
170
221
  - - ">="
171
222
  - !ruby/object:Gem::Version
172
223
  version: '0'
173
224
  requirements: []
174
- rubygems_version: 3.4.6
225
+ rubygems_version: 3.4.10
175
226
  signing_key:
176
227
  specification_version: 4
177
228
  summary: ''
metadata.gz.sig CHANGED
Binary file
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fixversion
4
- module CLI
5
- module Actions
6
- # Handles the config action.
7
- class Config
8
- include Fixversion::Import[:kernel, :logger]
9
-
10
- def initialize client: Configuration::Loader::CLIENT, **dependencies
11
- super(**dependencies)
12
-
13
- @client = client
14
- end
15
-
16
- def call selection
17
- case selection
18
- when :edit then edit
19
- when :view then view
20
- else logger.error { "Invalid configuration selection: #{selection}." }
21
- end
22
- end
23
-
24
- private
25
-
26
- attr_reader :client
27
-
28
- def edit = kernel.system("$EDITOR #{client.current}")
29
-
30
- def view = kernel.system("cat #{client.current}")
31
- end
32
- end
33
- end
34
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "dry/container"
4
-
5
- module Fixversion
6
- module CLI
7
- module Actions
8
- # Provides a single container of application and action specific dependencies.
9
- module Container
10
- extend Dry::Container::Mixin
11
-
12
- merge Fixversion::Container
13
-
14
- register(:config) { Config.new }
15
- end
16
- end
17
- end
18
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "infusible"
4
-
5
- module Fixversion
6
- module CLI
7
- module Actions
8
- Import = Infusible.with Container
9
- end
10
- end
11
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "optparse"
4
-
5
- module Fixversion
6
- module CLI
7
- # Assembles and parses all Command Line Interface (CLI) options.
8
- class Parser
9
- include Import[:configuration]
10
-
11
- CLIENT = OptionParser.new nil, 40, " "
12
-
13
- # Order is important.
14
- SECTIONS = [Parsers::Core].freeze
15
-
16
- def initialize sections: SECTIONS, client: CLIENT, **dependencies
17
- super(**dependencies)
18
-
19
- @sections = sections
20
- @client = client
21
- @configuration_duplicate = configuration.dup
22
- end
23
-
24
- def call arguments = []
25
- sections.each { |section| section.call configuration_duplicate, client: }
26
- client.parse arguments
27
- configuration_duplicate.freeze
28
- end
29
-
30
- def to_s = client.to_s
31
-
32
- private
33
-
34
- attr_reader :sections, :client, :configuration_duplicate
35
- end
36
- end
37
- end
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/structs"
4
-
5
- module Fixversion
6
- module CLI
7
- module Parsers
8
- # Handles parsing of Command Line Interface (CLI) core options.
9
- class Core
10
- include Import[:specification]
11
-
12
- using Refinements::Structs
13
-
14
- def self.call(...) = new(...).call
15
-
16
- def initialize configuration = Container[:configuration],
17
- client: Parser::CLIENT,
18
- **dependencies
19
-
20
- super(**dependencies)
21
- @configuration = configuration
22
- @client = client
23
- end
24
-
25
- def call arguments = []
26
- client.banner = specification.labeled_summary
27
- client.separator "\nUSAGE:\n"
28
- collate
29
- client.parse arguments
30
- configuration
31
- end
32
-
33
- private
34
-
35
- attr_reader :configuration, :client
36
-
37
- def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method }
38
-
39
- def add_fetch
40
- client.on "-f",
41
- "--fetch ACTION",
42
- %i[next],
43
- "Get next fix version" do |action|
44
- in_time_zone = Fixversion::Inner::InTimeZone.new
45
- puts "Next fix version is:"
46
- puts in_time_zone.fetch
47
- end
48
- end
49
-
50
- def add_config
51
- client.on "-c",
52
- "--config ACTION",
53
- %i[edit view],
54
- "Manage gem configuration: edit or view." do |action|
55
- configuration.merge! action_config: action
56
- end
57
- end
58
-
59
- def add_version
60
- client.on "-v", "--version", "Show gem version." do
61
- configuration.merge! action_version: true
62
- end
63
- end
64
-
65
- def add_help
66
- client.on "-h", "--help", "Show this message." do
67
- configuration.merge! action_help: true
68
- end
69
- end
70
- end
71
- end
72
- end
73
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fixversion
4
- module Configuration
5
- # Defines the content of the configuration for use throughout the gem.
6
- Content = Struct.new(
7
- :action_config,
8
- :action_help,
9
- :action_version,
10
- keyword_init: true
11
- ) do
12
- def initialize *arguments
13
- super
14
- freeze
15
- end
16
- end
17
- end
18
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "pathname"
4
- require "refinements/hashes"
5
- require "refinements/structs"
6
- require "runcom"
7
- require "yaml"
8
-
9
- module Fixversion
10
- module Configuration
11
- # Represents the fully assembled Command Line Interface (CLI) configuration.
12
- class Loader
13
- using Refinements::Hashes
14
- using Refinements::Structs
15
-
16
- DEFAULTS = (YAML.load_file(Pathname(__dir__).join("defaults.yml")) || {}).freeze
17
- CLIENT = Runcom::Config.new "fixversion/configuration.yml", defaults: DEFAULTS
18
-
19
- def self.call = new.call
20
-
21
- def self.with_defaults = new client: DEFAULTS
22
-
23
- def initialize content: Content.new, client: CLIENT
24
- @content = content
25
- @client = client
26
- end
27
-
28
- def call = content.merge(**client.to_h.flatten_keys).freeze
29
-
30
- private
31
-
32
- attr_reader :content, :client
33
- end
34
- end
35
- end
@@ -1,94 +0,0 @@
1
- require 'active_support/all'
2
-
3
- module Fixversion
4
- module Inner
5
- class Base
6
-
7
- CUTOFFS = {
8
- 'wednesday': {
9
- cutoff: '11:00 am MST',
10
- release: 'thursday'
11
- },
12
- 'friday': {
13
- cutoff: '11:00 am MST',
14
- release: 'tuesday'
15
- }
16
- }.with_indifferent_access
17
-
18
- attr_accessor :date
19
-
20
- def initialize(date)
21
- @date = date
22
- end
23
-
24
- def cutoff_days
25
- CUTOFFS.keys
26
- end
27
-
28
- def day_of_week
29
- date.strftime("%A").downcase
30
- end
31
-
32
- def cutoff_day?
33
- CUTOFFS.keys.include?(day_of_week)
34
- end
35
-
36
- def fix_version
37
- next_release_day.strftime('%Y.%m.%d')
38
- end
39
-
40
- def cutoff_index
41
- CUTOFFS.keys.index(cutoff)
42
- end
43
-
44
- def cutoff_time_string
45
- '11:00 am MST'
46
- end
47
-
48
- def cutoff_time
49
- base = Time.parse(cutoff_time_string).to_datetime
50
- updated = base.change(
51
- day: date.day,
52
- month: date.month,
53
- year: date.year
54
- )
55
- end
56
-
57
- def before_cutoff_time?
58
- date < cutoff_time
59
- end
60
-
61
- def days_of_week_names = Date::DAYNAMES.map(&:downcase)
62
-
63
- def next_cutoff
64
- CUTOFFS[next_cutoff_dow]
65
- end
66
-
67
- def dow_before_cutoff_time
68
- return day_of_week if cutoff_day?
69
-
70
- dow_index = days_of_week_names.index(day_of_week)
71
- rotated = days_of_week_names.rotate(dow_index)
72
- rotated.detect { |dow| CUTOFFS.keys.include?(dow) }
73
- end
74
-
75
- def dow_after_cutoff_time
76
- dow_index = days_of_week_names.index(day_of_week)
77
- rotated = days_of_week_names.rotate(dow_index + 1)
78
- rotated.detect { |dow| CUTOFFS.keys.include?(dow) }
79
- end
80
-
81
- def next_cutoff_dow
82
- return dow_before_cutoff_time if before_cutoff_time?
83
-
84
- dow_after_cutoff_time
85
- end
86
-
87
- def next_release_day
88
- next_release_dow = next_cutoff['release']
89
- date.next_occurring(next_release_dow.to_sym)
90
- end
91
-
92
- end
93
- end
94
- end
@@ -1,30 +0,0 @@
1
- require 'active_support/all'
2
-
3
- # Fixversion::Inner::InTimeZone
4
- module Fixversion
5
- module Inner
6
- class InTimeZone
7
-
8
- attr_accessor :today
9
-
10
- def initialize(today = time_current_default)
11
- @today = today
12
- end
13
-
14
- def fetch
15
- base = Base.new(today)
16
- # debugger;
17
-
18
- base.fix_version
19
- end
20
-
21
- def time_current_default
22
- DateTime.current.in_time_zone("Mountain Time (US & Canada)").to_datetime
23
- end
24
-
25
- def time_zones = ActiveSupport::TimeZone.all.map(&:name)
26
-
27
-
28
- end
29
- end
30
- end