rbapp 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/bin/rbapp +16 -0
- data/lib/rbapp.rb +40 -0
- data/lib/rbapp/version.rb +3 -0
- data/lib/templates/app/Gemfile.tt +6 -0
- data/lib/templates/app/bin/app.tt +18 -0
- data/lib/templates/app/lib/app.tt +33 -0
- data/lib/templates/app/lib/app/version.tt +4 -0
- data/lib/templates/app/lib/tasks/sample.thor +10 -0
- data/rbapp.gemspec +25 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
## Overview
|
2
|
+
|
3
|
+
rbapp is a ([thor](http://github.com/wycats/thor) & bundler based) ruby console application generator. You get a dependency with thor, but I think the pros wins the cons:
|
4
|
+
|
5
|
+
- Your ruby app gets a neat console API: arguments, options,and help for free.
|
6
|
+
- Your app is modular and easy to extend: only add new thor tasks!
|
7
|
+
- Your app get gets a simple but powerfull template based generator.
|
8
|
+
- Your app is generated as a bundle based gem, so you get easy deployment
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
Of course, rbapp was generated by rbapp!
|
13
|
+
|
14
|
+
## Install & Use
|
15
|
+
|
16
|
+
To install:
|
17
|
+
|
18
|
+
gem install rbapp
|
19
|
+
|
20
|
+
For use:
|
21
|
+
|
22
|
+
rbapp myapp
|
23
|
+
=> generate an application named myapp in ./myapp dir
|
24
|
+
|
25
|
+
rbapp myapp --sample
|
26
|
+
|
27
|
+
=> generate also a sample task
|
28
|
+
|
29
|
+
rbapp --help
|
30
|
+
|
31
|
+
=> show options
|
32
|
+
|
33
|
+
# Help
|
34
|
+
|
35
|
+
|
36
|
+
Your generated app is a [thor](http://github.com/wycats/thor) "clone", so read [thor](http://github.com/wycats/thor) docs to get help about how create new tasks for your app.
|
37
|
+
rbapp is a very simple application: Read the source for better understanding: rbapp is it self rbapp generated, so it can show how your app works.
|
38
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/rbapp
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname($0), '..', 'lib')
|
5
|
+
require 'rbapp'
|
6
|
+
Rbapp::Runner.start(ARGV)
|
7
|
+
|
8
|
+
rescue Interrupt => e
|
9
|
+
puts "\nQuitting..."
|
10
|
+
puts e.backtrace.join("\n")
|
11
|
+
exit 1
|
12
|
+
rescue Exception => e
|
13
|
+
puts e.message
|
14
|
+
puts e.backtrace.join("\n")
|
15
|
+
exit 1
|
16
|
+
end
|
data/lib/rbapp.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rbapp/version"
|
2
|
+
require 'thor'
|
3
|
+
require 'thor/group'
|
4
|
+
|
5
|
+
module Rbapp
|
6
|
+
class Runner < Thor::Group
|
7
|
+
namespace ""
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
# Define arguments and options
|
11
|
+
argument :name
|
12
|
+
class_option :sample, type: :boolean, default: false
|
13
|
+
class_option :ocra, type: :boolean, default: false
|
14
|
+
|
15
|
+
def self.source_root
|
16
|
+
File.dirname(__FILE__)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_bin_file
|
20
|
+
template('templates/app/bin/app.tt', "#{name}/bin/#{name}.rb")
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_gem_file
|
24
|
+
template('templates/app/Gemfile.tt', "#{name}/Gemfile")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_app_file
|
28
|
+
template('templates/app/lib/app.tt', "#{name}/lib/#{name}.rb")
|
29
|
+
end
|
30
|
+
|
31
|
+
def create_version_file
|
32
|
+
template('templates/app/lib/app/version.tt', "#{name}/lib/#{name}/version.rb")
|
33
|
+
end
|
34
|
+
|
35
|
+
def copy_sample_task
|
36
|
+
return unless options.sample?
|
37
|
+
copy_file "templates/app/lib/tasks/sample.thor", "#{name}/lib/tasks/sample.thor"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
$LOAD_PATH.unshift File.join(File.dirname($0), '..', 'lib')
|
5
|
+
require 'bundler/setup'
|
6
|
+
require '<%= name %>'
|
7
|
+
<%= "ARGV << :list if defined?(Ocra) #force detect all tasks" if options.ocra? %>
|
8
|
+
<%= name.capitalize %>::Runner.start(ARGV)
|
9
|
+
|
10
|
+
rescue Interrupt => e
|
11
|
+
puts "\nQuitting..."
|
12
|
+
puts e.backtrace.join("\n")
|
13
|
+
exit 1
|
14
|
+
rescue Exception => e
|
15
|
+
puts e.message
|
16
|
+
puts e.backtrace.join("\n")
|
17
|
+
exit 1
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require 'thor/runner'
|
5
|
+
|
6
|
+
require '<%= name %>/version'
|
7
|
+
|
8
|
+
module Thor::Util #:nodoc:
|
9
|
+
SEARCH_ROOT = File.dirname(__FILE__)
|
10
|
+
# redefine to search tasks only for this app
|
11
|
+
def self.globs_for(path)
|
12
|
+
["#{SEARCH_ROOT}/*.thor", "#{SEARCH_ROOT}/tasks/*.thor"]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module <%= name.capitalize %>
|
17
|
+
EXE_NAME = File.basename($0, '.rb')
|
18
|
+
class Runner < Thor::Runner
|
19
|
+
# remove some tasks not needed
|
20
|
+
superclass.remove_task :install, :installed, :uninstall, :update
|
21
|
+
|
22
|
+
# default version and banner outputs THOR, so redefine it
|
23
|
+
|
24
|
+
def self.banner(task, all = false, subcommand = false)
|
25
|
+
"#{<%= name.capitalize %>::EXE_NAME} " + task.formatted_usage(self, all, subcommand)
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "version", "Show #{<%= name.capitalize %>::EXE_NAME} version"
|
29
|
+
def version
|
30
|
+
say "#{<%= name.capitalize %>::VERSION}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Sample < Thor
|
2
|
+
desc "echo TEXT", "a sample task"
|
3
|
+
method_options :upcase => :boolean, :sufix => :string
|
4
|
+
def echo(text)
|
5
|
+
out_text = text.dup
|
6
|
+
out_text.upcase! if options.upcase?
|
7
|
+
out_text += options.sufix if options.sufix?
|
8
|
+
say out_text
|
9
|
+
end
|
10
|
+
end
|
data/rbapp.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rbapp/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rbapp"
|
7
|
+
s.version = Rbapp::VERSION
|
8
|
+
s.authors = ["Jorge L. Cangas"]
|
9
|
+
s.email = ["jorge.cangas@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{ruby console app generator}
|
12
|
+
s.description = %q{ruby console app generator}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rbapp"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "thor"
|
24
|
+
end
|
25
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbapp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jorge L. Cangas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: &13071100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *13071100
|
25
|
+
description: ruby console app generator
|
26
|
+
email:
|
27
|
+
- jorge.cangas@gmail.com
|
28
|
+
executables:
|
29
|
+
- rbapp
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- .gitignore
|
34
|
+
- Gemfile
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- bin/rbapp
|
38
|
+
- lib/rbapp.rb
|
39
|
+
- lib/rbapp/version.rb
|
40
|
+
- lib/templates/app/Gemfile.tt
|
41
|
+
- lib/templates/app/bin/app.tt
|
42
|
+
- lib/templates/app/lib/app.tt
|
43
|
+
- lib/templates/app/lib/app/version.tt
|
44
|
+
- lib/templates/app/lib/tasks/sample.thor
|
45
|
+
- rbapp.gemspec
|
46
|
+
homepage: ''
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project: rbapp
|
66
|
+
rubygems_version: 1.8.10
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: ruby console app generator
|
70
|
+
test_files: []
|