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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 286c2605ea1c91c6586d38160e2563f5098d69c4
4
- data.tar.gz: 0fca96ba664837d6c4ab526c92ad029ba4f88f7d
3
+ metadata.gz: 6a7c47e521f766163e9a5bfe3b51136b3405982f
4
+ data.tar.gz: 735dda8c7949b2d8d8e37b12f21115c917106406
5
5
  SHA512:
6
- metadata.gz: bcda6d77077795fd91c104ddd1f3ef7a3a7307839a4449db652cbe0f985fd858bb1195b9e22a76f6a9bf74923b88c353cd5db81fbf91bc065b16891e4292eb63
7
- data.tar.gz: f43d4a5ded3f638b22ee706d01d52a79ebe91e5adaa7f11b45fb7e2dbd26f303e320f19acbf107ef8041353577ccf53533d334ffdcc4c14990314b483feef0ae
6
+ metadata.gz: 5797af65dab73a1a95276b2eb1efde09e94e551b67f145e94a82b6a80ffc361f82672de0a2f3873b6c6d3d1012bac63e259c62e631a29c3909db6cf2faa11d6e
7
+ data.tar.gz: c65f5849dce6bd4a9b9c476784d9a98a0961326c445ac751dc82223e6f9f5746cf1d8bb4a1bb801bbd8bcf3e1fc4347460c341c1f869de73868d893fa4f92b39
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  *.a
14
14
  mkmf.log
15
15
  *.gem
16
+ *.sw[op]
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ before_install: gem install bundler --version='1.7.2'
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.2
7
+ - ruby-head
8
+ matrix:
9
+ allow_failures:
10
+ - rvm: ruby-head
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in testcloud-generator.gemspec
4
4
  gemspec
5
+
6
+ group :development do
7
+ gem 'pry'
8
+ end
9
+
10
+ group :test do
11
+ gem 'rspec', '~> 3.0.0'
12
+ gem 'shoulda', '~> 3.5.0'
13
+ end
data/README.md CHANGED
@@ -1,26 +1,26 @@
1
+ [![Build Status](https://travis-ci.org/testCloud/testcloud-generator.svg?branch=master)](https://travis-ci.org/testCloud/testcloud-generator)
2
+
1
3
  # Testcloud::Generator
2
4
 
3
- TODO: Write a gem description
5
+ Generators for speeding up repetitive tasks during development.
4
6
 
5
7
  ## Installation
6
8
 
7
- Add this line to your application's Gemfile:
9
+ Just install the generator globally for your ruby version.
8
10
 
9
- ```ruby
10
- gem 'testcloud-generator'
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
- TODO: Write usage instructions here
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
@@ -1,2 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path('../../lib', __FILE__))
4
+ require 'testcloud_generator'
5
+ require 'pry'
6
+
7
+ Pry::CLI.parse_options
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')
@@ -1,3 +1,6 @@
1
+ require 'rubygems'
2
+ require 'active_support/core_ext'
3
+
1
4
  module Testcloud
2
5
  module Generator
3
6
 
@@ -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'
@@ -3,6 +3,7 @@ module Testcloud
3
3
  module Commands
4
4
  require 'testcloud/generator/commands/base'
5
5
  require 'testcloud/generator/commands/gem'
6
+ require 'testcloud/generator/commands/use_case'
6
7
  end
7
8
  end
8
9
  end
@@ -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
@@ -8,7 +8,7 @@ module Testcloud
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
10
  PATCH = 0
11
- PRE = 3
11
+ PRE = 4
12
12
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
13
13
  end
14
14
  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,8 @@
1
+ module <%= config[:spec][:constant_array].first %>
2
+ module <%= config[:spec][:constant_array].last %>
3
+ module Params
4
+ class <%= config[:use_case][:params_constant_array].last %> < Testcloud::Params::Base
5
+ end
6
+ end
7
+ end
8
+ end
@@ -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
@@ -0,0 +1,7 @@
1
+ lib = File.expand_path('../../lib', __FILE__)
2
+ $:.unshift(lib) unless $:.include?(lib)
3
+ require 'testcloud_generator'
4
+
5
+ RSpec.configure do |config|
6
+ config.pattern = 'spec/**/*_spec.rb'
7
+ end
@@ -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
@@ -19,5 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency 'bundler', '~> 1.7'
20
20
  spec.add_development_dependency 'rake', '~> 10.0'
21
21
 
22
+ spec.add_runtime_dependency 'activesupport', '>= 4.1'
22
23
  spec.add_runtime_dependency 'thor', '~> 0.19'
23
24
  end
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.3
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-29 00:00:00.000000000 Z
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.0
146
+ rubygems_version: 2.2.2
124
147
  signing_key:
125
148
  specification_version: 4
126
149
  summary: Generators at testCloud