tramway 2.1.2.2 → 2.1.3

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: a108d9f6b0ab15ca13dbec981bf7f4ac29c5474a2d323e27403b38b1314dce6d
4
- data.tar.gz: e457068710dab0be690f42595fb0342b4b71d9c87dc96a523227fcaf0d23f6f1
3
+ metadata.gz: 92a090294d94e95de5522b38fd15210388522bdcdd31844fd47d091b7b208011
4
+ data.tar.gz: 06c9928adff35d27dd6bcc92c99fdee5e9d48f7753186309baa46d5999505d8d
5
5
  SHA512:
6
- metadata.gz: d0306bd5aa60e044e3505be37fd0c18946ef6a10285fbc6047b7139eaaba139f85f0f7dc8e504172fe169fb4cc8693d1352e93c72d78cf07c30b358b810aea6c
7
- data.tar.gz: 6cd072afc56a204e8417b31f838670049ad738e5f49eba04a77e22a1c7c33ab2d6e7d2ab5aa8c47d7d1076d334076c6e3f083c19bb66ea2c8770f7d21c9073b8
6
+ metadata.gz: 790773b5ff343ca1eb92629215e39f722a1c4638133ca44960a317ad1b9e7805107ba1beed6cc1c597585314e3fe78027fabc8f266515e9aabded6b721f4bde7
7
+ data.tar.gz: e0d6ef70d2a1769736343a1104dbdade1aec992e52e604453f495b094f28fd8287dba0d62d52fb063905b9d9c6fa46c28feb65b29f743ab96640a502979d6ba2
data/docs/AGENTS.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## Start of Tramway AGENTS.md
2
+
1
3
  # AGENTS.md: Tramway Code Generation Standards
2
4
 
3
5
  This document guides AI-assisted code generation for Rails applications built with **Tramway**. It is designed for founders, designers, PMs, and engineers who rely on AI tools (ChatGPT/Copilot/etc.) to build maintainable Rails code that fits Tramway’s conventions without a senior engineer reworking everything.
@@ -160,3 +162,5 @@ end
160
162
  - [ ] Controller actions are concise with guard clauses.
161
163
  - [ ] Reusable UI is a ViewComponent using Tailwind utilities and accessible semantics.
162
164
  - [ ] Tailwind safelist covers dynamic classes.
165
+
166
+ ## End of Tramway AGENTS.md
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'rails/generators'
4
4
  require 'fileutils'
5
+ require 'net/http'
5
6
 
6
7
  module Tramway
7
8
  module Generators
@@ -49,16 +50,32 @@ module Tramway
49
50
  @agents_file_path ||= File.join(destination_root, 'AGENTS.md')
50
51
  end
51
52
 
52
- def gem_agents_file_path
53
- @gem_agents_file_path ||= File.expand_path('../../../../docs/AGENTS.md', __dir__)
53
+ def agents_template_url
54
+ 'https://raw.githubusercontent.com/TrinityMonsters/tramway/refs/heads/main/docs/AGENTS.md'
55
+ end
56
+
57
+ def agents_template_body
58
+ return @agents_template_body if defined?(@agents_template_body)
59
+
60
+ uri = URI.parse(agents_template_url)
61
+ response = Net::HTTP.get_response(uri)
62
+ @agents_template_body = response.body.to_s
63
+ end
64
+
65
+ def agents_section_start
66
+ '## Start of Tramway AGENTS.md'
67
+ end
68
+
69
+ def agents_section_end
70
+ '## End of Tramway AGENTS.md'
54
71
  end
55
72
 
56
73
  def agents_template
57
- @agents_template ||= File.read(gem_agents_file_path)
74
+ @agents_template ||= [agents_section_start, agents_template_body.rstrip, agents_section_end].join("\n")
58
75
  end
59
76
 
60
- def agents_section_heading
61
- @agents_section_heading ||= agents_template.lines.first&.strip
77
+ def agents_section_present?(content)
78
+ content.include?(agents_section_start) && content.include?(agents_section_end)
62
79
  end
63
80
 
64
81
  def create_tailwind_config
@@ -99,11 +116,9 @@ module Tramway
99
116
  line[/^\s*/] || ' '
100
117
  end
101
118
 
102
- def append_agents_template(content)
119
+ def insert_agents_template(content)
103
120
  separator = agents_separator(content)
104
- File.open(agents_file_path, 'a') do |file|
105
- file.write("#{separator}#{agents_template}")
106
- end
121
+ "#{content}#{separator}#{agents_template}"
107
122
  end
108
123
 
109
124
  def agents_separator(content)
@@ -111,6 +126,15 @@ module Tramway
111
126
 
112
127
  content.end_with?("\n") ? "\n" : "\n\n"
113
128
  end
129
+
130
+ def replace_agents_section(content)
131
+ return insert_agents_template(content) unless agents_section_present?(content)
132
+
133
+ content.sub(
134
+ /#{Regexp.escape(agents_section_start)}.*?#{Regexp.escape(agents_section_end)}/m,
135
+ agents_template
136
+ )
137
+ end
114
138
  end
115
139
 
116
140
  # Running `rails generate tramway:install` will invoke this generator
@@ -121,12 +145,19 @@ module Tramway
121
145
  desc 'Installs Tramway dependencies and Tailwind safelist configuration.'
122
146
 
123
147
  def ensure_agents_file
124
- return create_file(agents_file_path, agents_template) unless File.exist?(agents_file_path)
148
+ say_status(
149
+ :info,
150
+ "Tramway will replace the content between \"#{agents_section_start}\" and " \
151
+ "\"#{agents_section_end}\" in AGENTS.md."
152
+ )
153
+
154
+ return create_file(agents_file_path, "#{agents_template}\n") unless File.exist?(agents_file_path)
125
155
 
126
156
  content = File.read(agents_file_path)
127
- return if content.include?(agents_section_heading)
157
+ updated = replace_agents_section(content)
158
+ return if updated == content
128
159
 
129
- append_agents_template(content)
160
+ File.write(agents_file_path, updated)
130
161
  end
131
162
 
132
163
  def ensure_dependencies
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tramway
4
- VERSION = '2.1.2.2'
4
+ VERSION = '2.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kalashnikovisme