Sha256: 257ac0e7edd176b72f713a2eb904a0b47f8b3ccaaa16f64772c5be5b6c00b573

Contents?: true

Size: 807 Bytes

Versions: 5

Compression:

Stored size: 807 Bytes

Contents

require 'thor/group'
require 'csv'
module Proptax
  module Generators
    class Report < Thor::Group
      include Thor::Actions
      attr_accessor :address, :assessed_value, :y_axis_limits

      argument :csv_file, :type => :string
      argument :opts

      def create_report_dir
        empty_directory('reports')
        FileUtils.cp(csv_file, "reports")
      end

      def copy_report_template
        CSV.foreach(csv_file, headers: true) do |row|
          self.address = row['Location Address']
          self.assessed_value = row['Current Assessed Value']
          file_name = address.gsub(/\s/, '_')
          template("#{opts.template}.Rmd", "reports/#{file_name}.Rmd")
        end
      end

      def self.source_root
        File.dirname(__FILE__) + "/report"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
proptax-0.1.0 lib/proptax/generators/report.rb
proptax-0.0.4 lib/proptax/generators/report.rb
proptax-0.0.3 lib/proptax/generators/report.rb
proptax-0.0.2 lib/proptax/generators/report.rb
proptax-0.0.1 lib/proptax/generators/report.rb