dirt 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +22 -0
- data/Gemfile.lock +91 -0
- data/MIT-LICENSE +23 -0
- data/README.md +150 -0
- data/core/contexts/commit_git_repository.rb +56 -0
- data/core/contexts/create_basic_face.rb +60 -0
- data/core/contexts/create_default_structure.rb +57 -0
- data/core/contexts/create_git_repository.rb +45 -0
- data/core/contexts/roles/.gitkeep +0 -0
- data/core/contexts/roles/generating.rb +26 -0
- data/core/dirt.rb +14 -0
- data/core/models/.gitkeep +0 -0
- data/core/tests/behaviours/commit_files.feature +36 -0
- data/core/tests/behaviours/create_basic_face.feature +49 -0
- data/core/tests/behaviours/create_default_structure.feature +55 -0
- data/core/tests/behaviours/create_vcs_repository.feature +26 -0
- data/core/tests/behaviours/step_definitions/given.rb +18 -0
- data/core/tests/behaviours/step_definitions/then.rb +55 -0
- data/core/tests/behaviours/step_definitions/when.rb +21 -0
- data/core/tests/behaviours/support/env.rb +100 -0
- data/core/tests/behaviours/support/helpers.rb +21 -0
- data/core/tests/factories.rb +23 -0
- data/core/version.rb +3 -0
- data/faces/cli/bin/dirt +6 -0
- data/faces/cli/integrations/generate_context.feature +40 -0
- data/faces/cli/integrations/generate_face.feature +53 -0
- data/faces/cli/integrations/generate_model.feature +11 -0
- data/faces/cli/integrations/generate_project.feature +143 -0
- data/faces/cli/integrations/generate_role.feature +12 -0
- data/faces/cli/integrations/step_definitions/given.rb +16 -0
- data/faces/cli/integrations/step_definitions/then.rb +48 -0
- data/faces/cli/integrations/step_definitions/when.rb +28 -0
- data/faces/cli/integrations/support/env.rb +21 -0
- data/faces/cli/optparse/main.rb +143 -0
- data/faces/cli/thor/.gitkeep +0 -0
- data/templates/faces/web/template.helpers.rb +4 -0
- data/templates/template.Gemfile +18 -0
- data/templates/template.env.rb +13 -0
- data/templates/template.gitignore +21 -0
- data/templates/template.project_name.rb +14 -0
- metadata +104 -0
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'dirt-core', '~> 2.2.1', git: 'git://github.com/TenjinInc/dirt-core.git'
|
4
|
+
gem 'activesupport'
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'simplecov'
|
8
|
+
end
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec', '~> 2.14.1'
|
12
|
+
gem 'cucumber'
|
13
|
+
gem 'capybara'
|
14
|
+
gem 'launchy'
|
15
|
+
|
16
|
+
gem 'fakefs'
|
17
|
+
|
18
|
+
gem 'aruba-doubles'
|
19
|
+
|
20
|
+
gem 'factory_girl', '~> 4.0'
|
21
|
+
gem 'parallel_tests'
|
22
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/TenjinInc/dirt-core.git
|
3
|
+
revision: 3fe12bced8addd1d2b09a9bd35aef4b469f5e99e
|
4
|
+
specs:
|
5
|
+
dirt-core (2.2.2)
|
6
|
+
activesupport (>= 3.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (4.1.5)
|
12
|
+
i18n (~> 0.6, >= 0.6.9)
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
thread_safe (~> 0.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
addressable (2.3.6)
|
18
|
+
aruba-doubles (1.2.1)
|
19
|
+
cucumber (>= 1.0.2)
|
20
|
+
rspec (>= 2.6.0)
|
21
|
+
builder (3.2.2)
|
22
|
+
capybara (2.4.1)
|
23
|
+
mime-types (>= 1.16)
|
24
|
+
nokogiri (>= 1.3.3)
|
25
|
+
rack (>= 1.0.0)
|
26
|
+
rack-test (>= 0.5.4)
|
27
|
+
xpath (~> 2.0)
|
28
|
+
cucumber (1.3.16)
|
29
|
+
builder (>= 2.1.2)
|
30
|
+
diff-lcs (>= 1.1.3)
|
31
|
+
gherkin (~> 2.12)
|
32
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
|
+
multi_test (>= 0.1.1)
|
34
|
+
diff-lcs (1.2.5)
|
35
|
+
docile (1.1.5)
|
36
|
+
factory_girl (4.4.0)
|
37
|
+
activesupport (>= 3.0.0)
|
38
|
+
fakefs (0.5.2)
|
39
|
+
gherkin (2.12.2)
|
40
|
+
multi_json (~> 1.3)
|
41
|
+
i18n (0.6.11)
|
42
|
+
json (1.8.1)
|
43
|
+
launchy (2.4.2)
|
44
|
+
addressable (~> 2.3)
|
45
|
+
mime-types (2.3)
|
46
|
+
mini_portile (0.6.0)
|
47
|
+
minitest (5.4.0)
|
48
|
+
multi_json (1.10.1)
|
49
|
+
multi_test (0.1.1)
|
50
|
+
nokogiri (1.6.3.1)
|
51
|
+
mini_portile (= 0.6.0)
|
52
|
+
parallel (1.2.4)
|
53
|
+
parallel_tests (1.0.5)
|
54
|
+
parallel
|
55
|
+
rack (1.5.2)
|
56
|
+
rack-test (0.6.2)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rspec (2.14.1)
|
59
|
+
rspec-core (~> 2.14.0)
|
60
|
+
rspec-expectations (~> 2.14.0)
|
61
|
+
rspec-mocks (~> 2.14.0)
|
62
|
+
rspec-core (2.14.8)
|
63
|
+
rspec-expectations (2.14.5)
|
64
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
65
|
+
rspec-mocks (2.14.6)
|
66
|
+
simplecov (0.9.0)
|
67
|
+
docile (~> 1.1.0)
|
68
|
+
multi_json
|
69
|
+
simplecov-html (~> 0.8.0)
|
70
|
+
simplecov-html (0.8.0)
|
71
|
+
thread_safe (0.3.4)
|
72
|
+
tzinfo (1.2.2)
|
73
|
+
thread_safe (~> 0.1)
|
74
|
+
xpath (2.0.0)
|
75
|
+
nokogiri (~> 1.3)
|
76
|
+
|
77
|
+
PLATFORMS
|
78
|
+
ruby
|
79
|
+
|
80
|
+
DEPENDENCIES
|
81
|
+
activesupport
|
82
|
+
aruba-doubles
|
83
|
+
capybara
|
84
|
+
cucumber
|
85
|
+
dirt-core (~> 2.2.1)!
|
86
|
+
factory_girl (~> 4.0)
|
87
|
+
fakefs
|
88
|
+
launchy
|
89
|
+
parallel_tests
|
90
|
+
rspec (~> 2.14.1)
|
91
|
+
simplecov
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Tenjin Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
data/README.md
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
#Dirt
|
2
|
+
Make best practices easy. Come play in the Dirt.
|
3
|
+
|
4
|
+
##Why Dirt
|
5
|
+
Good design is when the easiest usage and the correct usage are one in the same.
|
6
|
+
|
7
|
+
Best practices, however, are often an extra effort; many require configuration every time you start a new project.
|
8
|
+
Newbies are too busy learning to put in that effort and that quickly develops into bad habits.
|
9
|
+
Masters find best practices useful, but routine and boring. So we asked ourselves:
|
10
|
+
|
11
|
+
> What if there was a tool to make best practices simple or even automatic?
|
12
|
+
|
13
|
+
Dirt is the answer to this question.
|
14
|
+
|
15
|
+
It exists because we wanted a toolset to automatically set us up for:
|
16
|
+
- Behaviour Driven Development (BDD)
|
17
|
+
- User Story Orientation
|
18
|
+
- A simple, standard project directory structure
|
19
|
+
- Clear separation of concerns - thin views, thin persistence, thick core.
|
20
|
+
- Use of modern version control systems
|
21
|
+
- Code analysis & metrics.
|
22
|
+
|
23
|
+
**That's the goal of Dirt: make best practices dead easy.**
|
24
|
+
|
25
|
+
##Features
|
26
|
+
This is what Dirt gets you right now:
|
27
|
+
|
28
|
+
- **Helpful defaults** Logical directory tree and some useful default meta files
|
29
|
+
|
30
|
+
- **Versioning** Start with a git repository initialized, a populated .gitignore, and all default files already committed.
|
31
|
+
|
32
|
+
- **Ready BDD** Working [Cucumber](https://github.com/cucumber/cucumber) test environments and a default Gemfile to support them.
|
33
|
+
|
34
|
+
- **Undead resistance +3** Great for those pesky lich infestations.
|
35
|
+
|
36
|
+
###Roadmap
|
37
|
+
This is where we're headed. If you want to help make it a reality, get in touch!
|
38
|
+
|
39
|
+
- **Face Generation** Web, CLI, and simple mobile. All including integration tests to justify their existence.
|
40
|
+
- **VCS independence** Written around Git right now, other VCSes should be supported, especially distributed ones.
|
41
|
+
- **Project Diffing** Wouldn't it be nice to know what in your project is different form the standards, or the templates?
|
42
|
+
- **Architectural linting** Core files should only depend on core files.
|
43
|
+
- **Licence Injection** Applying the licence to all source files should be easy, and optional.
|
44
|
+
- **Simple installation** The language and Dirt should just work out of the box.
|
45
|
+
- **Multilingual Support** These concepts aren't Ruby specific. They can easily apply to any modern language. Where [Cucumber](https://github.com/cucumber/cucumber) and [Gherkin](https://github.com/cucumber/cucumber/wiki/Gherkin) go, Dirt may follow.
|
46
|
+
- ... Plus some other experimental ideas that BDD enable
|
47
|
+
|
48
|
+
## Prerequisites
|
49
|
+
Dirt requires [linux or unix](http://www.ubuntu.com/), [git](http://git-scm.com/book/en/v2/Getting-Started-Installing-Git), and [ruby](https://www.ruby-lang.org/en/documentation/installation/).
|
50
|
+
|
51
|
+
##Usage
|
52
|
+
|
53
|
+
###Project Generation
|
54
|
+
|
55
|
+
Generating a project will give you a project directory that looks like:
|
56
|
+
|
57
|
+
```
|
58
|
+
core/
|
59
|
+
├─── contexts/
|
60
|
+
│ └─────── roles/
|
61
|
+
├── models/
|
62
|
+
├── tests/
|
63
|
+
│ ├──── behaviours/
|
64
|
+
│ │ ├───────── step_definitions/
|
65
|
+
│ │ │ ├── given.rb
|
66
|
+
│ │ │ ├── then.rb
|
67
|
+
│ │ │ └── when.rb
|
68
|
+
│ │ └───────── support/
|
69
|
+
│ │ └────── env.rb
|
70
|
+
│ └───── isolations/
|
71
|
+
└── example_project.rb
|
72
|
+
faces/
|
73
|
+
persist/
|
74
|
+
Gemfile
|
75
|
+
.gitignore
|
76
|
+
```
|
77
|
+
|
78
|
+
We'll take a look at a couple of scenarios first: remote host and local host.
|
79
|
+
|
80
|
+
*First, a note about git and dirt*
|
81
|
+
Usually, git stores history information in a .git file within your project directory. You can make a *bare* that is a
|
82
|
+
folder with just the history information, and no actual project files. Then, you can point multiple regular git
|
83
|
+
repository's to the bare, and it can act as a shared history.
|
84
|
+
|
85
|
+
Dirt has two intended modes: having a git bare on a remote machine, or on your local machine.
|
86
|
+
|
87
|
+
####Remote Bare Host
|
88
|
+
Intended for teams, this scenario will not only create a local project and git repository, but will also create a
|
89
|
+
Git bare in a remote location.
|
90
|
+
```
|
91
|
+
dirt generate project --name PROJECT_NAME --location PATH --host HOST_NAME --bare-path PATH
|
92
|
+
```
|
93
|
+
|
94
|
+
*Example*
|
95
|
+
We would like a new project:
|
96
|
+
- called "*Our Project*"
|
97
|
+
- saved in `~/projects/our_project`
|
98
|
+
- with a git bare repository saved on a machine called *dresden*, and in `/var/git/our_project.git`
|
99
|
+
|
100
|
+
So we'd use:
|
101
|
+
|
102
|
+
```
|
103
|
+
dirt generate project --name "Our Project" --location ~/projects/ --host dresden --bare-path /var/git/
|
104
|
+
```
|
105
|
+
|
106
|
+
####Local Bare Host
|
107
|
+
Even if you're building solo, you should have a bare repository to act as a sort of backup. Besides, you never know if you'll gain
|
108
|
+
teammates, and having a bare ready to copy to a remote machine is very handy.
|
109
|
+
|
110
|
+
This is a lot like the remote machine scenario above, but we don't need to provide the `--host` or `--bare-path`.
|
111
|
+
|
112
|
+
```
|
113
|
+
dirt generate project --name PROJECT_NAME --location PATH
|
114
|
+
```
|
115
|
+
|
116
|
+
*Example*
|
117
|
+
To have a new project called "*My New Project*" in `~/projects/my_new_project`, use:
|
118
|
+
|
119
|
+
```
|
120
|
+
dirt generate project --name "My New Project" --location ~/projects/
|
121
|
+
```
|
122
|
+
|
123
|
+
#### Full Listing
|
124
|
+
```
|
125
|
+
dirt generate [options]
|
126
|
+
```
|
127
|
+
|
128
|
+
This is the full listing of generation flags.
|
129
|
+
|
130
|
+
| Flag | Default Value | Description |
|
131
|
+
| ---------------------- | ----------------- | ---------------------------------------------------------------------------------- |
|
132
|
+
| `-n, --name NAME` | | The human-readable name of the new project. Put it in quotes if you want spaces. |
|
133
|
+
| `-l, --location PATH` | *Current directory* | The **parent** directory of the new project on the local machine. |
|
134
|
+
| `-h, --host ADDRESS` | `localhost` | The IP address or hostname of the machine where the bare repository will be kept. |
|
135
|
+
| `-b, --bare-path PATH` | n/a | The **parent** directory of the new git bare on the host machine. _See also:_ `--host` |
|
136
|
+
| `-u, --user NAME` | *Your username* | The username to be used to log into the host device. _See also:_ `--host` |
|
137
|
+
|
138
|
+
##Template variables
|
139
|
+
In the template files, there are some times that you need dynamic data insertion.
|
140
|
+
|
141
|
+
These are the variables accessible to the template engine. Any instance of these tags will be replaced by the appropriate data.
|
142
|
+
|
143
|
+
| Tag | Description | Default Value | Example |
|
144
|
+
| --------------------- | ----------------------------------------------------- | -------------------------- | ------------- |
|
145
|
+
| `<project_name>` | The human-readable name of the project. | | My Project |
|
146
|
+
| `<project_directory>` | The snake-case name of the project. | | my_project |
|
147
|
+
| `<project_module>` | The module name of the project. | | MyProject |
|
148
|
+
| `<ruby_version>` | The version of ruby that your project should support. | `ruby --version` | 1.9.3 |
|
149
|
+
| `<user_name>` | The name of the user running dirt. | _your name_ | Bob Guardian |
|
150
|
+
| `<user_website>` | The website to be associated with the project. | | www.tenjin.ca |
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Tenjin Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Samling
|
25
|
+
class CommitGitRepository < Dirt::Context
|
26
|
+
def initialize(project_path)
|
27
|
+
@project_path = Pathname.new(project_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def call
|
31
|
+
empty_dirs = Dir["#{@project_path}/**/*"].select do |d|
|
32
|
+
Dir.entries(d) == ['.', '..'] if File.directory?(d)
|
33
|
+
end
|
34
|
+
|
35
|
+
empty_dirs.each do |dir|
|
36
|
+
path = Pathname.new(dir) + '.gitkeep'
|
37
|
+
|
38
|
+
path.dirname.mkpath
|
39
|
+
FileUtils.touch(path)
|
40
|
+
end
|
41
|
+
|
42
|
+
Dir.glob("#{@project_path}/**/*", File::FNM_DOTMATCH).select do |f|
|
43
|
+
path = Pathname.new(f)
|
44
|
+
path.file? && !path.to_s.include?('/.git/')
|
45
|
+
end.each { |f| system(%Q{git --git-dir "#{@project_path}/.git" --work-tree "#{@project_path}" add -v "#{f}"}) }
|
46
|
+
|
47
|
+
system(%Q{git --git-dir "#{@project_path}/.git" --work-tree "#{@project_path}" commit -am "Project init with Dirt."})
|
48
|
+
|
49
|
+
system(%Q{git --git-dir "#{@project_path}/.git" --work-tree "#{@project_path}" push origin master})
|
50
|
+
|
51
|
+
'Comitting and pushing...'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Tenjin Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Samling
|
25
|
+
class CreateBasicFace < Dirt::Context
|
26
|
+
def initialize(root_path, face_name)
|
27
|
+
@root_path = Pathname.new(root_path)
|
28
|
+
@face_root = Pathname.new('faces') + face_name
|
29
|
+
end
|
30
|
+
|
31
|
+
def call
|
32
|
+
dirs = %w{integrations/support
|
33
|
+
integrations/step_definitions}
|
34
|
+
|
35
|
+
dirs.each do |f|
|
36
|
+
FileUtils.mkdir_p(@root_path + @face_root + f)
|
37
|
+
end
|
38
|
+
|
39
|
+
files_to_templates = {(@face_root + 'integrations/support/env.rb').to_s => 'template.env.rb'}
|
40
|
+
|
41
|
+
# this isn't a great way to find the dir, but at the time of writing, there isn't a nicer one -remiller
|
42
|
+
# templates_dir = Pathname.new(__FILE__).dirname
|
43
|
+
|
44
|
+
# files_to_templates.each do |f, t|
|
45
|
+
# File.open((@face_root + f).to_s, 'w') do |file|
|
46
|
+
# specified_content = File.read(Pathname.new('persist/templates/' + t).to_s)
|
47
|
+
# specified_content.gsub!('<project_name>', @root_path.basename.to_s)
|
48
|
+
#
|
49
|
+
# file.write(specified_content)
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
|
53
|
+
Generating.new(files_to_templates).generate_templates(@root_path)
|
54
|
+
|
55
|
+
FileUtils.touch((@root_path + @face_root + 'integrations/step_definitions/given.rb').to_s)
|
56
|
+
FileUtils.touch((@root_path + @face_root + 'integrations/step_definitions/when.rb').to_s)
|
57
|
+
FileUtils.touch((@root_path + @face_root + 'integrations/step_definitions/then.rb').to_s)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2014 Tenjin Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
module Samling
|
25
|
+
class CreateDefaultStructure < Dirt::Context
|
26
|
+
def initialize(project_path)
|
27
|
+
@project_root = Pathname.new(project_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def call
|
31
|
+
FileUtils.mkdir_p(@project_root)
|
32
|
+
|
33
|
+
dirs = %w{core/contexts
|
34
|
+
core/contexts/roles
|
35
|
+
core/models
|
36
|
+
core/tests/isolations
|
37
|
+
faces
|
38
|
+
persist}
|
39
|
+
|
40
|
+
dirs.each do |path|
|
41
|
+
FileUtils.mkdir_p(@project_root + path)
|
42
|
+
end
|
43
|
+
|
44
|
+
files_to_templates = {'.gitignore' => 'template.gitignore',
|
45
|
+
'Gemfile' => 'template.Gemfile',
|
46
|
+
"core/project_name.rb" => 'template.project_name.rb',
|
47
|
+
'core/tests/behaviours/support/env.rb' => 'template.env.rb',
|
48
|
+
'core/tests/behaviours/step_definitions/given.rb' => nil,
|
49
|
+
'core/tests/behaviours/step_definitions/when.rb' => nil,
|
50
|
+
'core/tests/behaviours/step_definitions/then.rb' => nil}
|
51
|
+
|
52
|
+
Generating.new(files_to_templates).generate_templates(@project_root)
|
53
|
+
|
54
|
+
"Created project structure in #{@project_root.to_s}."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|