Class: CaptiveRelease::VersionDetector

Inherits:
Object
  • Object
show all
Defined in:
lib/captive_release/version_detector.rb

Constant Summary collapse

EXCLUDED_DIRS =
%w[node_modules .git vendor tmp coverage dist .next .nuxt Pods].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ VersionDetector

Returns a new instance of VersionDetector.



13
14
15
# File 'lib/captive_release/version_detector.rb', line 13

def initialize(root)
  @root = Pathname.new(root).expand_path
end

Class Method Details

.scan(root = ".") ⇒ Object



9
10
11
# File 'lib/captive_release/version_detector.rb', line 9

def self.scan(root = ".")
  new(root).scan
end

Instance Method Details

#capacitor?Boolean

Returns:

  • (Boolean)


33
34
35
36
37
38
39
# File 'lib/captive_release/version_detector.rb', line 33

def capacitor?
  %w[capacitor.config.ts capacitor.config.json capacitor.config.js].any? do |f|
    File.exist?(@root.join(f))
  end
rescue
  false
end

#expo?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/captive_release/version_detector.rb', line 26

def expo?
  find_files("app.config.js", "app_config_js").any? ||
    find_files("app.json", "plain").any? { |f| File.read(File.join(@root, f.path)).include?('"expo"') }
rescue
  false
end

#scanObject



17
18
19
20
21
22
23
24
# File 'lib/captive_release/version_detector.rb', line 17

def scan
  find_files("package.json", "package_json") +
    find_files("app.config.js", "app_config_js") +
    find_ruby_version_files +
    find_files("VERSION", "plain") +
    find_android_gradle_files +
    find_ios_plist_files
end