README.md in canpe-0.1.0 vs README.md in canpe-0.1.1
- old
+ new
@@ -10,14 +10,33 @@
When run the `canpe create sample_repository`, canpe initialize new repo in the current directory.
```
$ canpe create sample_repository
-create directory: ./.canpe_repos/sample_repository/templates
-copy ./.canpe_repos/sample_repository/binding.yml
+
+create directory: /Users/Yoshinori/.canpe_repos
+create directory: /Users/Yoshinori/.canpe_repos/sample_repository
+copy: /Users/Yoshinori/.canpe_repos/sample_repository/binding.yml
+create directory: /Users/Yoshinori/.canpe_repos/sample_repository/templates
+copy: /Users/Yoshinori/.canpe_repos/sample_repository/templates/sample.html.erb
```
+Each repository has `templates` directory, and `binding.yml`.
+
+```
+$ tree .canpe_repos
+
+.canpe_repos
+`-- sample_repository
+ |-- binding.yml
+ `-- templates
+ `-- sample.html.erb
+
+2 directories, 2 files
+
+```
+
`binding.yml` defines the variables which you can access from templates.
```
variables:
- name: sample_string
@@ -26,43 +45,54 @@
type: array
```
Set your template files under the templates directory.
Each file is automatically evaluated as ERB template.
+And you can access variables via `canpe` object.
```
+$ cat .canpe_repos/sample_repository/templates/sample.html.erb
+
<%= canpe[:sample_string] %>
<%= canpe[:sample_array].join ', ' %>
```
-Then run `canpe generate sample_repository`.
+To generate files from repository, you can use `canpe generate` command.
```
-$ bundle exec bin/canpe generate sample_repository
-working directory (/Users/Yoshinori/gem_projects/canpe) ?
+$ canpe generate sample_repository
+
+working directory (/Users/Yoshinori) ?
you need to set variables to generate codes!
1: sample_string (string)
2: sample_array (array)
-
+
If you want to stop setting array, let it blank and press enter.
sample_string ?) Hello, world
sample_array[0] ?) 1
sample_array[1] ?) 2
sample_array[2] ?) 3
sample_array[3] ?)
finished variable settings: {"sample_string"=>"Hello, world", "sample_array"=>["1", "2", "3"]}
-copy: /Users/Yoshinori/gem_projects/canpe/hello
-
+copy: /Users/Yoshinori/sample.html.erb
+
+$ cat sample.html.erb
+Hello, world
+1, 2, 3
```
-If you set sample_string as 'Hello, world', and sample_array as [1, 2, 3],
-This template is rendered like this.
+You can list up registered repositories.
```
-Hello, world
-1, 2, 3
+Yoshinori@ykosaka-MacBook-Pro:~$ canpe list
+HOME::sample_repository
+.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/canpe-0.1.0::default_repository
```
+## Advanced Usage
+
+File name is also evaluated as ERB.
+look at `.canpe_repos/default_repository/<%= canpe[:repository_name] %>` in this repository.
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.