Skip to content

Commit

Permalink
オリジナル言語を作る : Domain-Specific Languages #86
Browse files Browse the repository at this point in the history
・16.3 データファイル? いいえ、プログラムです!

EFROR-73
  • Loading branch information
k2works committed Aug 29, 2017
1 parent 0e45887 commit b75f86f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/domains/design_pattern/dsl/backup.pr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
ex = DesignPattern::Interpreter::Expression.new

backup 'spec/domains/dsl/data'
backup 'spec/domains/dsl/data/music', file_name('*.mp3' & file_name('*.wav')
backup 'spec/domains/dsl/data/images', except(file_name('*.tmp'))
backup 'spec/domains/dsl/data/music', ex.name('*.mp3') & ex.name('*.wav')
backup 'spec/domains/dsl/data/images', ex.except(ex.name('*.tmp'))
to 'spec/domains/dsl/backup'
interval 60
22 changes: 22 additions & 0 deletions app/domains/design_pattern/dsl/packrat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require_relative '../../../../app/domains/design_pattern/interpreter/expression.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/all.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/and.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/bigger.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/file_name.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/not.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/or.rb'
require_relative '../../../../app/domains/design_pattern/interpreter/writable.rb'

def backup(dir, find_expression= DesignPattern::Interpreter::All.new)
puts "Backup called, source dir=#{dir} find expr=#{find_expression}"
end

def to(backup_directory)
puts "To called, backup dir=#{backup_directory}"
end

def interval(minutes)
puts "Interval called, interval = #{minutes} minutes"
end

eval(File.read('backup.pr'))
5 changes: 5 additions & 0 deletions spec/domains/design_pattern/dsl/backup_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

describe DesignPattern::DSL::Backup do

end

0 comments on commit b75f86f

Please sign in to comment.