teamster 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38b798f8b57a2391be2ce3588c257209a7161fd0
4
- data.tar.gz: dd6722aebe67f52210b84cac3739cf91b156a69b
3
+ metadata.gz: 7c5a470c1e28e2d662dc3c98942635606502e112
4
+ data.tar.gz: 7a5a7e6d1a5c615fdc84c95d1e31855948118c5e
5
5
  SHA512:
6
- metadata.gz: d1256ef9ea0ca19ff6015d10179ceb6dcd3aa3271fd1bdcf3022a78d201ca02a895c8dc22576463758a21a38fecfe2df794c92150fb3febe444a28545e9d3258
7
- data.tar.gz: 437dc59fa9b18722ca1593b022ee35e6baf03406a5e148cac30c8033d062d4c4fd29621a34219db2249fece8e1f446107c2db0b74ce89aa7f3dd0137c2042cba
6
+ metadata.gz: 32996c28d9f7ad620a41084ab884b5a8846998dd73641f1edffb5f53e00c0dbcd1c88245a4f226d48f24d559e36a71b6d8c0dda1779f624e50bf4b03f10b0522
7
+ data.tar.gz: f6ffded7e2a5fe8178cf9cc58cfefe33c24d0bf141aadfb3296d97d1c8af7c8daf75721dc51bdfff0e2d0623ed0def6789f418d3062c7dcb58f41ca4a31ee89c
data/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- 0.6.1
1
+ 0.7.0
2
2
 
data/bin/teamster CHANGED
@@ -28,27 +28,39 @@ class TeamsterApp
28
28
  ["--prod", GetoptLong::NO_ARGUMENT ],
29
29
  ["--help", GetoptLong::NO_ARGUMENT ],
30
30
  ["--overwrite", GetoptLong::NO_ARGUMENT ],
31
+ ["--local", GetoptLong::NO_ARGUMENT ],
32
+ ["--no-update", GetoptLong::NO_ARGUMENT ],
31
33
  ["--socket-file", GetoptLong::REQUIRED_ARGUMENT],
32
34
  ["--state-file", GetoptLong::REQUIRED_ARGUMENT])
33
- @config = {}.tap do |hsh|
35
+ @opts = {}.tap do |hsh|
34
36
  opts.each do |opt, arg|
35
37
  opt = opt[/--([\w-]+)/, 1].gsub(/-/, "_").to_sym
36
38
  arg ||= true
37
39
  hsh[opt] = arg
38
40
  end
39
41
  end
40
- @config
42
+ @opts
41
43
  end
42
44
 
45
+ ALLOWED_COMMANDS = [
46
+ :init, :list,
47
+ :create, :delete, :remove, :export, :import, :update,
48
+ :start, :stop, :restart
49
+ ]
50
+
43
51
  def run_app
44
- if @config[:help]
52
+ if @opts[:help]
45
53
  quit detailed_usage
46
- elsif @config[:version]
54
+ elsif @opts[:version]
47
55
  quit show_version
48
56
  elsif ARGV.size > 0
49
57
  command = ARGV.shift.to_sym
50
58
  args = ARGV
51
- send command, *args
59
+ if ALLOWED_COMMANDS.include?(command)
60
+ send command, *args
61
+ else
62
+ unknown command
63
+ end
52
64
  else
53
65
  quit usage
54
66
  end
@@ -58,14 +70,18 @@ class TeamsterApp
58
70
 
59
71
  # --{ COMMANDS }-- #
60
72
 
73
+ def unknown(command)
74
+ quit "\nUNKNOWN COMMAND: #{command}\nFor help, run command: teamster --help", 1
75
+ end
76
+
61
77
  def init(*args)
62
78
  current_working_folder = Dir.pwd
63
- team_name = args[0]
64
79
  content = File.dirname(__FILE__) + '/../content'
80
+ @config = {}
65
81
  puts "Initializing Teamster in current folder."
66
82
  puts "Creating required content..."
67
83
  FileUtils.mkdir_p "conf"
68
- create_config team_name
84
+ create_config
69
85
  FileUtils.mkdir_p "data"
70
86
  create_user
71
87
  FileUtils.cp_r "#{content}/views", current_working_folder
@@ -81,9 +97,9 @@ class TeamsterApp
81
97
  def start(*)
