Sha256: 6465e450418491a4b0b45a1f2b772d85d1825cf2dd14db3eef761d74597e24fa

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

require 'ostruct'
require 'csv'

require 'flextures/flextures_base_config'
require 'flextures/flextures'
require 'flextures/flextures_factory'

module Flextures
  module Rake
    module Command
      def self.dump
        Flextures::load_configurations
        table_names = Flextures::ARGS.parse(ENV)
        puts "dumping..."
        case ENV["FORMAT"].to_s.to_sym
        when :yml,:yaml
          table_names.map { |fmt| Flextures::Dumper::yml(fmt) }
        when :csv
          table_names.map { |fmt| Flextures::Dumper::csv(fmt) }
        else
          table_names.map { |fmt| Flextures::Dumper::csv(fmt) }
        end
      end

      def self.load
        Flextures::load_configurations
        table_names = Flextures::ARGS.parse(ENV)
        Flextures::init_tables unless ENV["T"] or ENV["TABLE"] or ENV["M"] or ENV["MODEL"] or ENV["F"] or ENV["FIXTUES"]
        file_format = ENV["FORMAT"]
        puts "loading..."
        case file_format.to_s.to_sym
        when :csv
          table_names.map { |fmt| Flextures::Loader::csv(fmt) }
        when :yml
          table_names.map { |fmt| Flextures::Loader::yml(fmt) }
        else
          table_names.map { |fmt| Flextures::Loader::load(fmt) }
        end
      end

      # load and dump data
      def self.generate
        Flextures::load_configurations
        table_names = Flextures::ARGS.parse(ENV)
        Flextures::init_tables unless ENV["T"] or ENV["TABLE"] or ENV["M"] or ENV["MODEL"] or ENV["F"] or ENV["FIXTUES"]
        file_format = ENV["FORMAT"]
        puts "generating..."
        case file_format.to_s.to_sym
        when :yml
          table_names.map { |fmt| Flextures::Loader::yml(fmt); Flextures::Dumper::yml(fmt) }
        when :csv
          table_names.map { |fmt| Flextures::Loader::csv(fmt); Flextures::Dumper::csv(fmt) }
        else
          table_names.map { |fmt| Flextures::Loader::csv(fmt); Flextures::Dumper::csv(fmt) }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flextures-4.2.2 lib/flextures/flextures_command.rb
flextures-4.2.0 lib/flextures/flextures_command.rb
flextures-4.1.0 lib/flextures/flextures_command.rb