Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 365 lines (304 sloc) 15.49 kb
a49613c @noklesta First commit
noklesta authored
1 import os
6129e21 @noklesta Put related files at the top of the list
noklesta authored
2 import re
a49613c @noklesta First commit
noklesta authored
3 import sublime
4 import sublime_plugin
7a0aee6 @noklesta Use recursive glob
noklesta authored
5 from recursive_glob import rglob
cc1c07b @noklesta Use inflector code
noklesta authored
6 from lib.inflector import *
a49613c @noklesta First commit
noklesta authored
7
8
9 class RailsMixin:
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
10 def get_setting(self, key):
11 settings = None
12 view = self.window.active_view()
13
14 if view:
15 settings = self.window.active_view().settings()
16
259a632 @noklesta Rename to SublimeRailsNav
noklesta authored
17 if settings and settings.has('SublimeRailsNav') and key in settings.get('SublimeRailsNav'):
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
18 # Get project-specific setting
259a632 @noklesta Rename to SublimeRailsNav
noklesta authored
19 dirs = settings.get('SublimeRailsNav')[key]
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
20 else:
21 # Get user-specific or default setting
259a632 @noklesta Rename to SublimeRailsNav
noklesta authored
22 settings = sublime.load_settings('SublimeRailsNav.sublime-settings')
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
23 dirs = settings.get(key)
24 return dirs
25
eadc4ff @noklesta Rename segment to dir
noklesta authored
26 def show_files(self, dirs, file_pattern='\.rb$'):
27 paths = self.construct_glob_paths(dirs)
6129e21 @noklesta Put related files at the top of the list
noklesta authored
28 self.find_files(paths, file_pattern)
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
29
36b768d @noklesta Remove current file from listings
noklesta authored
30 view = self.window.active_view()
31 if view:
32 current_file = view.file_name()
33 if self.is_listing_current_file_group(current_file):
34 self.remove_from_list(current_file)
35 else:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
36 self.move_related_files_to_top(current_file)
a49613c @noklesta First commit
noklesta authored
37
6129e21 @noklesta Put related files at the top of the list
noklesta authored
38 start_index = len(self.root) + 1
8f160be @noklesta Support listing of javascript files
noklesta authored
39 # Need to add a couple of spaces to avoid getting the file names cut off
40 relative_paths = map(lambda x: x[start_index:] + ' ', self.files)
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
41
f00f5eb @noklesta Change to WindowCommmand
noklesta authored
42 self.window.show_quick_panel(relative_paths, self.file_selected)
a49613c @noklesta First commit
noklesta authored
43
44 def rails_root(self):
314acf1 @noklesta Support Rails < 3
noklesta authored
45 # Look for a Gemfile first, since that should always be found in the
46 # root directory of a Rails 3 project. If no Gemfile is found, we
47 # might have a Rails 2 (or earlier) project, so look for a Rakefile
48 # instead. However, since Rakefiles may be found in subdirectories as
49 # well, in that case we also check for a number for additional
50 # standard Rails directories.
51 for root_indicator in ['Gemfile', 'Rakefile']:
b98bfc4 @noklesta Handle lack of any directories in sidebar
noklesta authored
52 folders = self.window.folders()
53 if len(folders) == 0:
54 return False
55
56 directory = folders[0]
314acf1 @noklesta Support Rails < 3
noklesta authored
57 while directory:
58 if os.path.exists(os.path.join(directory, root_indicator)):
59 if root_indicator == 'Gemfile':
60 return directory
61 else:
62 looks_like_root = True
63 for additional_dir in ['app', 'config', 'lib', 'vendor']:
64 if not (os.path.exists(os.path.join(directory, additional_dir))):
65 looks_like_root = False
66 break
67 if looks_like_root:
68 return directory
69
70 parent = os.path.realpath(os.path.join(directory, os.path.pardir))
71 if parent == directory:
72 # /.. == /
73 break
74 directory = parent
a49613c @noklesta First commit
noklesta authored
75 return False
76
eadc4ff @noklesta Rename segment to dir
noklesta authored
77 def construct_glob_paths(self, dirs):
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
78 paths = []
eadc4ff @noklesta Rename segment to dir
noklesta authored
79 for dir in dirs:
80 paths.append(os.path.join(self.root, *dir))
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
81 return paths
a49613c @noklesta First commit
noklesta authored
82
83 def file_selected(self, selected_index):
a725c24 @noklesta Handle canceling of quick panel
noklesta authored
84 if selected_index != -1:
85 self.window.open_file(self.files[selected_index])
a49613c @noklesta First commit
noklesta authored
86
6129e21 @noklesta Put related files at the top of the list
noklesta authored
87 def find_files(self, paths, file_pattern):
88 self.files = []
89 for path in paths:
90 self.files.extend(rglob(path, file_pattern))
a49613c @noklesta First commit
noklesta authored
91
36b768d @noklesta Remove current file from listings
noklesta authored
92 def remove_from_list(self, current_file):
eeb54a5 @noklesta Check if current file is in list before removing
noklesta authored
93 # First check to see if the current file is in the list. For instance,
94 # if the current file is under vendor/assets/javascripts and we did
95 # not include that among the javascript locations that we list,
96 # the current file will not in fact be there.
97 if current_file in self.files:
98 self.files.remove(current_file)
99 pass
6129e21 @noklesta Put related files at the top of the list
noklesta authored
100
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
101 def move_related_files_to_top(self, current_file):
102 related_file_name_pattern = self.construct_related_file_name_pattern(current_file)
36b768d @noklesta Remove current file from listings
noklesta authored
103
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
104 if related_file_name_pattern:
36b768d @noklesta Remove current file from listings
noklesta authored
105 for file in self.files:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
106 if re.search(related_file_name_pattern, file):
36b768d @noklesta Remove current file from listings
noklesta authored
107 i = self.files.index(file)
108 self.files.insert(0, self.files.pop(i))
6129e21 @noklesta Put related files at the top of the list
noklesta authored
109
110
111 class RailsCommandBase(sublime_plugin.WindowCommand, RailsMixin):
eadc4ff @noklesta Rename segment to dir
noklesta authored
112 MODEL_DIR = os.path.join('app', 'models')
113 CONTROLLER_DIR = os.path.join('app', 'controllers')
114 VIEW_DIR = os.path.join('app', 'views')
31c3fca @noklesta Show helper related to controller or spec at the top of the list
noklesta authored
115 HELPER_DIR = os.path.join('app', 'helpers')
5df1ace @noklesta List fixtures for active model, model test or controller test first
noklesta authored
116 FIXTURE_DIR = os.path.join('test', 'fixtures')
cc1c07b @noklesta Use inflector code
noklesta authored
117
5cd4c7a @noklesta Refactor
noklesta authored
118 def setup(self):
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
119 self.root = self.rails_root()
120 if not self.root:
121 sublime.error_message('No Rails root directory found. Not a Rails application?')
122 return False
5cd4c7a @noklesta Refactor
noklesta authored
123
124 if os.path.isdir(os.path.join(self.root, 'spec')):
125 # RSpec seems to be installed, so ignore the 'test' dir and search for specs
126 self.test_type = 'spec'
127 self.model_test_dir = os.path.join('spec', 'models')
128 self.controller_test_dir = os.path.join('spec', 'controllers')
444e812 @noklesta Show the test/spec for a view at the top of the list
noklesta authored
129 self.view_test_dir = os.path.join('spec', 'views')
31c3fca @noklesta Show helper related to controller or spec at the top of the list
noklesta authored
130 self.helper_test_dir = os.path.join('spec', 'helpers')
5cd4c7a @noklesta Refactor
noklesta authored
131 else:
132 # No RSpec, so use the standard 'test' dir
133 self.test_type = 'test'
134 self.model_test_dir = os.path.join('test', 'unit')
135 self.controller_test_dir = os.path.join('test', 'functional')
31c3fca @noklesta Show helper related to controller or spec at the top of the list
noklesta authored
136 self.helper_test_dir = os.path.join('test', 'unit', 'helpers')
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
137 return True
138
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
139 def construct_related_file_name_pattern(self, current_file):
6129e21 @noklesta Put related files at the top of the list
noklesta authored
140 pass
141
142
143 class ListRailsModelsCommand(RailsCommandBase):
f00f5eb @noklesta Change to WindowCommmand
noklesta authored
144 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
145 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
146 return
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
147 self.show_files([['app', 'models']])
a49613c @noklesta First commit
noklesta authored
148
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
149 def construct_related_file_name_pattern(self, current_file):
eadc4ff @noklesta Rename segment to dir
noklesta authored
150 if self.CONTROLLER_DIR in current_file:
cc1c07b @noklesta Use inflector code
noklesta authored
151 m = re.search(r'(\w+)_controller\.\w+$', current_file)
152 singular = Inflector().singularize(m.group(1))
153
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
154 pattern = re.sub(self.CONTROLLER_DIR, self.MODEL_DIR, current_file)
155 pattern = re.sub(r'\w+_controller(\.\w+$)', '%s\g<1>' % singular, pattern)
156 return pattern
ef7d204 @noklesta List model related to active fixture first
noklesta authored
157 elif self.FIXTURE_DIR in current_file:
158 m = re.search(r'(\w+)\.yml$', current_file)
159 singular = Inflector().singularize(m.group(1))
160
161 pattern = re.sub(self.FIXTURE_DIR, self.MODEL_DIR, current_file)
162 pattern = re.sub(r'\w+.yml$', '%s.rb' % singular, pattern)
163 return pattern
939d07e @noklesta Put model/model test and controller/controller test at top
noklesta authored
164 elif self.model_test_dir in current_file:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
165 pattern = re.sub(self.model_test_dir, self.MODEL_DIR, current_file)
5df1ace @noklesta List fixtures for active model, model test or controller test first
noklesta authored
166 pattern = re.sub(r'(_%s)(.\w+)$' % self.test_type, '\g<2>', pattern)
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
167 return pattern
6129e21 @noklesta Put related files at the top of the list
noklesta authored
168 else:
169 return None
170
36b768d @noklesta Remove current file from listings
noklesta authored
171 def is_listing_current_file_group(self, current_file):
101f3d3 @noklesta Make paths platform-independent
noklesta authored
172 return os.path.join('app', 'models') in current_file
36b768d @noklesta Remove current file from listings
noklesta authored
173
a49613c @noklesta First commit
noklesta authored
174
6129e21 @noklesta Put related files at the top of the list
noklesta authored
175 class ListRailsControllersCommand(RailsCommandBase):
f00f5eb @noklesta Change to WindowCommmand
noklesta authored
176 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
177 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
178 return
d5d84b4 @noklesta Support searching in multiple locations
noklesta authored
179 self.show_files([['app', 'controllers']])
588b42b @noklesta Support listing of Rails views
noklesta authored
180
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
181 def construct_related_file_name_pattern(self, current_file):
eadc4ff @noklesta Rename segment to dir
noklesta authored
182 if self.MODEL_DIR in current_file:
cc1c07b @noklesta Use inflector code
noklesta authored
183 m = re.search(r'(\w+)\.\w+$', current_file)
184 plural = Inflector().pluralize(m.group(1))
185
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
186 pattern = re.sub(self.MODEL_DIR, self.CONTROLLER_DIR, current_file)
187 pattern = re.sub(r'\w+(\.\w+)$', '%s_controller\g<1>' % plural, pattern)
188 return pattern
05fd399 @noklesta Show controller related to view at the top of the list
noklesta authored
189 elif self.VIEW_DIR in current_file:
190 pattern = re.sub(self.VIEW_DIR, self.CONTROLLER_DIR, current_file)
191 pattern = re.sub(os.path.join('', r'(\w+)', r'[\w\.]+$'), '\g<1>_controller', pattern)
192 return pattern
32a4c10 @noklesta Put controller related to helper at the top of the list
noklesta authored
193 if self.HELPER_DIR in current_file:
194 pattern = re.sub(self.HELPER_DIR, self.CONTROLLER_DIR, current_file)
195 pattern = re.sub(r'_helper\.rb$', '_controller\.rb', pattern)
196 return pattern
939d07e @noklesta Put model/model test and controller/controller test at top
noklesta authored
197 elif self.controller_test_dir in current_file:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
198 pattern = re.sub(self.controller_test_dir, self.CONTROLLER_DIR, current_file)
5df1ace @noklesta List fixtures for active model, model test or controller test first
noklesta authored
199 pattern = re.sub(r'(_%s)(.\w+)$' % self.test_type, '\g<2>', pattern)
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
200 return pattern
6129e21 @noklesta Put related files at the top of the list
noklesta authored
201 else:
202 return None
203
36b768d @noklesta Remove current file from listings
noklesta authored
204 def is_listing_current_file_group(self, current_file):
101f3d3 @noklesta Make paths platform-independent
noklesta authored
205 return os.path.join('app', 'controllers') in current_file
36b768d @noklesta Remove current file from listings
noklesta authored
206
588b42b @noklesta Support listing of Rails views
noklesta authored
207
6129e21 @noklesta Put related files at the top of the list
noklesta authored
208 class ListRailsViewsCommand(RailsCommandBase):
588b42b @noklesta Support listing of Rails views
noklesta authored
209 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
210 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
211 return
4fc4727 @noklesta Support Slim templates
noklesta authored
212 self.show_files([['app', 'views']], '\.(?:erb|haml|slim)$')
8f160be @noklesta Support listing of javascript files
noklesta authored
213
5b17efa @noklesta Show views related to controller at the top of the list
noklesta authored
214 def construct_related_file_name_pattern(self, current_file):
215 if self.CONTROLLER_DIR in current_file:
216 pattern = re.sub(self.CONTROLLER_DIR, self.VIEW_DIR, current_file)
217 pattern = re.sub(r'(\w+)_controller\.\w+$', '\g<1>' + os.sep, pattern)
218 return pattern
b433791 @noklesta Show views related to test/spec at the top of the list
noklesta authored
219 elif self.test_type == 'test' and self.controller_test_dir in current_file:
220 # With Test::Unit, view tests are found in the controller test
221 # file, so the best we can do is to show all views for the
222 # controller associated with the currently active controller test
223 # at the top of the list.
224 pattern = re.sub(self.controller_test_dir, self.VIEW_DIR, current_file)
225 pattern = re.sub(r'(\w+)_controller_test\.rb$', '\g<1>' + os.sep, pattern)
226 return pattern
227 elif self.test_type == 'spec' and self.view_test_dir in current_file:
228 # RSpec uses separate view specs, so here we can show the
229 # particular view associated with the currently active spec at the
230 # top of the list.
231 pattern = re.sub(self.view_test_dir, self.VIEW_DIR, current_file)
232 pattern = re.sub(r'(\w+)\.[\w\.]+$', '\g<1>\.', pattern)
233 return pattern
5b17efa @noklesta Show views related to controller at the top of the list
noklesta authored
234 else:
235 return None
236
36b768d @noklesta Remove current file from listings
noklesta authored
237 def is_listing_current_file_group(self, current_file):
101f3d3 @noklesta Make paths platform-independent
noklesta authored
238 return os.path.join('app', 'views') in current_file
36b768d @noklesta Remove current file from listings
noklesta authored
239
8f160be @noklesta Support listing of javascript files
noklesta authored
240
f882224 @noklesta Add command for listing helpers
noklesta authored
241 class ListRailsHelpersCommand(RailsCommandBase):
242 def run(self):
243 if not self.setup():
244 return
245 self.show_files([['app', 'helpers']])
246
31c3fca @noklesta Show helper related to controller or spec at the top of the list
noklesta authored
247 def construct_related_file_name_pattern(self, current_file):
248 if self.CONTROLLER_DIR in current_file:
249 pattern = re.sub(self.CONTROLLER_DIR, self.HELPER_DIR, current_file)
250 pattern = re.sub(r'_controller\.rb$', '_helper\.rb', pattern)
251 return pattern
252 elif self.helper_test_dir in current_file:
253 pattern = re.sub(self.helper_test_dir, self.HELPER_DIR, current_file)
5df1ace @noklesta List fixtures for active model, model test or controller test first
noklesta authored
254 pattern = re.sub(r'(_%s)(.\w+)$' % self.test_type, '\g<2>', pattern)
31c3fca @noklesta Show helper related to controller or spec at the top of the list
noklesta authored
255 return pattern
256 else:
257 return None
258
f882224 @noklesta Add command for listing helpers
noklesta authored
259 def is_listing_current_file_group(self, current_file):
101f3d3 @noklesta Make paths platform-independent
noklesta authored
260 return os.path.join('app', 'helpers') in current_file
f882224 @noklesta Add command for listing helpers
noklesta authored
261
262
ebb8bcf @noklesta Add command for listing fixtures
noklesta authored
263 class ListRailsFixturesCommand(RailsCommandBase):
264 def run(self):
265 if not self.setup():
266 return
267 self.show_files([['test', 'fixtures']], '\.yml$')
268
5df1ace @noklesta List fixtures for active model, model test or controller test first
noklesta authored
269 def construct_related_file_name_pattern(self, current_file):
270 if self.MODEL_DIR in current_file:
271 m = re.search(r'(\w+)\.rb$', current_file)
272 plural = Inflector().pluralize(m.group(1))
273
274 pattern = re.sub(self.MODEL_DIR, self.FIXTURE_DIR, current_file)
275 pattern = re.sub(r'\w+\.rb$', r'%s\.yml' % plural, pattern)
276 return pattern
277 elif self.model_test_dir in current_file:
278 m = re.search(r'(\w+)_%s\.rb$' % self.test_type, current_file)
279 plural = Inflector().pluralize(m.group(1))
280
281 pattern = re.sub(self.model_test_dir, self.FIXTURE_DIR, current_file)
282 pattern = re.sub(r'(\w+)_%s\.rb$' % self.test_type, r'%s\.yml' % plural, pattern)
283 return pattern
284 elif self.controller_test_dir in current_file:
285 m = re.search(r'(\w+)_controller_%s\.rb$' % self.test_type, current_file)
286 plural = Inflector().pluralize(m.group(1))
287
288 pattern = re.sub(self.controller_test_dir, self.FIXTURE_DIR, current_file)
289 pattern = re.sub(r'(\w+)_controller_%s\.rb$' % self.test_type, r'%s\.yml' % plural, pattern)
290 return pattern
291 else:
292 return None
293
ebb8bcf @noklesta Add command for listing fixtures
noklesta authored
294 def is_listing_current_file_group(self, current_file):
295 return os.path.join('test', 'fixtures') in current_file
296
297
2f43bdd @noklesta Add command for listing tests/specs
noklesta authored
298 class ListRailsTestsCommand(RailsCommandBase):
299 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
300 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
301 return
2f43bdd @noklesta Add command for listing tests/specs
noklesta authored
302
303 self.show_files([[self.test_type]])
304
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
305 def construct_related_file_name_pattern(self, current_file):
eadc4ff @noklesta Rename segment to dir
noklesta authored
306 if self.MODEL_DIR in current_file:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
307 pattern = re.sub(self.MODEL_DIR, self.model_test_dir, current_file)
308 pattern = re.sub(r'(\.\w+)$', '_%s\g<1>' % self.test_type, pattern)
309 return pattern
eadc4ff @noklesta Rename segment to dir
noklesta authored
310 elif self.CONTROLLER_DIR in current_file:
e8b1af1 @noklesta Support several related files matching a pattern
noklesta authored
311 pattern = re.sub(self.CONTROLLER_DIR, self.controller_test_dir, current_file)
312 pattern = re.sub(r'(\.\w+)$', '_%s\g<1>' % self.test_type, pattern)
313 return pattern
444e812 @noklesta Show the test/spec for a view at the top of the list
noklesta authored
314 elif self.VIEW_DIR in current_file:
315 if self.test_type == 'spec':
316 # RSpec uses separate view specs
317 pattern = re.sub(self.VIEW_DIR, self.view_test_dir, current_file)
318 pattern = re.sub(r'(\w+)\.[\w\.]+$', r'\g<1>[\w\.]*_spec\.rb', pattern)
319 else:
320 # Test::Unit puts view tests in the controller test file
321 pattern = re.sub(self.VIEW_DIR, self.controller_test_dir, current_file)
322 pattern = re.sub(r'(\w+)%s[\w\.]+$' % os.sep, '\g<1>_controller_test.rb', pattern)
323 return pattern
f12f13a @noklesta Put test/spec related to helper at the top of the list
noklesta authored
324 elif self.HELPER_DIR in current_file:
325 pattern = re.sub(self.HELPER_DIR, self.helper_test_dir, current_file)
326 pattern = re.sub(r'\.rb$', r'_%s\.rb' % self.test_type, pattern)
327 return pattern
ba4f17a @noklesta List model and controller tests related to active fixture first
noklesta authored
328 elif self.FIXTURE_DIR in current_file:
329 m = re.search(r'(\w+)\.yml$', current_file)
330 singular = Inflector().singularize(m.group(1))
331
332 pattern = re.sub(self.FIXTURE_DIR, r'(?:%s|%s)' % (self.model_test_dir, self.controller_test_dir), current_file)
333 pattern = re.sub(r'(\w+)\.yml$', r'(?:\g<1>_controller|%s)_%s\.rb' % (singular, self.test_type), pattern)
334 return pattern
acc36fd @noklesta List routing specs first if routes.rb is active and RSpec is used
noklesta authored
335 elif 'config/routes.rb' in current_file and self.test_type == 'spec':
336 pattern = os.path.join(self.root, 'spec', 'routing', '.+_routing_spec.rb')
337 return pattern
2f43bdd @noklesta Add command for listing tests/specs
noklesta authored
338 else:
339 return None
340
341 def is_listing_current_file_group(self, current_file):
ba4f17a @noklesta List model and controller tests related to active fixture first
noklesta authored
342 return os.path.join(self.root, self.test_type) in current_file and not self.FIXTURE_DIR in current_file
2f43bdd @noklesta Add command for listing tests/specs
noklesta authored
343
344
6129e21 @noklesta Put related files at the top of the list
noklesta authored
345 class ListRailsJavascriptsCommand(RailsCommandBase):
8f160be @noklesta Support listing of javascript files
noklesta authored
346 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
347 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
348 return
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
349 dirs = self.get_setting('javascript_locations')
350 self.show_files(dirs, '\.(?:js|coffee|erb)$')
dbf1a13 @noklesta Support listing of stylesheets
noklesta authored
351
36b768d @noklesta Remove current file from listings
noklesta authored
352 def is_listing_current_file_group(self, current_file):
353 return 'javascripts' in current_file
354
dbf1a13 @noklesta Support listing of stylesheets
noklesta authored
355
6129e21 @noklesta Put related files at the top of the list
noklesta authored
356 class ListRailsStylesheetsCommand(RailsCommandBase):
dbf1a13 @noklesta Support listing of stylesheets
noklesta authored
357 def run(self):
5cd4c7a @noklesta Refactor
noklesta authored
358 if not self.setup():
86c07c6 @noklesta Find Rails root at the beginning of each run
noklesta authored
359 return
6ba4bdb @noklesta Support project-specific and per-user settings
noklesta authored
360 dirs = self.get_setting('stylesheet_locations')
a130462 @jugyo add less
authored
361 self.show_files(dirs, '\.(?:css|scss|less)$')
36b768d @noklesta Remove current file from listings
noklesta authored
362
363 def is_listing_current_file_group(self, current_file):
364 return 'stylesheets' in current_file
Something went wrong with that request. Please try again.