rgentpl 1.2.6 → 2.0.0
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 +5 -5
- data/.gitignore +0 -11
- data/.rspec +0 -1
- data/.ruby-version +1 -1
- data/.solargraph.yml +14 -0
- data/.standard.yml +13 -0
- data/.yardopts +0 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +271 -0
- data/Guardfile +13 -41
- data/LICENSE.txt +0 -0
- data/README.md +2 -12
- data/Rakefile +7 -8
- data/bin/rgentpl +3 -3
- data/config/boot.rb +2 -2
- data/config/environment.rb +2 -2
- data/config/environments/development.rb +1 -1
- data/config/environments/production.rb +0 -0
- data/config/environments/test.rb +1 -1
- data/lib/rgentpl/boot/application.rb +0 -0
- data/lib/rgentpl/boot/initializer.rb +1 -1
- data/lib/rgentpl/command/base.rb +6 -6
- data/lib/rgentpl/command/generate.rb +11 -23
- data/lib/rgentpl/core/configuration.rb +5 -5
- data/lib/rgentpl/core_ext/string.rb +2 -2
- data/lib/rgentpl/exception/critical.rb +0 -0
- data/lib/rgentpl/version.rb +1 -1
- data/lib/rgentpl.rb +13 -15
- data/lib/tasks/rspec.rake +9 -0
- data/lib/tasks/rubycritic.rake +12 -0
- data/lib/tasks/standard.rake +5 -0
- data/lib/tasks/yard.rake +17 -0
- data/log/.gitignore +0 -0
- data/rgentpl.gemspec +44 -68
- data/spec/lib/rgentpl/boot/application_spec.rb +4 -6
- data/spec/lib/rgentpl/boot/initializer_spec.rb +8 -8
- data/spec/lib/rgentpl/command/base_spec.rb +8 -8
- data/spec/lib/rgentpl/command/generate_spec.rb +12 -12
- data/spec/lib/rgentpl/core/configuration_spec.rb +21 -22
- data/spec/lib/rgentpl/core_ext/string_spec.rb +7 -7
- data/spec/lib/rgentpl_spec.rb +10 -10
- data/spec/spec_helper.rb +12 -18
- data/spec/support/.gitkeep +0 -0
- data/src/%app_name%.gemspec.tt +29 -51
- data/src/.gitignore +0 -11
- data/src/.rspec +0 -1
- data/src/.ruby-version +1 -1
- data/src/.solargraph.yml +14 -0
- data/src/.standard.yml +13 -0
- data/src/.yardopts +0 -0
- data/src/Gemfile +2 -2
- data/src/Guardfile +13 -41
- data/src/LICENSE.txt +0 -0
- data/src/README.md.tt +3 -2
- data/src/Rakefile +7 -8
- data/src/config/boot.rb.tt +0 -0
- data/src/config/environment.rb.tt +1 -1
- data/src/config/environments/development.rb.tt +0 -0
- data/src/config/environments/production.rb +0 -0
- data/src/config/environments/test.rb +1 -1
- data/src/config/initializers/.gitignore +0 -0
- data/src/doc/.gitignore +0 -0
- data/src/lib/%app_name%/boot/application.rb.tt +0 -0
- data/src/lib/%app_name%/boot/initializer.rb.tt +0 -0
- data/src/lib/%app_name%/command/base.rb.tt +0 -0
- data/src/lib/%app_name%/core/configuration.rb.tt +0 -0
- data/src/lib/%app_name%/core_ext/string.rb.tt +0 -0
- data/src/lib/%app_name%/exception/critical.rb.tt +0 -0
- data/src/lib/%app_name%/version.rb.tt +0 -0
- data/src/lib/%app_name%.rb.tt +2 -4
- data/src/lib/tasks/rspec.rake +9 -0
- data/src/lib/tasks/rubycritic.rake +12 -0
- data/src/lib/tasks/standard.rake +5 -0
- data/src/lib/tasks/yard.rake +17 -0
- data/src/log/yard.log +0 -0
- data/src/spec/lib/%app_name%/boot/application_spec.rb.tt +2 -4
- data/src/spec/lib/%app_name%/boot/initializer_spec.rb.tt +1 -1
- data/src/spec/lib/%app_name%/command/base_spec.rb.tt +0 -0
- data/src/spec/lib/%app_name%/core/configuration_spec.rb.tt +6 -4
- data/src/spec/lib/%app_name%/core_ext/.gitignore +0 -0
- data/src/spec/lib/%app_name%/core_ext/string_spec.rb.tt +1 -1
- data/src/spec/lib/%app_name%/exception/.gitignore +0 -0
- data/src/spec/lib/%app_name%_spec.rb.tt +1 -1
- data/src/spec/spec_helper.rb +25 -0
- data/src/spec/support/.gitkeep +0 -0
- data/src/tmp/.gitkeep +0 -0
- data/tmp/.gitkeep +0 -0
- metadata +55 -377
- data/.cane +0 -7
- data/.document +0 -3
- data/.excellent.yml +0 -1
- data/.rspec-travis +0 -2
- data/.rubocop.yml +0 -32
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -17
- data/Capfile +0 -27
- data/ChangeLog.md +0 -141
- data/README.rdoc +0 -4
- data/ShortLog +0 -84
- data/config/deploy/production.rb +0 -9
- data/config/deploy/staging.rb +0 -9
- data/config/deploy.rb +0 -43
- data/lib/capistrano/tasks/copy_git.rake +0 -13
- data/src/.cane +0 -7
- data/src/.document +0 -3
- data/src/.excellent.yml +0 -1
- data/src/.rspec-travis +0 -2
- data/src/.rubocop.yml +0 -32
- data/src/.ruby-gemset.tt +0 -1
- data/src/.travis.yml +0 -17
- data/src/Capfile +0 -27
- data/src/ChangeLog.md +0 -0
- data/src/README.rdoc +0 -3
- data/src/ShortLog +0 -0
- data/src/config/deploy/production.rb +0 -9
- data/src/config/deploy/staging.rb +0 -9
- data/src/config/deploy.rb +0 -43
- data/src/lib/capistrano/tasks/copy_git.rake +0 -13
- data/src/spec/spec_helper.rb.tt +0 -29
- data/src/tasks/excellent.rake +0 -8
- data/src/tasks/quality.rake +0 -15
- data/src/tasks/rspec.rake +0 -9
- data/src/tasks/rubocop.rake +0 -10
- data/src/tasks/rubycritic.rake +0 -13
- data/src/tasks/sdoc.rake +0 -19
- data/src/tasks/yard.rake +0 -18
- data/tasks/excellent.rake +0 -8
- data/tasks/quality.rake +0 -15
- data/tasks/rspec.rake +0 -9
- data/tasks/rubocop.rake +0 -10
- data/tasks/rubycritic.rake +0 -13
- data/tasks/sdoc.rake +0 -19
- data/tasks/yard.rake +0 -18
|
@@ -11,53 +11,41 @@ module Rgentpl
|
|
|
11
11
|
include Thor::Actions
|
|
12
12
|
|
|
13
13
|
# Application path description
|
|
14
|
-
APP_PATH_DESC =
|
|
15
|
-
# CTags description
|
|
16
|
-
CTAGS_DESC = 'Full CTags path command (default: /usr/local/bin/ctags)'
|
|
14
|
+
APP_PATH_DESC = "Application path with current path as a default value"
|
|
17
15
|
|
|
18
16
|
# @return [String] the final install application path
|
|
19
17
|
attr_accessor :app_path
|
|
20
|
-
# @return [String] the ctags full binary path
|
|
21
|
-
attr_accessor :ctags
|
|
22
18
|
|
|
23
19
|
# App name argument
|
|
24
20
|
argument :app_name, type: :string, required: true,
|
|
25
|
-
|
|
21
|
+
desc: "Application name"
|
|
26
22
|
# @return [String] the application path root
|
|
27
23
|
def self.source_root
|
|
28
24
|
TEMPLATE_ROOT
|
|
29
25
|
end
|
|
30
26
|
|
|
31
27
|
class_option :app_path, type: :string,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class_option :ctags, type: :string,
|
|
37
|
-
required: false,
|
|
38
|
-
desc: CTAGS_DESC,
|
|
39
|
-
default: '/usr/local/bin/ctags',
|
|
40
|
-
aliases: '-t'
|
|
28
|
+
required: true,
|
|
29
|
+
desc: APP_PATH_DESC,
|
|
30
|
+
default: File.expand_path("."),
|
|
31
|
+
aliases: "-p"
|
|
41
32
|
# @return [void]
|
|
42
33
|
def create_app
|
|
43
|
-
@app_path = options[
|
|
44
|
-
@
|
|
45
|
-
directory('src', "#{@app_path.chomp('/')}/#{app_name}")
|
|
34
|
+
@app_path = options["app_path"]
|
|
35
|
+
directory("src", "#{@app_path.chomp("/")}/#{app_name}")
|
|
46
36
|
end
|
|
47
37
|
|
|
48
38
|
# @return [void]
|
|
49
39
|
def add_perms
|
|
50
|
-
chmod("#{@app_path.chomp(
|
|
40
|
+
chmod("#{@app_path.chomp("/")}/#{app_name}/bin/#{app_name}", 0o755)
|
|
51
41
|
end
|
|
52
42
|
|
|
53
43
|
# @return [void]
|
|
54
44
|
def git
|
|
55
45
|
inside("#{app_path}/#{app_name}") do
|
|
56
|
-
run(
|
|
57
|
-
run(
|
|
46
|
+
run("git init")
|
|
47
|
+
run("git add .")
|
|
58
48
|
run('git commit -am "First sending."')
|
|
59
|
-
run('git checkout -b develop')
|
|
60
|
-
run('git checkout -b feature-domain-logic')
|
|
61
49
|
end
|
|
62
50
|
end
|
|
63
51
|
end
|
|
@@ -24,7 +24,7 @@ module Rgentpl
|
|
|
24
24
|
# @param exc [NoMethodError] the exception
|
|
25
25
|
# @return [void]
|
|
26
26
|
def add_new_attribute_from_exception(exc)
|
|
27
|
-
add_new_attribute(exc, exc.name.to_s.gsub(/=$/,
|
|
27
|
+
add_new_attribute(exc, exc.name.to_s.gsub(/=$/, ""))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# Implementation for adding new attribute in configuration block
|
|
@@ -35,7 +35,7 @@ module Rgentpl
|
|
|
35
35
|
def add_new_attribute(exc, method)
|
|
36
36
|
@config.extend Virtus.model
|
|
37
37
|
@config.attribute method.to_sym, String, default: exc.args.first,
|
|
38
|
-
|
|
38
|
+
lazy: true
|
|
39
39
|
@config.send(exc.name, exc.args.first)
|
|
40
40
|
end
|
|
41
41
|
private :add_new_attribute
|
|
@@ -45,9 +45,9 @@ module Rgentpl
|
|
|
45
45
|
class Configuration
|
|
46
46
|
include Virtus.model
|
|
47
47
|
|
|
48
|
-
attribute :active,
|
|
48
|
+
attribute :active, Boolean, default: true
|
|
49
49
|
attribute :log_file, String
|
|
50
|
-
attribute
|
|
50
|
+
attribute(:options, {Symbol => String}, default: {})
|
|
51
51
|
|
|
52
52
|
# Set custom default values
|
|
53
53
|
#
|
|
@@ -56,7 +56,7 @@ module Rgentpl
|
|
|
56
56
|
def initialize(*args)
|
|
57
57
|
super
|
|
58
58
|
# Bug - Update some default values
|
|
59
|
-
@log_file = Rgentpl.env +
|
|
59
|
+
@log_file = Rgentpl.env + ".log"
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
# Configuration
|
|
@@ -7,14 +7,14 @@ module Rgentpl
|
|
|
7
7
|
#
|
|
8
8
|
# @return [String] the camelized string
|
|
9
9
|
def camelize
|
|
10
|
-
split(/\s|-|_/).each(&:capitalize!).join(
|
|
10
|
+
split(/\s|-|_/).each(&:capitalize!).join("")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
# Camelize!
|
|
14
14
|
#
|
|
15
15
|
# @return [String] the camelized string
|
|
16
16
|
def camelize!
|
|
17
|
-
replace(split(/\s|-|_/).each(&:capitalize!).join(
|
|
17
|
+
replace(split(/\s|-|_/).each(&:capitalize!).join(""))
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
File without changes
|
data/lib/rgentpl/version.rb
CHANGED
data/lib/rgentpl.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
1
|
+
require "rubygems"
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
require "virtus"
|
|
4
|
+
require "thor"
|
|
5
|
+
require "logger"
|
|
6
6
|
|
|
7
7
|
# Rgentpl
|
|
8
8
|
module Rgentpl
|
|
@@ -18,22 +18,20 @@ module Rgentpl
|
|
|
18
18
|
require file
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
require_relative
|
|
22
|
-
require_relative
|
|
23
|
-
require_relative
|
|
24
|
-
require_relative
|
|
25
|
-
require_relative
|
|
26
|
-
require_relative
|
|
21
|
+
require_relative "rgentpl/version"
|
|
22
|
+
require_relative "rgentpl/command/generate"
|
|
23
|
+
require_relative "rgentpl/command/base"
|
|
24
|
+
require_relative "rgentpl/boot/initializer"
|
|
25
|
+
require_relative "rgentpl/boot/application"
|
|
26
|
+
require_relative "rgentpl/core/configuration"
|
|
27
27
|
|
|
28
28
|
class << self
|
|
29
29
|
# Environment
|
|
30
30
|
#
|
|
31
31
|
# @return [String] the current environment
|
|
32
32
|
def env
|
|
33
|
-
unless
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
TEMPLATE_ENV
|
|
33
|
+
load File.expand_path("../config/environment.rb", __dir__) unless ENV.include? "TEMPLATE_ENV"
|
|
34
|
+
ENV["TEMPLATE_ENV"]
|
|
37
35
|
end
|
|
38
36
|
|
|
39
37
|
# Logger
|
data/lib/tasks/yard.rake
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require "rspec"
|
|
3
|
+
require "rspec/core/rake_task"
|
|
4
|
+
require "yard"
|
|
5
|
+
|
|
6
|
+
desc "Generate docs under doc/api folder (YARD)"
|
|
7
|
+
YARD::Rake::YardocTask.new do |t|
|
|
8
|
+
t.files += ["lib/**/*.rb"]
|
|
9
|
+
t.options += ["--protected"]
|
|
10
|
+
t.options += ["--private"]
|
|
11
|
+
t.options += ["--output-dir", "doc/api"]
|
|
12
|
+
t.stats_options = ["--list-undoc"]
|
|
13
|
+
end
|
|
14
|
+
task doc: :yard
|
|
15
|
+
rescue LoadError
|
|
16
|
+
warn "yard not available, yard task not provided."
|
|
17
|
+
end
|
data/log/.gitignore
CHANGED
|
File without changes
|
data/rgentpl.gemspec
CHANGED
|
@@ -1,74 +1,50 @@
|
|
|
1
|
-
require File.expand_path(
|
|
1
|
+
require File.expand_path("lib/rgentpl/version", __dir__)
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |gem|
|
|
4
|
-
gem.name
|
|
5
|
-
gem.version
|
|
6
|
-
gem.platform
|
|
7
|
-
gem.
|
|
8
|
-
gem.
|
|
9
|
-
gem.
|
|
10
|
-
gem.
|
|
11
|
-
gem.
|
|
12
|
-
gem.
|
|
13
|
-
gem.homepage = "https://github.com/jatap/rgentpl#readme"
|
|
14
|
-
gem.executables = ["rgentpl"]
|
|
4
|
+
gem.name = "rgentpl"
|
|
5
|
+
gem.version = Rgentpl::VERSION
|
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
|
7
|
+
gem.summary = "Ruby Skeleton Generator"
|
|
8
|
+
gem.description = "Ruby Skeleton Generator based in templates"
|
|
9
|
+
gem.license = "MIT"
|
|
10
|
+
gem.authors = ["Julio Antúnez Tarín"]
|
|
11
|
+
gem.email = "julio.antunez.tarin@gmail.com"
|
|
12
|
+
gem.homepage = "https://github.com/jatap/rgentpl#readme"
|
|
15
13
|
|
|
16
|
-
gem.files
|
|
17
|
-
gem.executables
|
|
18
|
-
gem.
|
|
19
|
-
gem.require_paths = ['lib']
|
|
14
|
+
gem.files = `git ls-files`.split($/)
|
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
20
17
|
|
|
21
|
-
gem.add_runtime_dependency
|
|
22
|
-
gem.add_runtime_dependency
|
|
23
|
-
gem.add_runtime_dependency
|
|
18
|
+
gem.add_runtime_dependency "rake"
|
|
19
|
+
gem.add_runtime_dependency "thor"
|
|
20
|
+
gem.add_runtime_dependency "virtus"
|
|
21
|
+
gem.add_runtime_dependency "logger"
|
|
24
22
|
|
|
25
|
-
gem.add_development_dependency
|
|
26
|
-
gem.add_development_dependency
|
|
27
|
-
gem.add_development_dependency
|
|
28
|
-
gem.add_development_dependency
|
|
29
|
-
gem.add_development_dependency
|
|
30
|
-
gem.add_development_dependency
|
|
31
|
-
gem.add_development_dependency
|
|
32
|
-
gem.add_development_dependency
|
|
33
|
-
gem.add_development_dependency
|
|
34
|
-
gem.add_development_dependency
|
|
35
|
-
gem.add_development_dependency
|
|
36
|
-
gem.add_development_dependency
|
|
37
|
-
gem.add_development_dependency
|
|
38
|
-
gem.add_development_dependency
|
|
39
|
-
gem.add_development_dependency
|
|
40
|
-
gem.add_development_dependency
|
|
41
|
-
gem.add_development_dependency
|
|
42
|
-
gem.add_development_dependency
|
|
43
|
-
gem.add_development_dependency
|
|
44
|
-
gem.add_development_dependency
|
|
45
|
-
gem.add_development_dependency
|
|
46
|
-
gem.add_development_dependency
|
|
47
|
-
gem.add_development_dependency
|
|
48
|
-
gem.add_development_dependency
|
|
49
|
-
gem.add_development_dependency
|
|
50
|
-
gem.add_development_dependency
|
|
51
|
-
gem.add_development_dependency
|
|
52
|
-
gem.add_development_dependency 'simplecov'
|
|
53
|
-
gem.add_development_dependency 'simplecov-gem-adapter'
|
|
54
|
-
gem.add_development_dependency 'selenium-webdriver'
|
|
55
|
-
gem.add_development_dependency 'launchy'
|
|
56
|
-
gem.add_development_dependency 'capybara'
|
|
57
|
-
gem.add_development_dependency 'webrat'
|
|
58
|
-
gem.add_development_dependency 'rspec-nc', '>= 0.2.0'
|
|
59
|
-
gem.add_development_dependency 'rspec-abhakungszeichen-formatter'
|
|
60
|
-
gem.add_development_dependency 'nyan-cat-formatter'
|
|
61
|
-
gem.add_development_dependency 'fuubar', '>= 2.0.0'
|
|
62
|
-
gem.add_development_dependency 'ffaker'
|
|
63
|
-
gem.add_development_dependency 'byebug'
|
|
64
|
-
gem.add_development_dependency 'pry'
|
|
65
|
-
gem.add_development_dependency 'pry-doc'
|
|
66
|
-
gem.add_development_dependency 'pry-byebug'
|
|
67
|
-
gem.add_development_dependency 'awesome_print'
|
|
68
|
-
gem.add_development_dependency 'colorize'
|
|
69
|
-
gem.add_development_dependency 'bcrypt-ruby'
|
|
70
|
-
gem.add_development_dependency 'capistrano', '>= 3.4.0'
|
|
71
|
-
gem.add_development_dependency 'capistrano-rvm'
|
|
72
|
-
gem.add_development_dependency 'capistrano-bundler', '>= 1.1.2'
|
|
23
|
+
gem.add_development_dependency "awesome_print"
|
|
24
|
+
gem.add_development_dependency "bundler"
|
|
25
|
+
gem.add_development_dependency "byebug"
|
|
26
|
+
gem.add_development_dependency "colorize"
|
|
27
|
+
gem.add_development_dependency "debug", ">= 1.0.0"
|
|
28
|
+
gem.add_development_dependency "fuubar"
|
|
29
|
+
gem.add_development_dependency "guard"
|
|
30
|
+
gem.add_development_dependency "guard-bundler"
|
|
31
|
+
gem.add_development_dependency "guard-rspec"
|
|
32
|
+
gem.add_development_dependency "guard-rubycritic"
|
|
33
|
+
gem.add_development_dependency "guard-standardrb"
|
|
34
|
+
gem.add_development_dependency "guard-yard"
|
|
35
|
+
gem.add_development_dependency "neovim"
|
|
36
|
+
gem.add_development_dependency "pry"
|
|
37
|
+
gem.add_development_dependency "pry-byebug"
|
|
38
|
+
gem.add_development_dependency "redcarpet"
|
|
39
|
+
gem.add_development_dependency "rspec"
|
|
40
|
+
gem.add_development_dependency "rspec-nc"
|
|
41
|
+
gem.add_development_dependency "rubocop-rake"
|
|
42
|
+
gem.add_development_dependency "rubocop-rspec"
|
|
43
|
+
gem.add_development_dependency "rubycritic"
|
|
44
|
+
gem.add_development_dependency "sdoc"
|
|
45
|
+
gem.add_development_dependency "simplecov"
|
|
46
|
+
gem.add_development_dependency "solargraph"
|
|
47
|
+
gem.add_development_dependency "standard", "1.5.0"
|
|
48
|
+
gem.add_development_dependency "webrick"
|
|
49
|
+
gem.add_development_dependency "yard"
|
|
73
50
|
end
|
|
74
|
-
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl::Application do
|
|
4
|
-
describe
|
|
5
|
-
it
|
|
6
|
-
#
|
|
7
|
-
ARGV = []
|
|
8
|
-
|
|
4
|
+
describe "#exec" do
|
|
5
|
+
it "executes application" do
|
|
6
|
+
ARGV = [] # standard:disable Lint/ConstantDefinitionInBlock
|
|
9
7
|
expect { Rgentpl::Application.exec }.to output(/commands:/).to_stdout
|
|
10
8
|
end
|
|
11
9
|
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl::Initializer do
|
|
4
|
-
describe
|
|
5
|
-
it
|
|
6
|
-
expect(Rgentpl.env).to eq TEMPLATE_ENV
|
|
4
|
+
describe "#build" do
|
|
5
|
+
it "loads enviroment" do
|
|
6
|
+
expect(Rgentpl.env).to eq ENV["TEMPLATE_ENV"]
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
context
|
|
9
|
+
context "given initializers" do
|
|
10
10
|
let(:initializer) do
|
|
11
11
|
File.expand_path("#{File.dirname(__FILE__)}/../../../../config/initializers/sample.rb")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
before :each do
|
|
15
|
-
file = File.new(initializer,
|
|
15
|
+
file = File.new(initializer, "w")
|
|
16
16
|
file.write "Rgentpl.configure { |c| c.new_key = 'New value' }"
|
|
17
17
|
file.close
|
|
18
18
|
|
|
@@ -23,8 +23,8 @@ describe Rgentpl::Initializer do
|
|
|
23
23
|
File.delete initializer
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
it
|
|
27
|
-
expect(Rgentpl.config.new_key).to eq
|
|
26
|
+
it "loads file" do
|
|
27
|
+
expect(Rgentpl.config.new_key).to eq "New value"
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl::Command::Base do
|
|
4
|
-
context
|
|
4
|
+
context "given a list of options" do
|
|
5
5
|
let(:command) { Rgentpl::Command::Base.new }
|
|
6
6
|
|
|
7
|
-
it
|
|
7
|
+
it "responds successfully to help, version and generate" do
|
|
8
8
|
[:help, :version, :generate].each do |element|
|
|
9
9
|
expect(command).to respond_to element
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
describe
|
|
15
|
-
it
|
|
14
|
+
describe "given a help option" do
|
|
15
|
+
it "shows help info" do
|
|
16
16
|
expect { Rgentpl::Command::Base.help(Thor::Base.shell.new) }.to \
|
|
17
17
|
output(/help/).to_stdout
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
describe
|
|
22
|
-
it
|
|
23
|
-
expect { Rgentpl::Command::Base.start %w
|
|
21
|
+
describe "given a version option" do
|
|
22
|
+
it "shows version info" do
|
|
23
|
+
expect { Rgentpl::Command::Base.start %w[version] }.to \
|
|
24
24
|
output(/version/).to_stdout
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "fileutils"
|
|
3
3
|
|
|
4
4
|
describe Rgentpl::Command::Generate do
|
|
5
|
-
let(:app) {
|
|
5
|
+
let(:app) { "test_app" }
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
|
-
Rgentpl::Command::Base.start %W
|
|
8
|
+
Rgentpl::Command::Base.start %W[generate #{app}]
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
let(:path) do
|
|
12
|
-
Rgentpl::Command::Generate.class_options[:app_path].default.chomp(
|
|
12
|
+
Rgentpl::Command::Generate.class_options[:app_path].default.chomp("/")
|
|
13
13
|
end
|
|
14
14
|
let(:file) { "#{path}/#{app}" }
|
|
15
15
|
|
|
@@ -17,21 +17,21 @@ describe Rgentpl::Command::Generate do
|
|
|
17
17
|
FileUtils.rm_rf(file) if File.exist?(file)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
describe
|
|
21
|
-
it
|
|
20
|
+
describe "#source_root" do
|
|
21
|
+
it "sets application source path root" do
|
|
22
22
|
expect(Rgentpl::Command::Generate.source_root)
|
|
23
|
-
.to eq File.absolute_path(File.join(File.dirname(__FILE__),
|
|
23
|
+
.to eq File.absolute_path(File.join(File.dirname(__FILE__), "../../../../"))
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
describe
|
|
28
|
-
it
|
|
27
|
+
describe ".create_app" do
|
|
28
|
+
it "adds a new directory with defined structure" do
|
|
29
29
|
expect(File.exist?(file)).to be
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
describe
|
|
34
|
-
it
|
|
33
|
+
describe ".add_perms" do
|
|
34
|
+
it "add executions perms to binary file" do
|
|
35
35
|
expect(File.stat(File.join(file, "/bin/#{app}")).mode).to eq 33_261
|
|
36
36
|
end
|
|
37
37
|
end
|
|
@@ -1,47 +1,46 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl::Configuration do
|
|
4
4
|
before :each do
|
|
5
5
|
@configuration = Rgentpl::Configuration.new
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
describe
|
|
8
|
+
describe "given expected attributes" do
|
|
9
9
|
[:active,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
it
|
|
10
|
+
:log_file,
|
|
11
|
+
:options].each do |expected_attribute|
|
|
12
|
+
it "responds to each of them" do
|
|
13
13
|
expect(@configuration).to respond_to expected_attribute
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
describe
|
|
19
|
-
it
|
|
18
|
+
describe "#config" do
|
|
19
|
+
it "is an Rgentpl::Configuration object" do
|
|
20
20
|
expect(Rgentpl.config).to be_kind_of Rgentpl::Configuration
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
context
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
describe 'can be configured with a block' do
|
|
33
|
-
it 'adding a new attribute' do
|
|
34
|
-
expect(Rgentpl.config.new_amazing_key).to eq 'some value'
|
|
24
|
+
context "#configure" do
|
|
25
|
+
describe "can be configured with a block" do
|
|
26
|
+
it "adding a new attribute" do
|
|
27
|
+
Rgentpl.configure do |config|
|
|
28
|
+
config.new_amazing_key = "some value"
|
|
29
|
+
end
|
|
30
|
+
expect(Rgentpl.config.new_amazing_key).to eq "some value"
|
|
35
31
|
end
|
|
36
32
|
|
|
37
|
-
it
|
|
38
|
-
|
|
33
|
+
it "updating an existing one" do
|
|
34
|
+
Rgentpl.configure do |config|
|
|
35
|
+
config.active = false
|
|
36
|
+
end
|
|
37
|
+
expect(Rgentpl.config.active).to eq false
|
|
39
38
|
end
|
|
40
39
|
end
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
describe
|
|
44
|
-
it
|
|
42
|
+
describe ".config" do
|
|
43
|
+
it "an alias of Rgentpl.config" do
|
|
45
44
|
Rgentpl.config.active = false
|
|
46
45
|
expect(Rgentpl.config.to_hash).to eq @configuration.config.to_hash
|
|
47
46
|
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl::CoreExt do
|
|
4
|
-
let(:str) {
|
|
5
|
-
let(:result) {
|
|
4
|
+
let(:str) { +"My custom string" }
|
|
5
|
+
let(:result) { "MyCustomString" }
|
|
6
6
|
|
|
7
|
-
describe
|
|
8
|
-
it
|
|
7
|
+
describe ".camelize" do
|
|
8
|
+
it "format according to camelize rules" do
|
|
9
9
|
expect(str.camelize).to eq result
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
describe
|
|
14
|
-
it
|
|
13
|
+
describe ".camelize!" do
|
|
14
|
+
it "persists result into variable" do
|
|
15
15
|
expect { str.camelize! }.to change { str }
|
|
16
16
|
end
|
|
17
17
|
end
|
data/spec/lib/rgentpl_spec.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "spec_helper"
|
|
2
2
|
|
|
3
3
|
describe Rgentpl do
|
|
4
|
-
describe
|
|
5
|
-
it
|
|
6
|
-
expect(Rgentpl.env).to eq(
|
|
4
|
+
describe ".env" do
|
|
5
|
+
it "shows current environment" do
|
|
6
|
+
expect(Rgentpl.env).to eq("test")
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
context
|
|
9
|
+
context "when none default environment is supplied" do
|
|
10
10
|
before :each do
|
|
11
|
-
|
|
11
|
+
ENV.delete "TEMPLATE_ENV"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
it
|
|
15
|
-
expect(Rgentpl.env).to eq(
|
|
14
|
+
it "adds development environment" do
|
|
15
|
+
expect(Rgentpl.env).to eq("development")
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
describe
|
|
21
|
-
it
|
|
20
|
+
describe ".logger" do
|
|
21
|
+
it "is a Logger object" do
|
|
22
22
|
expect(Rgentpl.logger).to be_kind_of Logger
|
|
23
23
|
end
|
|
24
24
|
end
|