lib/bin/toadstool in toadstool-0.0.0.5 vs lib/bin/toadstool in toadstool-0.0.0.7
- old
+ new
@@ -12,109 +12,106 @@
class Install < Thor::Group
include Thor::Actions
# Define arguments and options
argument :name, {:default => './'}
+ class_option :styleguide_directory, :type => :string, :default => "./styleguide/", :desc => 'The directory for the Toadstool app.'
def self.source_root
APP_PATH
end
def install_app
- # Per https://github.com/wycats/thor/pull/175#issuecomment-2250270
- # If any empty directory is found, it's copied and all .empty_directory files are ignored.
- # If any file name is wrapped within % signs, the text within the % signs will be executed
- # as a method and replaced with the returned value.
+ directory "project/doc-src", "#{install_directory}/doc-src"
+ directory "project/public", "#{install_directory}/public"
+ directory "project/sass", "#{install_directory}/sass"
+ directory "project/views", "#{install_directory}/views"
- directory "project/doc-src", "#{name}/doc-src"
- directory "project/public", "#{name}/public"
- directory "project/sass", "#{name}/sass"
- directory "project/views", "#{name}/views"
+ copy_file "project/config.rb", "#{install_directory}/config.rb"
+ copy_file "project/config.ru", "#{install_directory}/config.ru"
+ copy_file "project/Gemfile", "#{install_directory}/Gemfile"
+ copy_file "project/Rakefile", "#{install_directory}/Rakefile"
+ copy_file "project/readme.md", "#{install_directory}/readme.md"
+ copy_file "project/toadstool.rb", "#{install_directory}/toadstool.rb"
+ end
- copy_file "project/config.rb", "#{name}/config.rb"
- copy_file "project/config.ru", "#{name}/config.ru"
- copy_file "project/Gemfile", "#{name}/Gemfile"
- copy_file "project/Rakefile", "#{name}/Rakefile"
- copy_file "project/readme.md", "#{name}/readme.md"
- copy_file "project/toadstool.rb", "#{name}/toadstool.rb"
+ def install_directory
+ File.join('./', name, options[:styleguide_directory])
end
end
class Server < Thor::Group
- def exec_script_rails!
+ def start # no desc
+
cwd = Dir.pwd
- return unless in_rails_application? || in_rails_application_subdirectory?
- exec 'rackup', *ARGV if in_rails_application?
+ return unless in_toadstool_app? || in_app_subdirectory?
+ exec 'rackup', *ARGV if in_toadstool_app?
Dir.chdir("..") do
# Recurse in a chdir block: if the search fails we want to be sure
# the application is generated in the original working directory.
- exec_script_rails! unless cwd == Dir.pwd
+ start! unless cwd == Dir.pwd
end
rescue SystemCallError
# could not chdir, no problem just return
end
-
- no_tasks do
- def in_rails_application?
- File.exists?('config.ru')
- end
+ no_tasks do
+ def in_toadstool_app?
+ File.exists?('toadstool.rb') && File.exists?('config.ru')
+ end
- def in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
- File.exists?(File.join(path, 'config.ru')) || !path.root? && in_rails_application_subdirectory?(path.parent)
- end
- end
+ def in_app_subdirectory?(path = Pathname.new(Dir.pwd))
+ File.exists?(File.join(path, 'config.ru')) || !path.root? && in_app_subdirectory?(path.parent)
+ end
+ end
end
-
-
-# end
-#
-#
-# module Toadstool
class Generator < Thor
+ def self.source_root
+ APP_PATH
+ end
+
include Thor::Actions
- argument :name
- argument :state
-
- desc 'ts_module', "Generate a module"
- def ts_module
- create_file "views/modules/#{name}/_#{state}.erb"
- create_file "views/modules/#{name}/readme.md"
- create_file "sass/modules/#{name}/#{state}/_#{state}.sass", "@import 'mixins'\n@import 'extends'"
- create_file "sass/modules/#{name}/#{state}/_extends.sass"
- create_file "sass/modules/#{name}/#{state}/_mixins.scss"
+ argument :truffle
+ argument :oil
- create_file 'sass/_modules.sass' if !File.exist?('sass/_modules.sass')
-
- append_file 'sass/_modules.sass', "@import 'modules/#{name}/#{state}/#{state}'"
- end
+ desc 'ts_module', "Generate a module"
+ def ts_module
+ directory "module/views", "views/modules/#{truffle}"
+ directory "module/sass", "sass/modules/#{truffle}"
- desc 'ts_pattern', "Generate a module"
- def ts_pattern
- create_file "views/ui_patterns/#{name}/_#{state}.erb"
- create_file "views/ui_patterns/#{name}/readme.md"
- create_file "sass/ui_patterns/#{name}/#{state}/_#{state}.sass", "@import 'mixins'\n@import 'extends'"
- create_file "sass/ui_patterns/#{name}/#{state}/_extends.sass"
- create_file "sass/ui_patterns/#{name}/#{state}/_mixins.scss"
+ append_file 'sass/_modules.scss', "@import 'modules/#{truffle}/#{oil}/#{oil}'"
+ end
- create_file 'sass/_ui_patterns.sass' if !File.exist?('sass/_ui_patterns.sass')
-
- append_file 'sass/_ui_patterns.sass', "@import 'ui_patterns/#{name}/#{state}/#{state}'"
+ desc 'pattern', "Generate a module"
+ def pattern
+ directory "pattern/views", "views/ui_patterns/#{truffle}"
+ directory "pattern/sass", "sass/ui_patterns/#{truffle}"
+
+ append_file 'sass/_ui_patterns.scss', "@import 'ui_patterns/#{truffle}/#{oil}/#{oil}'"
+ end
+
+ no_tasks do
+ def shiitake
+ "#{oil}"
end
end
+
+ map 'module' => 'ts_module'
+ end
end
ARGV << '--help' if ARGV.empty?
aliases = {
"i" => "install",
"new" => "install",
- "s" => "server"
+ "s" => "server",
+ "g" => "generate"
}
help_message = <<-EOT
Usage: toadstool COMMAND [ARGS]
@@ -133,10 +130,9 @@
case command
when 'install'
Toadstool::Install.start
when 'server'
Toadstool::Server.start
-
when 'generate'
Toadstool::Generator.start
else
puts "Error: Command '#{command}' not recognized"
if %x{rake #{command} --dry-run 2>&1 } && $?.success?
\ No newline at end of file