82
98
  puts "Starting teamster..."
83
99
  if File.exists?(CONFIG_FILE)
84
- if @config[:prod]
85
- socket_file = @config[:socket_file] || DEFAULT_UNIX_SOCKET_FILE
86
- state_file = @config[:state_file] || DEFAULT_APP_STATE_FILE
100
+ if @opts[:prod]
101
+ socket_file = @opts[:socket_file] || DEFAULT_UNIX_SOCKET_FILE
102
+ state_file = @opts[:state_file] || DEFAULT_APP_STATE_FILE
87
103
  Thread.new { exec "puma -d -b unix://#{socket_file} -S #{state_file}" }
88
104
  else
89
105
  Thread.new { exec "rackup -p 9292" }
@@ -95,7 +111,7 @@ class TeamsterApp
95
111
 
96
112
  def stop(*)
97
113
  puts "Stopping teamster..."
98
- state_file = @config[:state_file] || DEFAULT_APP_STATE_FILE
114
+ state_file = @opts[:state_file] || DEFAULT_APP_STATE_FILE
99
115
  if File.exists? state_file
100
116
  Thread.new { exec "pumactl -S #{state_file} stop" }
101
117
  else
@@ -106,7 +122,7 @@ class TeamsterApp
106
122
 
107
123
  def restart(*)
108
124
  puts "Restarting teamster..."
109
- state_file = @config[:state_file] || DEFAULT_APP_STATE_FILE
125
+ state_file = @opts[:state_file] || DEFAULT_APP_STATE_FILE
110
126
  if File.exists? state_file
111
127
  Thread.new { exec "pumactl -S #{state_file} restart" }
112
128
  else
@@ -115,22 +131,98 @@ class TeamsterApp
115
131
  end
116
132
 
117
133
  def create(*args)
118
- name = args[0]
119
- create_adapter_for name.downcase
134
+ name = args.join(' ')
135
+ if name =~ /_/
136
+ quit "Does not support adapter names containing underscores."
137
+ end
138
+ create_adapter_for name
139
+ end
140
+
141
+ def update(*args)
142
+ name = if args.empty?
143
+ nil
144
+ else
145
+ args.join(' ')
146
+ end
147
+ if name
148
+ update_adapter name
149
+ else
150
+ update_new_adapters
151
+ update_existing_adapters
152
+ end
153
+ end
154
+
155
+ def delete(*args)
156
+ unless @opts[:no_update]
157
+ update_new_adapters
158
+ update_existing_adapters
159
+ end
160
+ name = args.join(' ')
161
+ config = YAML.load_file(CONFIG_FILE)
162
+ adapters = config.fetch('adapters')
163
+ selected_adapter = adapters.find {|e| e.fetch("name") == name}
164
+ if selected_adapter
165
+ files = selected_adapter.fetch("files")
166
+ confirmation = ask_user "Are you sure you want to delete adapter \"#{name}\"? [y/N]"
167
+ if confirmation =~ /^y$|^yes$/i
168
+ files.each do |file|
169
+ FileUtils.rm file
170
+ end
171
+ adapters.delete_if {|e| e.fetch("name") == name}
172
+ File.open(CONFIG_FILE, 'w') {|fh| fh.write config.to_yaml}
173
+ quit "Successfully deleted adapter: #{name}"
174
+ else
175
+ quit "Deletion of adapter \"#{name}\" cancelled."
176
+ end
177
+ else
178
+ quit "Unable to find adapter: #{name}"
179
+ end
180
+ end
181
+ alias_method :remove, :delete
182
+
183
+ def list(*args)
184
+ unless @opts[:no_update]
185
+ update_new_adapters
186
+ update_existing_adapters
187
+ end
188
+ local = @opts[:local] || true
189
+ adapters = fetch_adapters
190
+ adapter_names = [].tap do |arr|
191
+ adapters.each {|hsh| arr << hsh.fetch('name')}
192
+ end
193
+ puts
194
+ puts "Adapters In Current Instance:"
195
+ adapter_names.each {|name| puts "- #{name}"}
120
196
  end
121
197
 
122
198
  def import(*args)
123
- name = args[0]
124
- import_adapter_for name.downcase
199
+ name = args.join(' ')
200
+ quit "Import not supported for now."
125
201
  end
