README.md in decanter-0.6.3 vs README.md in decanter-0.7.0

- old
+ new

@@ -21,29 +21,18 @@ ``` bundle ``` -Add the following to application.rb so we can load your decanters properly: - -``` -config.paths.add "app/decanter", eager_load: true -config.to_prepare do - Dir[ File.expand_path(Rails.root.join("app/decanter/**/*.rb")) ].each do |file| - require_dependency file - end -end -``` - Basic Usage --- ``` rails g decanter Trip name:string start_date:date end_date:date ``` -**app/decanter/decanters/trip_decanter.rb** +**app/decanters/trip_decanter.rb** ```ruby class TripDecanter < Decanter::Base input :name, :string input :start_date, :date @@ -135,11 +124,11 @@ ``` rails g decanter Trip name:string start_date:date end_date:date ``` -Which generates app/decanter/decanters/trip_decanter.rb: +Which generates app/decanters/trip_decanter.rb: ```ruby class TripDecanter < Decanter::Base input :name, :string input :start_date, :date @@ -189,11 +178,11 @@ ```allow Date``` basically tells Decanter that if the value comes in as a Date object, we don't need to parse it at all. Other than that, the parser is really just doing ```Date.strptime("01/15/2015", '%m/%d/%Y')```, which is just a vanilla date parse. You'll notice that the above ```parser do``` block takes a ```:parse_format``` option. This allows you to specify the format your date string will come in. For example, if you expect "2016-01-15" instead of "01/15/2016", you can adjust the TripDecanter like so: ```ruby -# app/decanter/decanters/trip_decanter.rb +# app/decanters/trip_decanter.rb class TripDecanter < Decanter::Base input :name, :string input :start_date, :date, parse_format: '%Y-%m-%d' input :end_date, :date, parse_format: '%Y-%m-%d' @@ -204,11 +193,11 @@ ``` rails g parser Date ``` -**app/decanter/parsers/date_parser** +**lib/decanter/parsers/date_parser** ```ruby class DateParser < Decanter::ValueParser::Base parser do |name, value, options| # your parsing logic here @@ -243,11 +232,11 @@ ``` rails g decanter Trip name destinations:has_many rails g decanter Destination city state arrival_date:date departure_date:date ``` -Which produces app/decanter/decanters/trip and app/decanter/decanters/destination: +Which produces app/decanters/trip and app/decanters/destination: ```ruby class TripDecanter < Decanter::Base input :name, :string has_many :destinations @@ -291,11 +280,11 @@ ``` rails g decanter SearchFilter start_date:date end_date:date city:string state:string ``` ```ruby -# app/decanter/decanters/search_filter_decanter.rb +# app/decanters/search_filter_decanter.rb class SearchFilterDecanter < Decanter::Base end ``` @@ -344,10 +333,10 @@ ``` rails g parser SquashDate ``` ```ruby -# app/decanter/squashers/date_squasher.rb +# lib/decanter/parsers/squash_date_parser.rb class SquashDateParser < Decanter::Parser::Base parser do |name, values, options| day, month, year = values.map(&:to_i) Date.new(year, month, day)