Skip to content
This repository
Browse code

Add GLI Scaffolding

  • Loading branch information...
commit 7d30400b15b14986f47754a729d23f752dc0f3cc 1 parent 435bc08
Jacob Groundwater authored January 06, 2013
2  Gemfile
... ...
@@ -0,0 +1,2 @@
  1
+source :rubygems
  2
+gemspec
6  README.rdoc
Source Rendered
... ...
@@ -0,0 +1,6 @@
  1
+= binfuse
  2
+
  3
+Describe your project here
  4
+
  5
+:include:binfuse.rdoc
  6
+
44  Rakefile
... ...
@@ -0,0 +1,44 @@
  1
+require 'rake/clean'
  2
+require 'rubygems'
  3
+require 'rubygems/package_task'
  4
+require 'rdoc/task'
  5
+require 'cucumber'
  6
+require 'cucumber/rake/task'
  7
+Rake::RDocTask.new do |rd|
  8
+  rd.main = "README.rdoc"
  9
+  rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
  10
+  rd.title = 'Your application title'
  11
+end
  12
+
  13
+spec = eval(File.read('binfuse.gemspec'))
  14
+
  15
+Gem::PackageTask.new(spec) do |pkg|
  16
+end
  17
+CUKE_RESULTS = 'results.html'
  18
+CLEAN << CUKE_RESULTS
  19
+desc 'Run features'
  20
+Cucumber::Rake::Task.new(:features) do |t|
  21
+  opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
  22
+  opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
  23
+  t.cucumber_opts =  opts
  24
+  t.fork = false
  25
+end
  26
+
  27
+desc 'Run features tagged as work-in-progress (@wip)'
  28
+Cucumber::Rake::Task.new('features:wip') do |t|
  29
+  tag_opts = ' --tags ~@pending'
  30
+  tag_opts = ' --tags @wip'
  31
+  t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
  32
+  t.fork = false
  33
+end
  34
+
  35
+task :cucumber => :features
  36
+task 'cucumber:wip' => 'features:wip'
  37
+task :wip => 'features:wip'
  38
+require 'rake/testtask'
  39
+Rake::TestTask.new do |t|
  40
+  t.libs << "test"
  41
+  t.test_files = FileList['test/*_test.rb']
  42
+end
  43
+
  44
+task :default => [:test,:features]
91  bin/binfuse
... ...
@@ -0,0 +1,91 @@
  1
+#!/usr/bin/env ruby
  2
+require 'gli'
  3
+begin # XXX: Remove this begin/rescue before distributing your app
  4
+require 'binfuse'
  5
+rescue LoadError
  6
+  STDERR.puts "In development, you need to use `bundle exec bin/binfuse` to run your app"
  7
+  STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
  8
+  STDERR.puts "Feel free to remove this message from bin/binfuse now"
  9
+  exit 64
  10
+end
  11
+
  12
+include GLI::App
  13
+
  14
+program_desc 'Describe your application here'
  15
+
  16
+version Binfuse::VERSION
  17
+
  18
+desc 'Describe some switch here'
  19
+switch [:s,:switch]
  20
+
  21
+desc 'Describe some flag here'
  22
+default_value 'the default'
  23
+arg_name 'The name of the argument'
  24
+flag [:f,:flagname]
  25
+
  26
+desc 'Describe create here'
  27
+arg_name 'Describe arguments to create here'
  28
+command :create do |c|
  29
+  c.desc 'Describe a switch to create'
  30
+  c.switch :s
  31
+
  32
+  c.desc 'Describe a flag to create'
  33
+  c.default_value 'default'
  34
+  c.flag :f
  35
+  c.action do |global_options,options,args|
  36
+
  37
+    # Your command logic here
  38
+     
  39
+    # If you have any errors, just raise them
  40
+    # raise "that command made no sense"
  41
+
  42
+    puts "create command ran"
  43
+  end
  44
+end
  45
+
  46
+desc 'Describe test here'
  47
+arg_name 'Describe arguments to test here'
  48
+command :test do |c|
  49
+  c.action do |global_options,options,args|
  50
+    puts "test command ran"
  51
+  end
  52
+end
  53
+
  54
+desc 'Describe spawn here'
  55
+arg_name 'Describe arguments to spawn here'
  56
+command :spawn do |c|
  57
+  c.action do |global_options,options,args|
  58
+    puts "spawn command ran"
  59
+  end
  60
+end
  61
+
  62
+desc 'Describe publish here'
  63
+arg_name 'Describe arguments to publish here'
  64
+command :publish do |c|
  65
+  c.action do |global_options,options,args|
  66
+    puts "publish command ran"
  67
+  end
  68
+end
  69
+
  70
+pre do |global,command,options,args|
  71
+  # Pre logic here
  72
+  # Return true to proceed; false to abort and not call the
  73
+  # chosen command
  74
+  # Use skips_pre before a command to skip this block
  75
+  # on that command only
  76
+  true
  77
+end
  78
+
  79
+post do |global,command,options,args|
  80
+  # Post logic here
  81
+  # Use skips_post before a command to skip this
  82
+  # block on that command only
  83
+end
  84
+
  85
+on_error do |exception|
  86
+  # Error logic here
  87