126
202
 
127
203
  def export(*args)
128
- name = args[0]
129
- export_adapter_for name.downcase
204
+ unless @opts[:no_update]
205
+ update_new_adapters
206
+ update_existing_adapters
207
+ end
208
+ name = args.join(' ')
209
+ selected_adapter = fetch_adapter name
210
+ if selected_adapter
211
+ files = selected_adapter.fetch("files")
212
+ export_adapter name, files
213
+ else
214
+ quit "Adapter not found: #{name}"
215
+ end
130
216
  end
131
217
 
132
- # --{ HELPERS }-- #
218
+ def fetch_adapters
219
+ YAML.load_file(CONFIG_FILE).fetch('adapters')
220
+ end
133
221
 
222
+ def fetch_adapter(name)
223
+ adapters = fetch_adapters
224
+ adapters.find {|e| e.fetch("name") == name}
225
+ end
134
226
  end
135
227
  end
136
228
 
@@ -9,7 +9,7 @@
9
9
  <h3 class="panel-title"><%= name %></h3>
10
10
  </div>
11
11
  <div class="panel-body">
12
- <%= summary_of name%>
12
+ <%= summary_of name.gsub(' ', '_') %>
13
13
  <a class="small-text" href=<%= link %>><h6>More details...</h6></a>
14
14
  </div>
15
15
  </div>
data/lib/teamster-cli.rb CHANGED
@@ -10,12 +10,9 @@ module Teamster
10
10
  exit code
11
11
  end
12
12
 
13
- def create_config(team_name)
14
- if team_name
15
- @config[:title] = team_name
16
- else
17
- ask_user_for :title, "What is your team name"
18
- end
13
+ def create_config
14
+ @config['title'] = ask_user "What is your team name"
15
+ @config['adapters'] = []
19
16
  File.open(CONFIG_FILE, 'w') {|fh| fh.write @config.to_yaml}
20
17
  end
21
18
 
@@ -32,29 +29,87 @@ module Teamster
32
29
  Base64.strict_encode64(obj)
33
30
  end
34
31
 
35
- def ask_user_for(opt, question)
36
- unless @config[opt]
37
- @config[opt] = ask_user question
38
- end
39
- end
40
-
41
32
  def ask_user(question)
42
33
  print "#{question}: "
43
34
  STDIN.gets.strip
44
35
  end
45
36
 
37
+ def update_adapter(name)
38
+ config = YAML.load_file(CONFIG_FILE)
39
+ adapter = config.fetch('adapters').find {|e| e.fetch("name") == name}
40
+ quit "No local adapter found with name: #{name}" unless adapter
41
+ list_from_fs = Dir.glob("lib/teamster-adapters/#{name.gsub(' ', '_')}/**/*.*")
42
+ list_from_conf = adapter.fetch('files')
43
+ list_from_conf.concat(list_from_fs).uniq!
44
+ File.open(CONFIG_FILE, 'w') {|fh| fh.write config.to_yaml}
45
+ end
46
+
47
+ def update_new_adapters
48
+ config = YAML.load_file(CONFIG_FILE)
49
+ adapters = config.fetch('adapters')
50
+ current_adapters = Dir.glob("lib/teamster-adapters/*.rb").map do |f|
51
+ f.split('/').last.gsub('.rb', '').gsub('_', ' ')
52
+ end
53
+ current_adapters.each do |name|
54
+ next if adapters.find {|e| e.fetch("name") == name}
55
+ adapters << {}.tap do |hsh|
56
+ hsh["name"] = name
57
+ file_list = Dir.glob("lib/teamster-adapters/#{name.gsub(' ', '_')}/**/*.*")
58
+ file_list << "lib/teamster-adapters/#{name.gsub(' ', '_')}.rb"
59
+ hsh["files"] = file_list
60
+ end
61
+ end
62
+ File.open(CONFIG_FILE, 'w') {|fh| fh.write config.to_yaml}
63
+ end
64
+
65
+ def update_existing_adapters
66
+ config = YAML.load_file(CONFIG_FILE)
67
+ adapters = config.fetch('adapters')
68
+ current_adapters = Dir.glob("lib/teamster-adapters/*.rb").map do |f|
69
+ f.split('/').last.gsub('.rb', '').gsub('_', ' ')
70
+ end
71
+ current_adapters.each do |name|
72
+ adapter = adapters.find {|e| e.fetch("name") == name}
73
+ list_from_fs = Dir.glob("lib/teamster-adapters/#{name.gsub(' ', '_')}/**/*.*")
74
+ list_from_conf = adapter.fetch('files')
75
+ list_from_conf.concat(list_from_fs).uniq!
76
+ end
77
+ File.open(CONFIG_FILE, 'w') {|fh| fh.write config.to_yaml}
78
+ end
79
+
80
+ def add_adapter_to_config(name, filename)
81
+ @config = YAML.load_file CONFIG_FILE
82
+ adapter = {
83
+ 'name' => name,
84
+ 'files' => [
85
+ "lib/teamster-adapters/#{filename}.rb",
86
+ "lib/teamster-adapters/#{filename}/#{filename}_helper.rb",
87
+ "lib/teamster-adapters/#{filename}/views/#{filename}.erb",
88
+ "lib/teamster-adapters/#{filename}/views/#{filename}_summary.erb"
89
+ ]
90
+ }
91
+ @config.tap do |hsh|
92
+ adapters = hsh.fetch('adapters')
93
+ adapters << adapter
94
+ end
95
+ File.open(CONFIG_FILE, 'w') {|fh| fh.write @config.to_yaml}
96
+ end
97
+
46
98
  def create_adapter_for(name)
