this_town 0.0.2 → 0.0.3
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/bin/this_town +25 -6
- data/lib/this_town/generator.rb +4 -3
- data/lib/this_town/version.rb +1 -1
- metadata +2 -3
data/bin/this_town
CHANGED
@@ -1,12 +1,31 @@
|
|
1
1
|
# vim: set filetype=ruby:
|
2
|
+
require 'optparse'
|
2
3
|
require 'this_town'
|
3
4
|
|
5
|
+
options = {}
|
6
|
+
opts = OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{File.basename($0)} [options] <path>"
|
8
|
+
|
9
|
+
opts.on("-f", "--force", "Overwrite existing files") do |f|
|
10
|
+
options[:force] = true
|
11
|
+
end
|
12
|
+
|
13
|
+
opts.on_tail("--version", "Show version and quit") do
|
14
|
+
puts "#{File.basename($0)} #{ThisTown::VERSION}"
|
15
|
+
exit(0)
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
19
|
+
puts opts
|
20
|
+
exit(0)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.parse!
|
25
|
+
|
4
26
|
if ARGV.length != 1
|
5
|
-
|
6
|
-
|
7
|
-
elsif %w{-v --version}.include? ARGV.first
|
8
|
-
puts "#{File.basename($0)} #{ThisTown::VERSION}"
|
9
|
-
exit(0)
|
27
|
+
puts opts
|
28
|
+
exit(1)
|
10
29
|
else
|
11
|
-
ThisTown::Generator.new(ARGV.first).run
|
30
|
+
ThisTown::Generator.new(ARGV.first, options).run
|
12
31
|
end
|
data/lib/this_town/generator.rb
CHANGED
@@ -3,10 +3,11 @@ module ThisTown
|
|
3
3
|
TEMPLATES_PATH = File.expand_path(File.join(File.dirname(__FILE__),
|
4
4
|
"..", "..", "templates"))
|
5
5
|
|
6
|
-
def initialize(destination_root)
|
6
|
+
def initialize(destination_root, options = {})
|
7
7
|
@destination_root = destination_root
|
8
|
-
|
8
|
+
@force = options[:force]
|
9
9
|
|
10
|
+
base_name = File.basename(@destination_root)
|
10
11
|
@gem_name = base_name
|
11
12
|
constant_name = base_name.split('_').map { |p|
|
12
13
|
p[0..0].upcase + p[1..-1]
|
@@ -116,7 +117,7 @@ module ThisTown
|
|
116
117
|
|
117
118
|
def prepare_destination(destination_path)
|
118
119
|
out_path = File.expand_path(destination_path, @destination_root)
|
119
|
-
if File.exists?(out_path)
|
120
|
+
if !@force && File.exists?(out_path)
|
120
121
|
raise "file already exists: #{out_path}"
|
121
122
|
end
|
122
123
|
directory(File.dirname(out_path))
|
data/lib/this_town/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: this_town
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! 'Gem generator for Sinatra applications that use the following libraries:
|
15
15
|
sequel, mustache, test-unit, rack-test, mocha, guard'
|
@@ -78,4 +78,3 @@ signing_key:
|
|
78
78
|
specification_version: 3
|
79
79
|
summary: Gem generator for Sinatra applications
|
80
80
|
test_files: []
|
81
|
-
has_rdoc:
|