+  # return false to skip default error handling
  88
+  true
  89
+end
  90
+
  91
+exit run(ARGV)
49  binfuse.gemspec
... ...
@@ -1,22 +1,27 @@
1  
-Gem::Specification.new do |s|
2  
-  
3  
-  s.name          = "binfuse"
4  
-  s.version       = "0.0.1"
5  
-  s.platform      = Gem::Platform::RUBY
6  
-  
7  
-  s.authors       = ["Jacob Groundwater"]
8  
-  s.email         = ["groundwater@gmail.com"]
9  
-  
10  
-  s.homepage      = "http://github.com/jacobgroundwater/binary-fusion"
11  
-  s.summary       = "A Rapid Application Development and Distribution Tool"
12  
-  s.description   = %q{Hi}
13  
-  
14  
-  s.rubyforge_project = "binary-fusion"
15  
-  
16  
-  s.files         = ["bin/binfuse.rb"]
17  
-  s.executables   = ["binfuse.rb"]
18  
-  
19  
-  # Dependencies
20  
-  s.add_dependency("gli")
21  
-  
22  
-end
  1
+# Ensure we require the local version and not one we might have installed already
  2
+require File.join([File.dirname(__FILE__),'lib','binfuse','version.rb'])
  3
+spec = Gem::Specification.new do |s| 
  4
+  s.name = 'binfuse'
  5
+  s.version = Binfuse::VERSION
  6
+  s.author = 'Your Name Here'
  7
+  s.email = 'your@email.address.com'
  8
+  s.homepage = 'http://your.website.com'
  9
+  s.platform = Gem::Platform::RUBY
  10
+  s.summary = 'A description of your project'
  11
+# Add your other files here if you make them
  12
+  s.files = %w(
  13
+bin/binfuse
  14
+lib/binfuse/version.rb
  15
+lib/binfuse.rb
  16
+  )
  17
+  s.require_paths << 'lib'
  18
+  s.has_rdoc = true
  19
+  s.extra_rdoc_files = ['README.rdoc','binfuse.rdoc']
  20
+  s.rdoc_options << '--title' << 'binfuse' << '--main' << 'README.rdoc' << '-ri'
  21
+  s.bindir = 'bin'
  22
+  s.executables << 'binfuse'
  23
+  s.add_development_dependency('rake')
  24
+  s.add_development_dependency('rdoc')
  25
+  s.add_development_dependency('aruba')
  26
+  s.add_runtime_dependency('gli','2.5.3')
  27
+end
5  binfuse.rdoc
Source Rendered
... ...
@@ -0,0 +1,5 @@
  1
+= binfuse
  2
+
  3
+Generate this with
  4
+    binfuse rdoc
  5
+After you have described your command line interface
8  features/binfuse.feature
... ...
@@ -0,0 +1,8 @@
  1
+Feature: My bootstrapped app kinda works
  2
+  In order to get going on coding my awesome app
  3
+  I want to have aruba and cucumber setup
  4
+  So I don't have to do it myself
  5
+
  6
+  Scenario: App just runs
  7
+    When I get help for "binfuse"
  8
+    Then the exit status should be 0
6  features/step_definitions/binfuse_steps.rb
... ...
@@ -0,0 +1,6 @@
  1
+When /^I get help for "([^"]*)"$/ do |app_name|
  2
+  @app_name = app_name
  3
+  step %(I run `#{app_name} help`)
  4
+end
  5
+
  6
+# Add more step definitions here
15  features/support/env.rb
... ...
@@ -0,0 +1,15 @@
  1
+require 'aruba/cucumber'
  2
+
  3
+ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
  4
+LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
  5
+
  6
+Before do
  7
+  # Using "announce" causes massive warnings on 1.9.2
  8
+  @puts = true
  9
+  @original_rubylib = ENV['RUBYLIB']
  10
+  ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
  11
+end
  12
+
  13
+After do
  14
+  ENV['RUBYLIB'] = @original_rubylib
  15
+end
4  lib/binfuse.rb
... ...
@@ -0,0 +1,4 @@
  1
+require 'binfuse/version.rb'
  2
+
  3
+# Add requires for other files you add to your project here, so
  4
+# you just need to require this one file in your bin file
3  lib/binfuse/version.rb
... ...
@@ -0,0 +1,3 @@
  1
+module Binfuse
  2
+  VERSION = '0.0.1'
  3
+end
14  test/default_test.rb
... ...
@@ -0,0 +1,14 @@
  1
+require 'test_helper'
  2
+
  3
+class DefaultTest < Test::Unit::TestCase
  4
+
  5
+  def setup
  6
+  end
  7
+
  8
+  def teardown
  9
+  end
  10
+
  11
+  def test_the_truth
  12
+    assert true
  13
+  end
  14
+end
9  test/test_helper.rb
... ...
@@ -0,0 +1,9 @@
  1
+require 'test/unit'
  2
+
  3
+# Add test libraries you want to use here, e.g. mocha
  4
+
  5
+class Test::Unit::TestCase
  6
+
  7
+  # Add global extensions to the test case class here
  8
+  
  9
+end

0 notes on commit 7d30400

Please sign in to comment.
Something went wrong with that request. Please try again.