47
99
  puts "Creating placeholders for adapter #{name}...\n"
48
- FileUtils.mkdir_p "lib/teamster-adapters/#{name}/views"
49
- create_file "lib/teamster-adapters/#{name}.rb", "adapter_placeholder_for", name
50
- create_file "lib/teamster-adapters/#{name}/#{name}_helper.rb", "adapter_helper_placeholder_for", name
51
- create_file "lib/teamster-adapters/#{name}/views/#{name}.erb", "view_placeholder_for", name
52
- create_file "lib/teamster-adapters/#{name}/views/#{name}_summary.erb", "view_summary_placeholder_for", name
100
+ filename = name.split(' ').map{|a| a.downcase}.join('_')
101
+ class_name = name.split(' ').map{|a| a.capitalize}.join('')
102
+ FileUtils.mkdir_p "lib/teamster-adapters/#{filename}/views"
103
+ create_file "lib/teamster-adapters/#{filename}.rb", "adapter_placeholder_for", filename, class_name
104
+ create_file "lib/teamster-adapters/#{filename}/#{filename}_helper.rb", "adapter_helper_placeholder_for", filename, class_name
105
+ create_file "lib/teamster-adapters/#{filename}/views/#{filename}.erb", "view_placeholder_for", filename, class_name
106
+ create_file "lib/teamster-adapters/#{filename}/views/#{filename}_summary.erb", "view_summary_placeholder_for", filename, class_name
53
107
  puts "\nBasic adapter creation done!"
54
- puts "Controller : \"lib/teamster-adapters/#{name}.rb\""
55
- puts "Helper : \"lib/teamster-adapters/#{name}/#{name}_helper.rb\""
56
- puts "View : \"lib/teamster-adapters/#{name}/views/#{name}.erb\""
57
- puts "Summary View : \"lib/teamster-adapters/#{name}/views/#{name}_summary.erb\""
108
+ puts "Controller : \"lib/teamster-adapters/#{filename}.rb\""
109
+ puts "Helper : \"lib/teamster-adapters/#{filename}/#{filename}_helper.rb\""
110
+ puts "View : \"lib/teamster-adapters/#{filename}/views/#{filename}.erb\""
111
+ puts "Summary View : \"lib/teamster-adapters/#{filename}/views/#{filename}_summary.erb\""
112
+ add_adapter_to_config name, filename
58
113
  end
59
114
 
60
115
  def import_adapter_for(name)
@@ -72,22 +127,23 @@ module Teamster
72
127
  end
73
128
  end
74
129
 
