Browse Source

Putting together a basic squib new command

dev
Andy Meneely 12 years ago
parent
commit
b64e88ed0e
  1. 17
      bin/squib
  2. 16
      lib/squib.rb
  3. 23
      lib/squib/commands/new.rb
  4. 2
      lib/squib/project_template/.gitignore
  5. 19
      lib/squib/project_template/ABOUT.md
  6. 3
      lib/squib/project_template/Gemfile
  7. 4
      lib/squib/project_template/PNP NOTES.md
  8. 0
      lib/squib/project_template/config.yml
  9. 6
      lib/squib/project_template/deck.rb
  10. 0
      lib/squib/project_template/layout.yml
  11. 1
      squib.gemspec

17
bin/squib

@ -1,2 +1,19 @@
#!/usr/bin/env ruby
require 'squib'
require 'mercenary'
Mercenary.program(:squib) do |p|
p.version Squib::VERSION
p.description "A Ruby DSL for prototyping card games"
p.syntax "squib <subcommand> [options]"
p.command(:new) do |c|
c.syntax "new PATH"
c.description "Creates a new Squib project scaffolding in PATH. Must be a new directory or already empty."
c.action do |args, options|
Squib::Commands::New.new.process(args)
end
end
end

16
lib/squib.rb

@ -1,14 +1,4 @@
require 'logger'
module Squib
def logger
@logger ||= Logger.new(STDOUT)
end
module_function :logger
end
require 'squib/version'
require 'squib/commands/new'
require 'squib/deck'
require 'squib/card'
require 'squib/card'

23
lib/squib/commands/new.rb

@ -0,0 +1,23 @@
module Squib
module Commands
class New
def process(args)
raise ArgumentError.new('Please specify a path.') if args.empty?
new_project_path = File.expand_path(args.join(" "), Dir.pwd)
template_path = File.expand_path('../project_template', File.dirname(__FILE__))
FileUtils.mkdir_p new_project_path
if !Dir["#{new_project_path}/**/*"].empty?
$stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting."
else
Dir.chdir(new_project_path) do
FileUtils.cp_r template_path + '/.', new_project_path
end
end
end
end
end
end

2
lib/squib/project_template/.gitignore vendored

@ -0,0 +1,2 @@
_output

19
lib/squib/project_template/ABOUT.md

@ -0,0 +1,19 @@
My Awesome Game
===============
Check out my awesome game!
Objective
---------
Gameplay
--------
Ending the Game
---------------

3
lib/squib/project_template/Gemfile

@ -0,0 +1,3 @@
source 'https://rubygems.org'
gem 'squib'

4
lib/squib/project_template/PNP NOTES.md

@ -0,0 +1,4 @@
Print and Play Notes
====================
Fill this out to give tips on how to play this with print and play.

0
lib/squib/project_template/config.yml

6
lib/squib/project_template/deck.rb

@ -0,0 +1,6 @@
require 'squib'
Squib::Deck.new(cards: 3) do
text str: "Hello, World!"
save format: :png
end

0
lib/squib/project_template/layout.yml

1
squib.gemspec

@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'pango', '~> 2.2.0'
spec.add_runtime_dependency 'roo', '~> 1.13.2'
spec.add_runtime_dependency 'rsvg2', '~> 2.2.0'
spec.add_runtime_dependency 'mercenary', '~> 0.3.4'
spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake"

Loading…
Cancel
Save