Class: Codestrap::Object::Standard::Files
- Defined in:
- lib/codestrap/object/standard/files.rb
Overview
Static file derived objects
Create objects from .json, .yaml and executable files
Class Method Summary collapse
- .objects ⇒ Object
-
.weight ⇒ Integer
Object(s) weight.
Class Method Details
.objects ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/codestrap/object/standard/files.rb', line 17 def objects objects = {} glob_array = Array(Files.dirs).map { |file| File.join(File.(file), '*') } Codestrap::Patch::Dir.glob_files(glob_array).each do |file| stat = File::Stat.new file name = File.basename(file, File.extname(file)).downcase case when /\.json$/.match(file) objects[name] = JSON.load(File.read(file)) when /\.yaml$/.match(file) objects[name] = YAML.load(File.read(file)) when stat.executable? objects[name] = JSON.parse(`#{file}`) end end objects end |
.weight ⇒ Integer
Object(s) weight
13 14 15 |
# File 'lib/codestrap/object/standard/files.rb', line 13 def weight 100 end |