durable_streams-rails 0.2.1 → 0.2.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: 0c80a5c344510700b9f1820501af721aa5e7f622bfeb07336b641aaf1e9f75d0
4
- data.tar.gz: 4d6ec733fb72e08ce50a875fe39d0797590c078ff3605b754cf1cebf38425a4c
3
+ metadata.gz: c92e0876c45c1275005ac561769b4653d63fb344518fa5158b10d79558fd4538
4
+ data.tar.gz: '09935cbb04fb7e94081d10d5313488c7eccb7113fd7a327d892b33fc7d8c3d5a'
5
5
  SHA512:
6
- metadata.gz: e5397e49a89527153f53d0b558fbbad3a8f7db5851232173aabd70f4b9adfc73c4a9bccac48daaa9cbaa3a61102cf5d07b3bac59fbccbef321209c26328e86c3
7
- data.tar.gz: afa1c49d6679cc088e9c2c08928c39d902cd255f991c4b2f44c997bdd9ed4b2646ddb1200f5abb3a4b32db57b00a5e712e902479be3ed5a37ee22c28bbc59cec
6
+ metadata.gz: 91afdd838a384a32e001ce175fa3f5e0415953c1e60f28a9afaab9ebdd36aaa05a237fb0d735bf7be42cff3ac0c16746011bdd10e90c15a50234fa4b51a6a3a5
7
+ data.tar.gz: 68c5ba947c3821328d349034d106c18ab2004d1b44619396e2265337442510c82f7c439682d397769638554114cb5f61eb5914249af017fc822b1b76994c9882
@@ -1,3 +1,3 @@
1
1
  module DurableStreams
2
- RAILS_VERSION = "0.2.1"
2
+ RAILS_VERSION = "0.2.3"
3
3
  end
@@ -29,15 +29,22 @@ module DurableStreams
29
29
  return if options[:skip_procfile]
30
30
 
31
31
  procfile = "Procfile.dev"
32
+ procfile_path = File.join(destination_root, procfile)
32
33
  entry = "streams: bin/durable-streams\n"
33
34
 
34
- if File.exist?(procfile) && !File.read(procfile).match?(/^streams:/)
35
+ if File.exist?(procfile_path)
36
+ contents = File.read(procfile_path)
37
+ return if contents.match?(/^streams:/)
38
+
39
+ entry = "\n#{entry}" unless contents.end_with?("\n")
35
40
  append_file procfile, entry
36
41
  end
37
42
  end
38
43
 
39
44
  def update_gitignore
40
- if File.exist?(".gitignore") && !File.read(".gitignore").match?(/^bin\/dist/)
45
+ gitignore_path = File.join(destination_root, ".gitignore")
46
+
47
+ if File.exist?(gitignore_path) && !File.read(gitignore_path).match?(/^bin\/dist/)
41
48
  append_file ".gitignore", "\n# Durable Streams server binary\nbin/dist/\n"
42
49
  end
43
50
  end
@@ -1,6 +1,9 @@
1
1
  namespace :durable_streams do
2
2
  desc "Download the Durable Streams server binary for the current platform"
3
3
  task :download do
4
+ require "net/http"
5
+ require "json"
6
+
4
7
  version = ENV.fetch("DURABLE_STREAMS_VERSION", "latest")
5
8
  install_dir = Rails.root.join("bin", "dist")
6
9
  bin_path = install_dir.join("durable-streams-server")
@@ -25,18 +28,27 @@ namespace :durable_streams do
25
28
  end
26
29
  }
27
30
 
28
- FileUtils.mkdir_p(install_dir)
29
-
30
31
  if version == "latest"
31
- url = "https://github.com/durable-streams/durable-streams/releases/latest/download/durable-streams-server_#{os}_#{arch}.tar.gz"
32
- else
33
- url = "https://github.com/durable-streams/durable-streams/releases/download/caddy-v#{version}/durable-streams-server_#{version}_#{os}_#{arch}.tar.gz"
32
+ version = resolve_latest_version
34
33
  end
35
34
 
35
+ FileUtils.mkdir_p(install_dir)
36
+
37
+ url = "https://github.com/durable-streams/durable-streams/releases/download/v#{version}/durable-streams-server_#{version}_#{os}_#{arch}.tar.gz"
38
+
36
39
  puts "Downloading durable-streams-server #{version} (#{os}/#{arch})..."
37
- system("curl", "-sL", url, "-o", "-", out: IO.popen(["tar", "xz", "-C", install_dir.to_s], "w").fileno) ||
38
- abort("Download failed")
40
+ system("curl", "-sfL", url, "-o", "-", out: IO.popen(["tar", "xz", "-C", install_dir.to_s], "w").fileno) ||
41
+ abort("Download failed — check https://github.com/durable-streams/durable-streams/releases")
39
42
  FileUtils.chmod(0755, bin_path)
40
43
  puts "Installed to #{bin_path}"
41
44
  end
42
45
  end
46
+
47
+ def resolve_latest_version
48
+ uri = URI("https://api.github.com/repos/durable-streams/durable-streams/releases/latest")
49
+ response = Net::HTTP.get(uri)
50
+ tag = JSON.parse(response).fetch("tag_name")
51
+ tag.delete_prefix("v")
52
+ rescue => e
53
+ abort "Failed to resolve latest version: #{e.message}"
54
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durable_streams-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tokimonki