ruflet 0.0.16 → 0.0.17

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: 653ba520f85466110b49be97b22029f8f1e30629edefcd3057def6ecbf20be2c
4
- data.tar.gz: 66107e193cfd961763921dafcec2d67f21216f34daad33a22eeffbef279b1b0e
3
+ metadata.gz: 92e604b976fa35dca0232bb0612798b92cc77da2df6d3a90bca9442718a40cc5
4
+ data.tar.gz: 99ae439ad39adda4a48a9ac9289a3daa29ee934be9dad714ce29be643fcee5cc
5
5
  SHA512:
6
- metadata.gz: 73608863d7814a25d421f4a1b26bf07a231673b50679e3815eeb7e22df39c0da3c92bbdc696c207a36af38b427413d1d2ed6d61ba36d2720e8a0f444bb3ac3a7
7
- data.tar.gz: 9a25b923371b68c7a8f51dbab32a30a71c0034033760c89cdf1773ffb9295707728107072f88523c9a5f7db4b43c5ded66d74096d52fa0547cd35103c99066b1
6
+ metadata.gz: d07ee36f5bbf6d46640b6584cb766ec53f78f7a91106612cbf372db109550e32114f8aaa35debb1add616c53404b1dc22fe1b2e571d0ce89a6f46d233c76d800
7
+ data.tar.gz: ed7f771022ac501f0f672c23fe40378a5d2ecacca5acc1b5e1df1f560ad3f6800b72490a84828b69922e30c0f074f35e20e53d83bd413ae38769afb93467c6fd
@@ -736,7 +736,7 @@ module Ruflet
736
736
  alt = "ruflet.yml"
737
737
  config_path = alt if File.file?(alt)
738
738
  end
739
- return {} unless File.file?(config_path)
739
+ return load_rails_ruflet_initializer_config unless File.file?(config_path)
740
740
 
741
741
  YAML.safe_load(File.read(config_path), aliases: true) || {}
742
742
  rescue StandardError => e
@@ -744,6 +744,52 @@ module Ruflet
744
744
  {}
745
745
  end
746
746
 
747
+ def load_rails_ruflet_initializer_config
748
+ initializer = File.join(Dir.pwd, "config", "initializers", "ruflet.rb")
749
+ return {} unless File.file?(initializer)
750
+
751
+ require "ruflet_rails"
752
+
753
+ with_minimal_rails_config_context do
754
+ load initializer
755
+ config = Ruflet::Rails.config
756
+ config.respond_to?(:to_ruflet_yaml_hash) ? config.to_ruflet_yaml_hash : {}
757
+ end
758
+ rescue LoadError => e
759
+ warn "Failed to load Rails Ruflet config: #{e.class}: #{e.message}"
760
+ {}
761
+ rescue StandardError => e
762
+ warn "Failed to load Rails Ruflet config: #{e.class}: #{e.message}"
763
+ {}
764
+ end
765
+
766
+ def with_minimal_rails_config_context
767
+ return yield if defined?(::Rails)
768
+
769
+ rails_module = Module.new
770
+ root = Pathname.new(Dir.pwd)
771
+ env = minimal_rails_env(ENV.fetch("RAILS_ENV", "development"))
772
+ rails_module.define_singleton_method(:root) { root }
773
+ rails_module.define_singleton_method(:env) { env }
774
+
775
+ Object.const_set(:Rails, rails_module)
776
+ yield
777
+ ensure
778
+ Object.send(:remove_const, :Rails) if defined?(rails_module) && Object.const_defined?(:Rails, false) && ::Rails.equal?(rails_module)
779
+ end
780
+
781
+ def minimal_rails_env(name)
782
+ value = name.to_s
783
+ Object.new.tap do |env|
784
+ env.define_singleton_method(:to_s) { value }
785
+ env.define_singleton_method(:to_str) { value }
786
+ env.define_singleton_method(:==) { |other| value == other.to_s }
787
+ env.define_singleton_method(:development?) { value == "development" }
788
+ env.define_singleton_method(:test?) { value == "test" }
789
+ env.define_singleton_method(:production?) { value == "production" }
790
+ end
791
+ end
792
+
747
793
  def apply_build_config(client_dir, config = {})
748
794
  config_path = ENV["RUFLET_CONFIG"] || (File.file?("ruflet.yaml") ? "ruflet.yaml" : "ruflet.yml")
749
795
  config_present = File.file?(config_path)
@@ -1551,13 +1597,15 @@ module Ruflet
1551
1597
  "lib/main.dart",
1552
1598
  "lib/main.self.dart",
1553
1599
  "lib/main.server.dart",
1554
- "lib/connection_probe.dart",
1555
- "lib/connection_probe_io.dart",
1556
- "lib/connection_probe_stub.dart",
1557
1600
  "lib/ruflet_file_picker_service.dart",
1558
1601
  "macos/Runner/DebugProfile.entitlements",
1559
1602
  "macos/Runner/Release.entitlements"
1560
1603
  ]
1604
+ stale_files = [
1605
+ "lib/connection_probe.dart",
1606
+ "lib/connection_probe_io.dart",
1607
+ "lib/connection_probe_stub.dart"
1608
+ ]
1561
1609
 
1562
1610
  managed_files.each do |relative_path|
1563
1611
  source = File.join(template_root, relative_path)
@@ -1569,6 +1617,14 @@ module Ruflet
1569
1617
  build_log(verbose, "refreshed template file #{relative_path}")
1570
1618
  end
1571
1619
 
1620
+ stale_files.each do |relative_path|
1621
+ path = File.join(client_dir, relative_path)
1622
+ next unless File.file?(path)
1623
+
1624
+ FileUtils.rm_f(path)
1625
+ build_log(verbose, "removed stale template file #{relative_path}")
1626
+ end
1627
+
1572
1628
  repair_legacy_self_contained_bootstrap(client_dir, verbose: verbose)
1573
1629
  end
1574
1630
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ruflet
4
- VERSION = "0.0.16" unless const_defined?(:VERSION)
4
+ VERSION = "0.0.17" unless const_defined?(:VERSION)
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruflet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - AdamMusa
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.7.2
69
+ rubygems_version: 4.0.11
70
70
  specification_version: 4
71
71
  summary: Ruflet command line interface package.
72
72
  test_files: []