75
- def export_adapter_for(name)
76
- puts "Exporting adapter: #{name}"
77
- zip_file = "#{name}.zip"
78
- puts "The following files will be zipped:"
79
- puts "- lib/teamster-adapters/#{name}.rb"
80
- puts '- Everything in folder lib/teamster-adapters/#{name}/'
130
+ def export_adapter(name, files)
131
+ zip_file = "#{name.gsub(' ', '_')}.zip"
132
+ puts "\nExporting adapter #{name} to zip: #{zip_file}\n\n"
133
+ puts "The following files will be exported into a zip file:"
134
+ files.each {|f| puts "- #{f}"}
135
+ puts
81
136
  if `which zip`.length != 0
82
- `zip -r #{zip_file} lib/teamster-adapters/#{name}.rb lib/teamster-adapters/#{name}/`
83
- puts "\nExported to #{zip_file}!"
84
- else
85
- puts "\nUnable to export adapter. Export depends on cli tool \"zip\"."
137
+ if system "zip -r #{zip_file} #{files.join(' ')}"
138
+ quit "\nExport successful!", 0
139
+ else
140
+ quit "\nError occurred when zipping!", 1
141
+ end
86
142
  end
87
143
  end
88
144
 
89
145
  def create_file(filename, method, *args)
90
- case [File.exists?(filename), !!@config[:overwrite]]
146
+ case [File.exists?(filename), !!@opts[:overwrite]]
91
147
  when [true, false]
92
148
  puts "File \"#{filename}\" exists. Run with --overwrite to overwrite file."
93
149
  else
@@ -105,12 +161,12 @@ module Teamster
105
161
  Initialize application:
106
162
  teamster init
107
163
 
164
+ Create an adapter:
165
+ teamster create my amazing adapter
166
+
108
167
  Run web application:
109
168
  teamster start
110
169
 
111
- Run web application in production (uses unix socket & state file):
112
- teamster start --prod [--socket-file FILE] [--state-file FILE]
113
-
114
170
  Verify by opening browser and navigating to "http://localhost:9292".
115
171
 
116
172
  For more detailed help, please run "teamster --help".
@@ -127,32 +183,77 @@ Usage:
127
183
  teamster [COMMAND] [OPTIONS]
128
184
 
129
185
  Commands:
130
- init, start, stop, restart
186
+ init, list, create, delete, export, import, update, start, stop, restart
131
187
 
132
188
  Options (standalone):
133
189
  --help Display this detailed help.
134
190
  --version Version of the teamster used.
135
- --create-adapter NAME Creates a stub of a adapter
136
- --import-adapter FILE << PENDING IMPLEMENTATION >>
137
- --export-adapter FILE << PENDING IMPLEMENTATION >>
138
191
 
139
192
 
140
- Options used with \"start\":
141
- --prod Binds a unix socket to be used by a web
142
- server (eg. Nginx) and creates a state file
143
- that is used by the Puma app server.
144
- --socket-file FILE Relative/absolute path to the UNIX socket file.
145
- --state-file FILE Relative/absolute path to the Puma state file.
193
+ Command \"init\" : Initializes the web app. Creates required files for web app.
194
+ Options:
195
+ --overwrite If app is already initialized, --overwrite will
196
+ recreate all the base files.
197
+
198
+
199
+ Command \"list\" Lists all teamster adapters.
200
+
201
+
202
+ Command \"create\" NAME Creates a skeleton of a teamster adapter. Creates a
203
+ new entry in the config file.
204
+
205
+
206
+ Command \"update\" NAME Updates the files for a teamster adapter in the
207
+ config file. NAME is optional. If NAME is not given,
208
+ all new and existing adapters are updated.
209
+
146
210
 
211
+ Command \"delete\" NAME Deletes all the files of the adapter based on the
212
+ config file.
213
+ Option:
214
+ --no-update Does not update new and existing adapters in the
215
+ config files before deletion.
147
216
 
148
- Options used with \"stop\":
149
- --socket-file FILE Relative/absolute path to the UNIX socket file.
150
- --state-file FILE Relative/absolute path to the Puma state file.
151
217
 
218
+ Command \"remove\" NAME Same as DELETE above.
152
219
 
