testcloud-generator 0.0.0.3 → 0.0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +3 -0
- data/.travis.yml +10 -0
- data/Gemfile +9 -0
- data/README.md +13 -13
- data/Rakefile +7 -0
- data/bin/console +7 -0
- data/bin/rspec +16 -0
- data/lib/testcloud/generator.rb +3 -0
- data/lib/testcloud/generator/cli.rb +6 -0
- data/lib/testcloud/generator/commands.rb +1 -0
- data/lib/testcloud/generator/commands/gem.rb +4 -0
- data/lib/testcloud/generator/commands/use_case.rb +72 -0
- data/lib/testcloud/generator/gem_version.rb +1 -1
- data/lib/testcloud/generator/templates/newgem/README.md.tt +17 -0
- data/lib/testcloud/generator/templates/use_case/new_params.rb.tt +8 -0
- data/lib/testcloud/generator/templates/use_case/new_use_case.rb.tt +17 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/testcloud/generator/cli_spec.rb +17 -0
- data/testcloud-generator.gemspec +1 -0
- metadata +27 -4
- data/lib/testcloud/generator/commands/.gem.rb.swp +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a7c47e521f766163e9a5bfe3b51136b3405982f
|
4
|
+
data.tar.gz: 735dda8c7949b2d8d8e37b12f21115c917106406
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5797af65dab73a1a95276b2eb1efde09e94e551b67f145e94a82b6a80ffc361f82672de0a2f3873b6c6d3d1012bac63e259c62e631a29c3909db6cf2faa11d6e
|
7
|
+
data.tar.gz: c65f5849dce6bd4a9b9c476784d9a98a0961326c445ac751dc82223e6f9f5746cf1d8bb4a1bb801bbd8bcf3e1fc4347460c341c1f869de73868d893fa4f92b39
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
+
[](https://travis-ci.org/testCloud/testcloud-generator)
|
2
|
+
|
1
3
|
# Testcloud::Generator
|
2
4
|
|
3
|
-
|
5
|
+
Generators for speeding up repetitive tasks during development.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Just install the generator globally for your ruby version.
|
8
10
|
|
9
|
-
```
|
10
|
-
gem
|
11
|
+
```bash
|
12
|
+
gem install testcloud-generator
|
11
13
|
```
|
12
14
|
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install testcloud-generator
|
20
|
-
|
21
15
|
## Usage
|
22
16
|
|
23
|
-
|
17
|
+
```bash
|
18
|
+
# generate a new testCloud gem, that requires cores models
|
19
|
+
testcloud_generator gem greeter --core
|
20
|
+
|
21
|
+
# generate a new UseCase for an existing gem
|
22
|
+
testclud_generator use_case SayHelloToGreeter
|
23
|
+
```
|
24
24
|
|
25
25
|
## Contributing
|
26
26
|
|
data/Rakefile
CHANGED
data/bin/console
ADDED
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/lib/testcloud/generator.rb
CHANGED
@@ -17,6 +17,12 @@ module Testcloud
|
|
17
17
|
@command.run
|
18
18
|
end
|
19
19
|
|
20
|
+
desc 'use_case NAME', 'create a new use case'
|
21
|
+
def use_case(name)
|
22
|
+
@command = Testcloud::Generator::Commands::UseCase.new(options.merge(name: name), self)
|
23
|
+
@command.run
|
24
|
+
end
|
25
|
+
|
20
26
|
desc 'version', 'show the generator version'
|
21
27
|
def version()
|
22
28
|
require 'testcloud/generator/version'
|
@@ -41,7 +41,10 @@ module Testcloud
|
|
41
41
|
options = @template_options
|
42
42
|
|
43
43
|
templates = {
|
44
|
+
|
45
|
+
# generic files
|
44
46
|
'Gemfile.tt' => 'Gemfile',
|
47
|
+
'README.md.tt' => 'README.md',
|
45
48
|
'gitignore.tt' => '.gitignore',
|
46
49
|
'lib/newgem.rb.tt' => "lib/#{namespace_path}.rb",
|
47
50
|
'lib/newgem_shortcut.rb.tt' => "lib/#{underscore_name}.rb",
|
@@ -71,6 +74,7 @@ module Testcloud
|
|
71
74
|
# basic required files
|
72
75
|
thor.template('newgem/Gemfile.tt', File.join(target, "Gemfile"), options)
|
73
76
|
thor.template('newgem/LICENSE.txt', File.join(target, "LICENSE.txt"), options)
|
77
|
+
thor.template('newgem/README.md.tt', File.join(target, 'README.md'), options)
|
74
78
|
thor.template('newgem/newgem.gemspec.tt', gemspec_dest, options)
|
75
79
|
thor.template('newgem/lib/newgem.rb.tt', File.join(target, templates['lib/newgem.rb.tt']), options)
|
76
80
|
thor.template('newgem/lib/newgem_shortcut.rb.tt', File.join(target, templates['lib/newgem_shortcut.rb.tt']), options)
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Testcloud
|
2
|
+
module Generator
|
3
|
+
module Commands
|
4
|
+
class UseCase < Base
|
5
|
+
def execute_command
|
6
|
+
spec = find_gemspec_for(Dir.pwd)
|
7
|
+
spec_options = extract_options_from_gemspec(spec)
|
8
|
+
use_case_options = build_options_for_use_case(options)
|
9
|
+
target = File.join(Dir.pwd, 'lib', spec_options[:path_name])
|
10
|
+
puts target
|
11
|
+
|
12
|
+
@template_options = {
|
13
|
+
spec: spec_options,
|
14
|
+
use_case: use_case_options
|
15
|
+
}
|
16
|
+
|
17
|
+
options = @template_options
|
18
|
+
|
19
|
+
templates = {
|
20
|
+
'use_cases/new_use_case.rb.tt' => "use_cases/#{use_case_options[:underscore_name]}.rb",
|
21
|
+
'use_cases/new_params.rb.tt' => "params/#{use_case_options[:params_underscore_name]}.rb"
|
22
|
+
}
|
23
|
+
|
24
|
+
thor.template('use_case/new_use_case.rb.tt', File.join(target, templates['use_cases/new_use_case.rb.tt']), options)
|
25
|
+
thor.template('use_case/new_params.rb.tt', File.join(target, templates['use_cases/new_params.rb.tt']), options)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def find_gemspec_for(dir)
|
31
|
+
gemspec_file = Dir["#{dir}/*.gemspec"].first
|
32
|
+
::Gem::Specification.load(gemspec_file)
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_options_for_use_case(options)
|
36
|
+
use_case_name = options[:name]
|
37
|
+
klass_name = use_case_name.classify
|
38
|
+
constant_array = ['UseCases', klass_name]
|
39
|
+
constant_name = constant_array.join('::')
|
40
|
+
params_constant_array = ['Params', klass_name]
|
41
|
+
|
42
|
+
{
|
43
|
+
name: klass_name,
|
44
|
+
underscore_name: use_case_name.underscore,
|
45
|
+
constant_name: constant_name,
|
46
|
+
constant_array: constant_array,
|
47
|
+
params_name: klass_name,
|
48
|
+
params_underscore_name: use_case_name.underscore,
|
49
|
+
params_constant_name: params_constant_array.join('::'),
|
50
|
+
params_constant_array: params_constant_array
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def extract_options_from_gemspec(gemspec)
|
55
|
+
name = gemspec.name
|
56
|
+
underscore_name = name.tr('-','_')
|
57
|
+
path_name = name.tr('-', '/')
|
58
|
+
constant_name = name.split('-').map { |c| c[0..0].upcase + c[1..-1] }.join('::')
|
59
|
+
constant_array = constant_name.split('::')
|
60
|
+
|
61
|
+
{
|
62
|
+
name: name,
|
63
|
+
underscore_name: underscore_name,
|
64
|
+
path_name: path_name,
|
65
|
+
constant_name: constant_name,
|
66
|
+
constant_array: constant_array
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## <%= config['constant_name'].gsub('::', ' ') %>
|
2
|
+
|
3
|
+
#### About
|
4
|
+
|
5
|
+
TODO: Write why this gem exists.
|
6
|
+
|
7
|
+
#### Usage
|
8
|
+
|
9
|
+
TODO: Write up some usage examples.
|
10
|
+
|
11
|
+
#### Contributing
|
12
|
+
|
13
|
+
1. Fork it ( https://github.com/[my-github-username]/<%= config['name'] %>/fork )
|
14
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
15
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
16
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
17
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module <%= config[:spec][:constant_array].first %>
|
2
|
+
module <%= config[:spec][:constant_array].last %>
|
3
|
+
module UseCases
|
4
|
+
class <%= config[:use_case][:constant_array].last %> < Testcloud::UseCases::Base
|
5
|
+
register :<%= config[:spec][:name].split('-').last %>_<%= config[:use_case][:underscore_name] %>
|
6
|
+
params_parser <%= config[:spec][:constant_name] %>::<%= config[:use_case][:params_constant_name] %>
|
7
|
+
description %q{
|
8
|
+
TODO: write what <%= config[:use_case][:name] %> does
|
9
|
+
}
|
10
|
+
|
11
|
+
def implementation
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Testcloud::Generator::CLI do
|
4
|
+
|
5
|
+
it 'should have a gem command' do
|
6
|
+
expect(Testcloud::Generator::CLI.commands).to include('gem')
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have a version command' do
|
10
|
+
expect(Testcloud::Generator::CLI.commands).to include('version')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should have a use_case command' do
|
14
|
+
expect(Testcloud::Generator::CLI.commands).to include('use_case')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/testcloud-generator.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testcloud-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- testCloud Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: thor
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,22 +76,27 @@ extra_rdoc_files: []
|
|
62
76
|
files:
|
63
77
|
- ".envrc"
|
64
78
|
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
65
81
|
- Gemfile
|
66
82
|
- LICENSE.txt
|
67
83
|
- README.md
|
68
84
|
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/rspec
|
69
87
|
- bin/testcloud_generator
|
70
88
|
- lib/testcloud/generator.rb
|
71
89
|
- lib/testcloud/generator/cli.rb
|
72
90
|
- lib/testcloud/generator/commands.rb
|
73
|
-
- lib/testcloud/generator/commands/.gem.rb.swp
|
74
91
|
- lib/testcloud/generator/commands/base.rb
|
75
92
|
- lib/testcloud/generator/commands/gem.rb
|
93
|
+
- lib/testcloud/generator/commands/use_case.rb
|
76
94
|
- lib/testcloud/generator/gem_version.rb
|
77
95
|
- lib/testcloud/generator/templates/newgem/.envrc
|
78
96
|
- lib/testcloud/generator/templates/newgem/.rspec
|
79
97
|
- lib/testcloud/generator/templates/newgem/Gemfile.tt
|
80
98
|
- lib/testcloud/generator/templates/newgem/LICENSE.txt
|
99
|
+
- lib/testcloud/generator/templates/newgem/README.md.tt
|
81
100
|
- lib/testcloud/generator/templates/newgem/bin/console.tt
|
82
101
|
- lib/testcloud/generator/templates/newgem/bin/cucumber.tt
|
83
102
|
- lib/testcloud/generator/templates/newgem/bin/puma.tt
|
@@ -97,8 +116,12 @@ files:
|
|
97
116
|
- lib/testcloud/generator/templates/newgem/lib/newgem_shortcut.rb.tt
|
98
117
|
- lib/testcloud/generator/templates/newgem/newgem.gemspec.tt
|
99
118
|
- lib/testcloud/generator/templates/newgem/spec/spec_helper.rb.tt
|
119
|
+
- lib/testcloud/generator/templates/use_case/new_params.rb.tt
|
120
|
+
- lib/testcloud/generator/templates/use_case/new_use_case.rb.tt
|
100
121
|
- lib/testcloud/generator/version.rb
|
101
122
|
- lib/testcloud_generator.rb
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
- spec/testcloud/generator/cli_spec.rb
|
102
125
|
- testcloud-generator.gemspec
|
103
126
|
homepage: https://testcloud.io
|
104
127
|
licenses:
|
@@ -120,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
143
|
version: '0'
|
121
144
|
requirements: []
|
122
145
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.2.
|
146
|
+
rubygems_version: 2.2.2
|
124
147
|
signing_key:
|
125
148
|
specification_version: 4
|
126
149
|
summary: Generators at testCloud
|
Binary file
|