Skip to content

Commit

Permalink
Merge pull request #12 from onigra/change_build_html_path
Browse files Browse the repository at this point in the history
Change build html path
  • Loading branch information
onigra committed Feb 23, 2016
2 parents 48b5cda + 39c94f1 commit 714738a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Create awesome_project project
```sh
$ pln build -n awesome_project

Generate awesome_project/base.html
Generate awesome_project/base/index.html
```

#### divide
Expand Down
7 changes: 6 additions & 1 deletion lib/planaria/generator/builder/executer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ def run
instance_variable_set("@#{k}", v)
end

::File.open "./#{@name}/#{file_name}.html", "w" do |file|
create_directory file_name
::File.open "./#{@name}/#{file_name}/index.html", "w" do |file|
file.write erb.result(binding)
end
end
Expand All @@ -29,6 +30,10 @@ def yaml_files
def erb
::ERB.new(File.read "./#{@name}/html/index.html.erb")
end

def create_directory(file_name)
FileUtils.mkdir_p "./#{@name}/#{file_name}"
end
end
end
end
2 changes: 1 addition & 1 deletion lib/planaria/generator/builder/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(name)

def run
@executer.yaml_files.each do |file|
puts "Generate #{@name}/#{file.split("/").last.split(".").first}.html"
puts "Generate #{@name}/#{file.split("/").last.split(".").first}/index.html"
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/planaria/generator/builder/executer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

after { FileUtils.remove_dir "#{APP_ROOT}/#{project_name}", force: true }

it { expect(File.read "#{APP_ROOT}/#{project_name}/base.html").to eq assert_html }
it { expect(File.read "#{APP_ROOT}/#{project_name}/base/index.html").to eq assert_html }
end

context "en.yml, ja.yml" do
Expand Down Expand Up @@ -101,15 +101,15 @@

it "exists two files" do
aggregate_failures do
expect(File.exist?("#{APP_ROOT}/#{project_name}/en.html")).to be_truthy
expect(File.exist?("#{APP_ROOT}/#{project_name}/ja.html")).to be_truthy
expect(File.exist?("#{APP_ROOT}/#{project_name}/en/index.html")).to be_truthy
expect(File.exist?("#{APP_ROOT}/#{project_name}/ja/index.html")).to be_truthy
end
end

it "title is different" do
aggregate_failures do
expect(File.read "#{APP_ROOT}/#{project_name}/ja.html").to eq ja_html
expect(File.read "#{APP_ROOT}/#{project_name}/en.html").to eq en_html
expect(File.read "#{APP_ROOT}/#{project_name}/ja/index.html").to eq ja_html
expect(File.read "#{APP_ROOT}/#{project_name}/en/index.html").to eq en_html
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/planaria/generator/builder/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
describe "#run" do
let(:message) do
<<-EOS
Generate #{project}/cn.html
Generate #{project}/en.html
Generate #{project}/ja.html
Generate #{project}/cn/index.html
Generate #{project}/en/index.html
Generate #{project}/ja/index.html
EOS
end

Expand Down
4 changes: 2 additions & 2 deletions spec/planaria/generator/builder/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

let(:message) do
<<-EOS
Generate #{project}/base.html
Generate #{project}/base/index.html
EOS
end

it do
expect { described_class.new(project).run }.to output(message).to_stdout
expect(File.exist?("#{APP_ROOT}/#{project}/base.html")).to be_truthy
expect(File.exist?("#{APP_ROOT}/#{project}/base/index.html")).to be_truthy
end
end

Expand Down

0 comments on commit 714738a

Please sign in to comment.