153
- Options used with \"restart\":
154
- --socket-file FILE Relative/absolute path to the UNIX socket file.
155
- --state-file FILE Relative/absolute path to the Puma state file.
220
+
221
+ Command \"export\" NAME Zips all the files listed in the config file for
222
+ the specified adapter. Take care to scrub all
223
+ information in config files, etc.
224
+ Option:
225
+ --no-update Does not update new and existing adapters in the
226
+ config files before deletion.
227
+
228
+
229
+ Command \"import\" NAME Import is not yet implemented.
230
+
231
+
232
+ Command \"start\" : Used to run the teamster web app.
233
+ Options:
234
+ --prod Binds a unix socket to be used by a web
235
+ server (eg. Nginx) and creates a state file
236
+ that is used by the Puma app server.
237
+ --socket-file FILE Required with --prod. Relative/absolute path
238
+ to the UNIX socket file.
239
+ --state-file FILE Required with --prod. Relative/absolute path
240
+ to the Puma state file.
241
+
242
+
243
+ Command \"stop\" : Used to stop the teamster web app in production mode.
244
+ Options:
245
+ --socket-file FILE Required. Relative/absolute path to the UNIX
246
+ socket file.
247
+ --state-file FILE Required. Relative/absolute path to the Puma
248
+ state file.
249
+
250
+
251
+ Command \"restart\" : Used to restart the teamster web app in production mode.
252
+ Options:
253
+ --socket-file FILE Required. Relative/absolute path to the UNIX
254
+ socket file.
255
+ --state-file FILE Required. Relative/absolute path to the Puma
256
+ state file.
156
257
  DETAIL
157
258
  end
158
259
 
@@ -180,34 +281,38 @@ end
180
281
  CODE
181
282
  end
182
283
 
183
- def adapter_placeholder_for(name)
284
+ def adapter_placeholder_for(filename, class_name)
184
285
  <<-CODE
185
- require_relative \"#{name}/#{name}_helper\"
186
-
187
- \# NOTE: If the namespace is changed, please take care of the
188
- \# namespace of the sub-class and helper adapters.
286
+ require_relative \"#{filename}/#{filename}_helper\"
189
287
 
190
288
  module Teamster
191
289
  module Adapters
192
- class #{name.capitalize} < Sinatra::Base
290
+ class #{class_name} < Sinatra::Base
193
291
  \# Class methods that contain Teamster-Adapter specific helpers.
194
292
  include BaseAdapter
195
293
 
196
- \# Stuff that needs to be done before registration with core.
197
- has_helpers #{name.capitalize}Helper \# Add adapters here (comma separated) if there are helper adapters.
198
- views_at \"\#\{File.dirname(__FILE__)\}/#{name}/views\"
294
+ \# --{ Stuff that needs to be done before registration with core. }--
295
+
296
+ \# Add adapters here (comma separated) if there are helper adapters.
297
+ has_helpers #{class_name}Helper
298
+
299
+ \# Location of the views folder
300
+ views_at \"\#\{File.dirname(__FILE__)\}/#{filename}/views\"
301
+
199
302
  under_development \# Remove this line when development is finished.
303
+
304
+ \# ------------------------------------------------------------------
200
305
 
201
306
  \# Register this class so it can be used.
202
- register self
307
+ register self, "#{filename}"
203
308
 
204
309
  configure do
205
310
  enable :logging \# To log, use \"logger.info <MSG>\". Log messages are captured
206
311
  \# in the file specified in config.ru.
207
312
  end
208
313
 
209
- get '/#{name}/?' do
210
- erb :#{name}
314
+ get '/#{filename.gsub('_', '-')}/?' do
315
+ erb :#{filename}
211
316
  end
212
317
  end
213
318
  end
@@ -215,17 +320,17 @@ end
215
320
  CODE
216
321
  end
217
322
 
218
- def adapter_helper_placeholder_for(name)
323
+ def adapter_helper_placeholder_for(filename, class_name)
219
324
  <<-CODE
220
325
  module Teamster
221
326
  module Adapters
222
- module #{name.capitalize}Helper
223
- def #{name}_summary?
327
+ module #{class_name}Helper
328
+ def #{filename}_summary?
224
329
  true
225
330
  end
226
331
 
227
- def #{name}_summary
228
- erb :#{name}_summary
332
+ def #{filename}_summary
333
+ erb :#{filename}_summary
229
334
  end
230
335
  end
231
336
  end
@@ -233,14 +338,14 @@ end
233
338
  CODE
234
339
  end
235
340
 
236
- def view_placeholder_for(name)
341
+ def view_placeholder_for(filename, class_name)
237
342
  <<-CODE
