rails-diff 0.2.0 → 0.2.1

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: 1597a0a52bb69e722c40bdd8714a79d6ab42fcef23a844484c91ca70496d7e4b
4
- data.tar.gz: 92e9120a9d970073725b002ea0ae8a2144bfdc075b30ba02e637ce86fdcebee8
3
+ metadata.gz: 567e5e325109a4ed6c9daee6dd2c18a8c5bf20de492be9c4399c54347a2091fa
4
+ data.tar.gz: 6ef46901ce7d1445e0c8651323fdad776e9225223c4f2e4c1d6e506c31d70130
5
5
  SHA512:
6
- metadata.gz: 55149e9e567a6a63d6f0b6af85351d29a26af4c48ca16a8053cf46768cb883bfc16c8a908ab89e8047897194802ded032145b58d185f62772d5e81ca308d5120
7
- data.tar.gz: 716c754d1e4ff11ba617007aceb4de23fdea5cae49daaeedf794f3c497ad307e02d1827c48944d3fc4621b74427e6dba76c48089d878f36141f17e15f1c7a87b
6
+ metadata.gz: 1b5259244a5b576f651c75981c807854bb82d71cf3b7af72074a9ec05dacb30db477af39dc2a2ab1a11a2d328da23cbeb1b9deec62a0c190355785299f1622d5
7
+ data.tar.gz: 6b037fd06f237a6a48d2b98e4dcd36609b8a2b3ece0a7bada82b38249b63ca20fdcbdb8ee707ecafefa0de40fd5db8d6c18a97be033f2771a620cfb1750d9c42
data/CHANGELOG.md CHANGED
@@ -1,8 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2025-02-22
4
+
5
+ - Add missing version command
6
+ - Consistent error messages
7
+ - Ensure rails path exists and dependencies are installed
8
+
3
9
  ## [0.2.0] - 2025-02-21
4
10
 
5
11
  - Allow comparing a specific commit
12
+
6
13
  ```sh
7
14
  rails-diff file Dockerfile --commit 3e7640
8
15
  ```
@@ -23,6 +30,7 @@ M## [0.1.1] - 2025-02-21
23
30
 
24
31
  - Initial release
25
32
 
33
+ [0.2.1]: https://github.com/matheusrich/rails-diff/releases/tag/v0.2.1
26
34
  [0.2.0]: https://github.com/matheusrich/rails-diff/releases/tag/v0.2.0
27
35
  [0.1.1]: https://github.com/matheusrich/rails-diff/releases/tag/v0.1.1
28
36
  [0.1.0]: https://github.com/matheusrich/rails-diff/releases/tag/v0.1.0
data/Rakefile CHANGED
@@ -6,4 +6,4 @@ require "rspec/core/rake_task"
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  task default: :spec
9
- task release: :spec
9
+ task build: :spec
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rails
4
4
  module Diff
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
data/lib/rails/diff.rb CHANGED
@@ -33,21 +33,36 @@ module Rails
33
33
 
34
34
  private
35
35
 
36
+ def clear_cache
37
+ puts "Clearing cache"
38
+ FileUtils.rm_rf(CACHE_DIR)
39
+ end
40
+
41
+ def ensure_template_app_exists(commit)
42
+ FileUtils.mkdir_p(CACHE_DIR)
43
+ @commit = commit || latest_commit
44
+ return if cached_app?
45
+
46
+ FileUtils.rm_rf(template_app_path)
47
+ create_new_rails_app
48
+ end
49
+
36
50
  def template_app_path
37
51
  @template_app_path ||= File.join(CACHE_DIR, commit, app_name)
38
52
  end
39
53
 
40
54
  def rails_path
41
- @rails_path ||= File.join(CACHE_DIR, "rails")
55
+ @rails_path ||= begin
56
+ File.join(CACHE_DIR, "rails").tap do |path|
57
+ unless File.exist?(path)
58
+ system("git clone --depth 1 #{RAILS_REPO} #{path} >/dev/null 2>&1")
59
+ end
60
+ end
61
+ end
42
62
  end
43
63
 
44
64
  def app_name = @app_name ||= File.basename(Dir.pwd)
45
65
 
46
- def clear_cache
47
- puts "Clearing cache..."
48
- FileUtils.rm_rf(CACHE_DIR)
49
- end
50
-
51
66
  def list_files(dir, skip = [])
52
67
  Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH).reject do |it|
53
68
  File.directory?(it) ||
@@ -87,7 +102,7 @@ module Rails
87
102
  def install_app_dependencies
88
103
  Dir.chdir(template_app_path) do
89
104
  unless system("bundle check >/dev/null 2>&1")
90
- puts "Installing application dependencies..."
105
+ puts "Installing application dependencies"
91
106
  system("bundle install >/dev/null 2>&1")
92
107
  end
93
108
  end
@@ -108,15 +123,6 @@ module Rails
108
123
  ).to_s(:color).chomp
109
124
  end
110
125
 
111
- def ensure_template_app_exists(commit)
112
- FileUtils.mkdir_p(CACHE_DIR)
113
- @commit = commit || latest_commit
114
- return if cached_app?
115
-
116
- FileUtils.rm_rf(template_app_path)
117
- create_new_rails_app
118
- end
119
-
120
126
  def cached_app?
121
127
  File.exist?(template_app_path) && !rails_updated?
122
128
  end
@@ -139,10 +145,6 @@ module Rails
139
145
  end
140
146
 
141
147
  def create_new_rails_app
142
- unless File.exist?(rails_path)
143
- system("git clone --depth 1 #{RAILS_REPO} #{rails_path} >/dev/null 2>&1")
144
- end
145
-
146
148
  Dir.chdir(rails_path) do
147
149
  checkout_rails
148
150
  generate_app
@@ -151,7 +153,12 @@ module Rails
151
153
 
152
154
  def generate_app
153
155
  Dir.chdir("railties") do
154
- puts "Generating new Rails application..."
156
+ unless system("bundle check >/dev/null 2>&1")
157
+ puts "Installing Rails dependencies"
158
+ system("bundle install >/dev/null 2>&1")
159
+ end
160
+
161
+ puts "Generating new Rails application"
155
162
  system("bundle exec rails new #{template_app_path} --main --skip-bundle --force --skip-test --skip-system-test --quiet")
156
163
  end
157
164
  end
@@ -195,6 +202,12 @@ module Rails
195
202
 
196
203
  options[:fail] ? abort(diff) : puts(diff)
197
204
  end
205
+
206
+ map %w[--version -v] => :__version
207
+ desc "--version, -v", "print the version"
208
+ def __version
209
+ puts VERSION
210
+ end
198
211
  end
199
212
  end
200
213
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matheus Richard