francis 0.0.4 → 1.0.0

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/francis +1 -1
  3. data/lib/francis.rb +76 -41
  4. metadata +11 -13
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2c1b4d040d1adc0b565872ed025acdc501ccaa8ee55d5554765c33a1fd3a758f
4
+ data.tar.gz: b8510bb2fa5aed08c0a552b8817ef361c02115159bb1e884a6ee094057eaadbd
5
+ SHA512:
6
+ metadata.gz: b0fd9dd66fc727614fa511d5da0a0648f6fc5985b39ad0e3a683ad381313a190c4fa11ceaa76bce4fdc885f8b41c6fd65a11aee9016c5ccd9a87e3ff1e594ee7
7
+ data.tar.gz: 4e7397f747fbd4f39c661635851690bea0ae9ec0b1e6a90ee8db5a991f1bc2da57a25c40a8a2207c9b798011f0caf142fd00ac57ce565f1edefcd7d7e191a211
@@ -3,4 +3,4 @@ require 'francis'
3
3
  args = ARGV.dup
4
4
  ARGV.clear
5
5
  command = args.shift.strip
6
- Francis.dispatch(command, args)
6
+ Francis.new(command, args)
@@ -7,33 +7,60 @@
7
7
  # This is the only and main class for the gem.
8
8
 
9
9
  class Francis
10
- @@folders = ["app","tmp","db","public","views","public/css","public/js","public/img"]
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"
15
-
16
- # Determines which method to call.
17
- def self.dispatch(command, args)
10
+
11
+
12
+ attr_accessor :folders, :files, :newhelp, :foldershelp, :fileshelp
13
+
14
+ # Creates a new instance of the class and directs the gem
15
+ # to the method based on the command passed to it.
16
+ def initialize(command, args)
17
+ @folders = ["app","public","views"]
18
+ @files = ["app/app.rb", "Gemfile","config.ru"]
19
+ @newhelp = %Q(
20
+ Usage:
21
+
22
+ francis new <appname> [--git][--proc][--readme][--unicorn][-r <gems>]
23
+
24
+ Creates a new Sinatra app.
25
+
26
+ <appname> => Name of the new directory
27
+
28
+ Options:
29
+
30
+ --git => sets up the directory up as a git repo
31
+ --proc => sets up the directory with a Procfile
32
+ --readme => sets up the directory with a readme.md
33
+ --unicorn => sets up the directory with config/unicorn.rb, pids/unicorn.pid and logs/unicorn.log
34
+ -r <gems> => adds gems to the Gemfile
35
+ )
36
+
37
+ @foldershelp = %Q(
38
+ francis folders
39
+
40
+ Prints a list of folders that are created when francis new is run.
41
+ )
42
+ @fileshelp = %Q(
43
+ francis files
44
+
45
+ Prints a list of files that are created when francis new is run.
46
+ )
18
47
  case command
19
48
  when 'new'
20
- Francis.new(args[0],args[1..-1])
49
+ run(args[0],args[1..-1])
21
50
  when 'folders'
22
- Francis.folders
51
+ puts folders
23
52
  when 'files'
24
- Francis.files
53
+ puts files
25
54
  when 'help'
26
- Francis.help(args)
55
+ help(args)
27
56
  else
28
- #Francis.help
29
57
  puts "I don't understand"
30
58
  end
31
59
  end
32
-
33
- # Creates a new working directory for Sinatra apps,
34
- # it takes two variables: a name to call the directory
35
- # and an option array.
36
- def self.new(name, options)
60
+
61
+ # Main run method, this will create the working directory
62
+ # and add any further files and folders based on the options passed to it.
63
+ def run(name, options)
37
64
  dir = Dir.getwd
38
65
  if Dir.exists?("#{dir}/#{name}")
39
66
  abort("There is already a folder with that name, please choose another.")
@@ -41,10 +68,10 @@ class Francis
41
68
  Dir.mkdir("#{dir}/#{name}")
42
69
  end
43
70
  Dir.chdir("#{dir}/#{name}")
44
- @@folders.each do |f|
71
+ folders.each do |f|
45
72
  Dir.mkdir(f)
46
73
  end
47
- @@files.each do |f|
74
+ files.each do |f|
48
75
  File.new(f,"w")
49
76
  end
50
77
  File.open("Gemfile","a") do |f|
@@ -77,38 +104,46 @@ class Francis
77
104
  end
78
105
  end
79
106
  end
107
+ if options.include?("--unicorn")
108
+ ["config", "pids", "logs"].each do |f|
109
+ Dir.mkdir(f)
110
+ end
111
+ File.open("config/unicorn.rb","a") do |f|
112
+ f.write %Q(
113
+ app_path = File.expand_path(File.dirname(__FILE__) + '/..')
114
+ working_directory app_path
115
+ pid app_path + "/pids/unicorn.pid"
116
+ stderr_path app_path + "/logs/unicorn.log"
117
+ stdout_path app_path + "/logs/unicorn.log"
118
+ listen "/tmp/unicorn.#{Dir.pwd}.sock"
119
+ worker_processes 2
120
+ timeout 60
121
+ )
122
+ end
123
+
124
+ end
125
+
80
126
  puts "Sinatra app '#{name}' created!"
81
127
  end
82
-
83
- # Prints the folders that are included in the directory
84
- # set up.
85
- def self.folders
86
- puts @@folders
87
- end
88
-
89
- # Prints the files that are included in the directory
90
- # set up.
91
- def self.files
92
- puts @@files
93
- end
94
-
128
+
129
+
95
130
  # Prints the help file.
96
- def self.help(*method)
131
+ def help(*method)
97
132
  if method.empty?
98
- puts @@newhelp + @@foldershelp + @@fileshelp
133
+ puts newhelp + foldershelp + fileshelp
99
134
  elsif method.length == 1
100
135
  case method[0][0]
101
136
  when "new"
102
- puts @@newhelp
137
+ puts newhelp
103
138
  when "folders"
104
- puts @@foldershelp
139
+ puts foldershelp
105
140
  when "files"
106
- puts @@fileshelp
141
+ puts fileshelp
107
142
  else
108
- puts @@newhelp + @@foldershelp + @@fileshelp
143
+ puts newhelp + foldershelp + fileshelp
109
144
  end
110
145
  else
111
- puts @@newhelp + @@foldershelp + @@fileshelp
146
+ puts newhelp + foldershelp + fileshelp
112
147
  end
113
148
  end
114
- end
149
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: francis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ian Kent
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-07 00:00:00.000000000 Z
11
+ date: 2020-04-26 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A command line tool for quickly setting up Sinatra apps
15
14
  email: ian@iankent.me
@@ -18,30 +17,29 @@ executables:
18
17
  extensions: []
19
18
  extra_rdoc_files: []
20
19
  files:
21
- - lib/francis.rb
22
20
  - bin/francis
23
- homepage: http://code.iankent.me/francis
24
- licenses: []
21
+ - lib/francis.rb
22
+ homepage: https://bitbucket.org/iankentforrestbrown/francis/
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
25
26
  post_install_message:
26
27
  rdoc_options: []
27
28
  require_paths:
28
29
  - lib
29
30
  required_ruby_version: !ruby/object:Gem::Requirement
30
- none: false
31
31
  requirements:
32
- - - ! '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  required_rubygems_version: !ruby/object:Gem::Requirement
36
- none: false
37
36
  requirements:
38
- - - ! '>='
37
+ - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0'
41
40
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 1.8.25
41
+ rubygems_version: 3.1.2
44
42
  signing_key:
45
- specification_version: 3
43
+ specification_version: 4
46
44
  summary: Francis
47
45
  test_files: []