port_of_call 0.1.0.alpha1 → 0.1.0.alpha2

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: c5f861789c53684db6036135fcb5eb0057c90ea56c95aedd7fabd4cc85c9c0b2
4
- data.tar.gz: 0eab14311169be6984ed29ac0a531b0c0ac0f1da8a403dc7af2561a098969267
3
+ metadata.gz: dbaf6a0f26c6b113a5f89eaffcb945a6656b3c736d815991d3a404701133241d
4
+ data.tar.gz: 834f5918a1754e2f258fa788553346ccebfbd6b944543658c27b7fa68d7ba30a
5
5
  SHA512:
6
- metadata.gz: 984c62a2c7dec18962070b1dd51b7a0149a21f4caa57c39a42832e5e460671f4ccc55a82445158102d26eb29a27a27f98a99ab7270ec1af9ac5fd900c71427cd
7
- data.tar.gz: fcf8f557fa7763042ef1f0aae10f416d101d83413f9d9c5ec869266e217d3931b31dc7dc33afad5ef3cbfbc7f0bb107f9fb2943ae740945dd418a8f3fc59a878
6
+ metadata.gz: dac5f9249ff7534c22feb3c7b7305e8d0fa6d9aa949db3e5e26136bee03843375b9de13ed716f35edb0d5991179c6b158621e9305f719d65b3ec9da69172e9af
7
+ data.tar.gz: 646fd8762099c550711c15b479d5ec08c21949f3a93ae2e3665a57cf11ffd273bfeef5d9a4f72f1d396f37b7e040063343406653d20b9dfaa3a78cf35aae12c5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.0.alpha2] - 2025-03-25
9
+
10
+ ### Fixed
11
+ - Improved Rails environment detection in CLI commands
12
+ - Fixed CI workflow issues
13
+ - Better error handling when not in a Rails environment
14
+ - Added upper bound to Rails dependency version
15
+
8
16
  ## [0.1.0.alpha1] - 2025-03-25
9
17
 
10
18
  ### Added
@@ -57,27 +57,29 @@ module PortOfCall
57
57
  exit 1
58
58
  end
59
59
 
60
+ # Check if Rails is available
61
+ if !rails_available?
62
+ puts "ERROR: Rails environment not detected"
63
+ puts "Calculated port for #{project_name}: #{port}"
64
+ exit 1
65
+ end
66
+
60
67
  # Construct server command
61
- if defined?(Rails) && defined?(Rails::Server)
62
- puts "Port of Call - Starting Rails server for #{project_name} on port #{port}"
68
+ puts "Port of Call - Starting Rails server for #{project_name} on port #{port}"
69
+
70
+ # Add -p option if not already specified
71
+ unless args.include?("-p") || args.include?("--port")
72
+ args.unshift("-p", port.to_s)
73
+ end
63
74
 
64
- # Add -p option if not already specified
65
- unless args.include?("-p") || args.include?("--port")
66
- args.unshift("-p", port.to_s)
67
- end
75
+ # Start server
76
+ server_class = Object.const_get("Rails::Server")
77
+ server_class.new(args).tap do |server|
78
+ # Set port in server options
79
+ server.options[:Port] = port if server.options[:Port].nil?
68
80
 
69
81
  # Start server
70
- Rails::Server.new(args).tap do |server|
71
- # Set port in server options
72
- server.options[:Port] = port if server.options[:Port].nil?
73
-
74
- # Start server
75
- server.start
76
- end
77
- else
78
- # Fallback when not running in a Rails context
79
- puts "Port of Call - Rails environment not detected"
80
- puts "Calculated port for #{project_name}: #{port}"
82
+ server.start
81
83
  end
82
84
  end
83
85
 
@@ -98,13 +100,13 @@ module PortOfCall
98
100
  # Set the calculated port as the default in development.rb
99
101
  # @return [void]
100
102
  def set_default_port
101
- if defined?(Rails) && defined?(Rails.root)
102
- # Use rake task for this
103
- system("rake", "port_of_call:set_default")
104
- else
103
+ if !rails_available?
105
104
  puts "ERROR: Rails environment not detected"
106
105
  exit 1
107
106
  end
107
+
108
+ # Use rake task for this
109
+ system("rake", "port_of_call:set_default")
108
110
  end
109
111
 
110
112
  # Show version information
@@ -134,5 +136,11 @@ module PortOfCall
134
136
  port_of_call set # Set the calculated port as the default
135
137
  HELP
136
138
  end
139
+
140
+ # Check if Rails is available
141
+ # @return [Boolean] true if Rails is available
142
+ def rails_available?
143
+ defined?(Rails) && Rails.respond_to?(:application)
144
+ end
137
145
  end
138
146
  end
@@ -3,5 +3,5 @@
3
3
  module PortOfCall
4
4
  # Version number for the gem
5
5
  # Following Semantic Versioning (https://semver.org/)
6
- VERSION = "0.1.0.alpha1"
6
+ VERSION = "0.1.0.alpha2"
7
7
  end
data/lib/port_of_call.rb CHANGED
@@ -4,9 +4,13 @@ require "socket"
4
4
  require_relative "port_of_call/version"
5
5
  require_relative "port_of_call/configuration"
6
6
  require_relative "port_of_call/port_calculator"
7
- require_relative "port_of_call/railtie" if defined?(Rails)
8
7
  require_relative "port_of_call/cli"
9
8
 
9
+ # Only require Rails-specific code if Rails is defined
10
+ if defined?(Rails) && Rails.respond_to?(:application)
11
+ require_relative "port_of_call/railtie"
12
+ end
13
+
10
14
  # Port of Call is a Ruby gem that assigns each Rails application a consistent,
11
15
  # deterministic port number based on the application's name or repository.
12
16
  # This solves the common conflict of multiple Rails apps all defaulting to port 3000.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: port_of_call
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha1
4
+ version: 0.1.0.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JPB
@@ -16,6 +16,9 @@ dependencies:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
18
  version: '6.0'
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '9.0'
19
22
  type: :runtime
20
23
  prerelease: false
21
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -23,6 +26,9 @@ dependencies:
23
26
  - - ">="
24
27
  - !ruby/object:Gem::Version
25
28
  version: '6.0'
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '9.0'
26
32
  - !ruby/object:Gem::Dependency
27
33
  name: rspec
28
34
  requirement: !ruby/object:Gem::Requirement