port_of_call 0.1.0.alpha1 → 1.0.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: c5f861789c53684db6036135fcb5eb0057c90ea56c95aedd7fabd4cc85c9c0b2
4
- data.tar.gz: 0eab14311169be6984ed29ac0a531b0c0ac0f1da8a403dc7af2561a098969267
3
+ metadata.gz: bbeb66e086b05f2a7d9c8515d91c481c92fb9e488d9cdb9560448f48be955ea5
4
+ data.tar.gz: a711f3987939e88e5599f36dc81bd20f7bc12584a06a3dd8e12380cf387bb0aa
5
5
  SHA512:
6
- metadata.gz: 984c62a2c7dec18962070b1dd51b7a0149a21f4caa57c39a42832e5e460671f4ccc55a82445158102d26eb29a27a27f98a99ab7270ec1af9ac5fd900c71427cd
7
- data.tar.gz: fcf8f557fa7763042ef1f0aae10f416d101d83413f9d9c5ec869266e217d3931b31dc7dc33afad5ef3cbfbc7f0bb107f9fb2943ae740945dd418a8f3fc59a878
6
+ metadata.gz: f9b50b4755ed3ba80c0576139ea85c46a8131144485a774c4dc665fed1bcaad46b8f5a44f10fd2ce00275b3dc46e65db42eeaef54112ae02d7f85590e9deb0f9
7
+ data.tar.gz: d7066319108e1fb19b787b0d36f3886c6db7e5c10eefdd6b1ab3114e44b81d8262474968a2c2e5ec0fc0f590c4bdafeff6f6f24e2488265895ea5f30d3bdb6df
data/CHANGELOG.md CHANGED
@@ -5,6 +5,20 @@ 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
+ ## [1.0.0] - 2025-09-18
9
+
10
+ ### Changed
11
+ - Graduated to stable 1.0.0 release
12
+ - Public API is now considered stable
13
+
14
+ ## [0.1.0.alpha2] - 2025-03-25
15
+
16
+ ### Fixed
17
+ - Improved Rails environment detection in CLI commands
18
+ - Fixed CI workflow issues
19
+ - Better error handling when not in a Rails environment
20
+ - Added upper bound to Rails dependency version
21
+
8
22
  ## [0.1.0.alpha1] - 2025-03-25
9
23
 
10
24
  ### Added
data/README.md CHANGED
@@ -12,10 +12,10 @@ Rails developers who tend to work on multiple applications simultaneously
12
12
  =============================
13
13
  Port of Call deterministically assigns port numbers to Rails applications:
14
14
 
15
- 1. It extracts your application's name from Git or directory name
16
- 2. It creates a hash of the name using SHA256
17
- 3. It maps this hash to a port number within your configured range (default: 3000-3999)
18
- 4. It automatically sets this port when you start your Rails server
15
+ 1. It **extracts your application's name** from Git or directory name
16
+ 2. It **creates a hash** of the name using SHA256
17
+ 3. It **maps this hash to a port number** within your configured range (default: 3000-3999)
18
+ 4. It **automatically sets this port** when you start your Rails server
19
19
 
20
20
  The same app always gets the same port on any machine, avoiding conflicts!
21
21
 
@@ -54,33 +54,35 @@ Rake Tasks:
54
54
  - `rake port_of_call:start` - Start Rails server
55
55
  - `rake poc` - Shorthand for starting the server
56
56
 
57
+
58
+ ## Development
59
+
60
+ - After checking out the repo,
61
+ - run `bin/setup` to install dependencies.
62
+ - Then, run `rake spec` to run the tests.
63
+ - You can also run `bin/console` for an interactive prompt.
64
+
57
65
  ⛵️⛵️⛵️⛵️⛵️ Extras
58
66
  =============================
59
- Configuration:
67
+
68
+ ## Configuration:
60
69
  ```ruby
61
70
  # In config/initializers/port_of_call.rb
62
71
  PortOfCall.configure do |config|
63
72
  # Change port range (default: 3000..3999)
64
73
  config.port_range = 4000..4999
65
-
74
+
66
75
  # Set custom project name
67
76
  config.project_name = "my_unique_app_name"
68
-
77
+
69
78
  # Avoid specific ports
70
79
  config.reserved_ports = [4567, 5000]
71
80
  end
72
81
  ```
73
82
 
74
- Troubleshooting:
83
+ ## Troubleshooting:
75
84
  - If your port is already in use, Port of Call will warn you
76
85
  - To check port availability: `rake port_of_call:check`
77
86
  - For detailed info: `rake port_of_call:info`
78
87
 
79
- GitHub: [github.com/jonathanpberger/port-of-call](https://github.com/jonathanpberger/port-of-call)
80
-
81
- License: MIT with additional [disclaimer](LICENSE.txt)
82
- ```
83
-
84
- ## Development
85
-
86
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt.
88
+ [![Conforms to README.lint](https://img.shields.io/badge/README.lint-conforming-brightgreen)](https://github.com/discoveryworks/readme-dot-lint)
@@ -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 = "1.0.0"
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,13 +1,13 @@
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: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JPB
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-26 00:00:00.000000000 Z
10
+ date: 2025-09-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -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