Class: Synvert::Core::Utils
- Inherits:
-
Object
- Object
- Synvert::Core::Utils
- Defined in:
- lib/synvert/core/utils.rb
Class Method Summary collapse
- .eval_snippet(snippet_name) ⇒ Object
-
.glob(file_patterns) ⇒ Array<String>
Glob file paths.
- .load_snippet(snippet_name) ⇒ Object
Class Method Details
.eval_snippet(snippet_name) ⇒ Object
10 11 12 |
# File 'lib/synvert/core/utils.rb', line 10 def eval_snippet(snippet_name) eval(load_snippet(snippet_name)) end |
.glob(file_patterns) ⇒ Array<String>
Glob file paths.
36 37 38 39 40 41 42 43 44 |
# File 'lib/synvert/core/utils.rb', line 36 def glob(file_patterns) Dir.chdir(Configuration.root_path) do all_files = file_patterns.flat_map do |file_pattern| Dir.glob(file_pattern) end filter_only_paths(all_files) - get_skip_files end end |
.load_snippet(snippet_name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/synvert/core/utils.rb', line 14 def load_snippet(snippet_name) if is_valid_url?(snippet_name) uri = URI.parse(format_url(snippet_name)) return uri.open.read if remote_snippet_exists?(uri) raise Errors::SnippetNotFound.new("#{snippet_name} nout found") elsif is_valid_file?(snippet_name) return File.read(snippet_name) else snippet_path = (snippet_name) return File.read(snippet_path) if File.exist?(snippet_path) snippet_uri = URI.parse(format_url(remote_snippet_url(snippet_name))) return snippet_uri.open.read if remote_snippet_exists?(snippet_uri) raise Errors::SnippetNotFound.new("#{snippet_name} nout found") end end |