238
- <h1 style='text-align: center'>PLACEHOLDER FOR #{name.upcase}</h1>
343
+ <h1 style='text-align: center'>PLACEHOLDER FOR #{filename.split('_').map{|a| a.upcase}.join(' ')}</h1>
239
344
  <p style='text-align: center'>Page under construction. Please check back later!</p>
240
345
  CODE
241
346
  end
242
347
 
243
- def view_summary_placeholder_for(name)
348
+ def view_summary_placeholder_for(filename, class_name)
244
349
  <<-CODE
245
350
  <p>Under development right now..</p>
246
351
  CODE
data/lib/teamster.rb CHANGED
@@ -13,12 +13,12 @@ module Teamster
13
13
  @@views = []
14
14
  @@title = 'TEAMSTER'
15
15
  @@root = Dir.pwd
16
- CORE_CONFIG = './conf/teamster.conf'
16
+ CORE_CONFIG = 'conf/teamster.conf'
17
17
 
18
18
  # NOTE: Class methods used in configure block needs be declared
19
19
  # before the configure block.
20
20
  def self.set_default_options_from(core_opts)
21
- @@title = core_opts[:title]
21
+ @@title = core_opts["title"]
22
22
  end
23
23
 
24
24
  configure do
@@ -54,12 +54,12 @@ module Teamster
54
54
  @@root
55
55
  end
56
56
 
57
- def self.use_adapter(teamster_adapter)
58
- if @@adapters.include? teamster_adapter
57
+ def self.use_adapter(teamster_adapter, name)
58
+ if @@adapters.include? [teamster_adapter, name]
59
59
  warn "Adapter #{teamster_adapter} already registered!"
60
60
  else
61
- @@adapters << teamster_adapter
62
- @@views << teamster_adapter.views
61
+ @@adapters << [teamster_adapter, name]
62
+ @@views << teamster_adapter.views
63
63
  end
64
64
  teamster_adapter.helpers GeneralHelper
65
65
  if teamster_adapter.has_helper?
@@ -6,8 +6,8 @@ module Teamster
6
6
  end
7
7
 
8
8
  module ClassMethods
9
- def register(klass)
10
- Teamster::Core::App.use_adapter klass
9
+ def register(klass, name)
10
+ Teamster::Core::App.use_adapter klass, name
11
11
  end
12
12
 
13
13
  def has_helpers(*adapters)
@@ -58,9 +58,10 @@ module Teamster
58
58
 
59
59
  def available_adapters(shuffle = false)
60
60
  available_adapters = [].tap do |arr|
61
- App.adapters.each do |mod|
62
- adapter_name = mod.to_s.split("::").last
63
- arr << ['/' + adapter_name.downcase, adapter_name] unless mod.under_development?
61
+ App.adapters.each do |adapter, name|
62
+ unless adapter.under_development?
63
+ arr << ['/' + name.gsub('_', '-'), name.split('_').map{|a| a.capitalize}.join(' ')]
64
+ end
64
65
  end
65
66
  end
66
67
  shuffle ? available_adapters.shuffle : available_adapters
@@ -68,18 +69,18 @@ module Teamster
68
69
 
69
70
  def developing_adapters
70
71
  [].tap do |arr|
71
- App.adapters.each do |mod|
72
- adapter_name = mod.to_s.split("::").last
73
- arr << ['/' + adapter_name.downcase, adapter_name] if mod.under_development?
72
+ App.adapters.each do |adapter, name|
73
+ if adapter.under_development?
74
+ arr << ['/' + name.gsub('_', '-'), name.split('_').map{|a| a.capitalize}.join(' ')]
75
+ end
74
76
  end
75
77
  end
76
78
  end
77
79
 
78
80
  def all_adapters(shuffle = false)
79
81
  all_adapters = [].tap do |arr|
80
- App.adapters.each do |mod|
81
- adapter_name = mod.to_s.split("::").last
82
- arr << ['/' + adapter_name.downcase, adapter_name]
82
+ App.adapters.each do |adapter, name|
83
+ arr << ['/' + name.gsub('_', '-'), name.split('_').map{|a| a.capitalize}.join(' ')]
83
84
  end
84
85
  end
85
86
  shuffle ? all_adapters.shuffle : all_adapters
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nur Muhammad Bin Sirat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-06 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma