Sha256: f080a0d6927e4bd87b8c40adb17c881bac6aa0f77dd3137d03fea46f3cba4848
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
require 'fileutils' require_relative "base_generator" require "erb" require "find" module RoCommands module Generators class Ex include BaseGenerator class << self def create FileUtils.mkpath dir tt dir end private def dir @dir ||= 'ex' end def list Dir[File.join(dir, '**')] end def oldest_file Dir['ex/**'].sort_by do |f| Time.at(File.atime f).to_f end.map do |f| File.basename f end.first end def file len = list.length if len > 0 and len < 10 num = list.map do |file| result = File.basename(file).match(%r{ex(\d+).*}) result ? result[1].to_i : 0 end.max num += 1 unless num.nil? filename = "ex#{num}.rb" elsif len == 0 'ex.rb' else File.basename oldest_file end end def to super File.write(path, ctn) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ro_commands-0.0.3 | lib/ro_commands/generators/ex.rb |
ro_commands-0.0.2 | lib/ro_commands/generators/ex.rb |
ro_commands-0.0.1 | lib/ro_commands/generators/ex.rb |