francis 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/francis.rb +33 -4
  2. metadata +2 -2
data/lib/francis.rb CHANGED
@@ -9,6 +9,9 @@
9
9
  class Francis
10
10
  @@folders = ["app","tmp","db","public","views","public/css","public/js","public/img"]
11
11
  @@files = ["app/app.rb", "db/db.rb", "tmp/restart.txt", "Gemfile","config.ru"]
12
+ @@newhelp = "Usage:\n\nfrancis new <appname> [--git][--proc][--readme][-r <gems>]\n\nCreates a new Sinatra app.\n\n<appname> => Name of the new directory\n\nOptions\n\n--git => If present, will set the new directory up as a git repository\n\n--proc => If present, will set up the new directoy with a Procfile\n\n--readme => If present, will set up the new directory with a readme.md\n\n-r <gems> => Specify gems to be automatically included in your Gemfile\n\n"
13
+ @@foldershelp = "francis folders\n\nPrints a list of folders that are created when francis new is run.\n\n"
14
+ @@fileshelp = "francis files\n\nPrints a list of files that are created when francis new is run.\n\n"
12
15
 
13
16
  # Determines which method to call.
14
17
  def self.dispatch(command, args)
@@ -19,8 +22,11 @@ class Francis
19
22
  Francis.folders
20
23
  when 'files'
21
24
  Francis.files
25
+ when 'help'
26
+ Francis.help(args)
22
27
  else
23
- Francis.help
28
+ #Francis.help
29
+ puts "I don't understand"
24
30
  end
25
31
  end
26
32
 
@@ -42,7 +48,7 @@ class Francis
42
48
  File.new(f,"w")
43
49
  end
44
50
  File.open("Gemfile","a") do |f|
45
- f.write("source 'https://rubygems.org'\ngem 'sinatra'")
51
+ f.write("source 'https://rubygems.org'\ngem 'sinatra'\n")
46
52
  end
47
53
  if options.include?("--proc")
48
54
  File.open("Procfile","a") do |f|
@@ -63,6 +69,14 @@ class Francis
63
69
  f.write("# #{name.upcase}")
64
70
  end
65
71
  end
72
+ if options.include?("-r")
73
+ gems = options.select { |a| a[0] != "-" }
74
+ File.open("Gemfile","a") do |f|
75
+ gems.each do |g|
76
+ f.write("gem '#{g}'\n")
77
+ end
78
+ end
79
+ end
66
80
  puts "Sinatra app '#{name}' created!"
67
81
  end
68
82
 
@@ -79,7 +93,22 @@ class Francis
79
93
  end
80
94
 
81
95
  # Prints the help file.
82
- def self.help
83
- puts "Usage:\n\nfrancis new <appname> [--git]\n\nCreates a new Sinatra app.\n\n<appname> => Name of the new directory\n\n--git => If present, will set the new directory up as a git repository\n\nfrancis folders\n\nPrints a list of folders that are created when francis new is run.\n\nfrancis files\n\nPrints a list of files that are created when francis new is run."
96
+ def self.help(*method)
97
+ if method.empty?
98
+ puts @@newhelp + @@foldershelp + @@fileshelp
99
+ elsif method.length == 1
100
+ case method[0][0]
101
+ when "new"
102
+ puts @@newhelp
103
+ when "folders"
104
+ puts @@foldershelp
105
+ when "files"
106
+ puts @@fileshelp
107
+ else
108
+ puts @@newhelp + @@foldershelp + @@fileshelp
109
+ end
110
+ else
111
+ puts @@newhelp + @@foldershelp + @@fileshelp
112
+ end
84
113
  end
85
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: francis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-05-08 00:00:00.000000000 Z
12
+ date: 2013-06-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A command line tool for quickly setting up Sinatra apps
15
15
  email: ian@iankent.me