├── .gitignore
├── .hound.ruby.yml
├── .hound.yml
├── Gemfile
├── LICENSE
├── README.md
├── Rakefile
├── app
└── assets
│ ├── javascripts
│ └── selectivity.pl_PL.js.coffee
│ └── stylesheets
│ └── selectivity_bootstrap.sass
├── lib
└── selectivity
│ ├── rails.rb
│ ├── rails
│ └── version.rb
│ └── rspec.rb
├── selectivity-rails.gemspec
└── vendor
└── assets
├── javascripts
└── selectivity.js
└── stylesheets
├── selectivity.sass
└── selectivity
├── base.sass
├── dropdown.sass
├── input-types
├── multiple.sass
└── single.sass
├── plugins
└── submenu.sass
└── variables.sass
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | .bundle
4 | .config
5 | .yardoc
6 | Gemfile.lock
7 | InstalledFiles
8 | _yardoc
9 | coverage
10 | doc/
11 | lib/bundler/man
12 | pkg
13 | rdoc
14 | spec/reports
15 | test/tmp
16 | test/version_tmp
17 | tmp
18 |
--------------------------------------------------------------------------------
/.hound.ruby.yml:
--------------------------------------------------------------------------------
1 | AllCops:
2 | Include:
3 | - "**/*.gemspec"
4 | - "**/*.podspec"
5 | - "**/*.jbuilder"
6 | - "**/*.rake"
7 | - "**/*.opal"
8 | - "**/Gemfile"
9 | - "**/Rakefile"
10 | - "**/Capfile"
11 | - "**/Guardfile"
12 | - "**/Podfile"
13 | - "**/Thorfile"
14 | - "**/Vagrantfile"
15 | - "**/Berksfile"
16 | - "**/Cheffile"
17 | - "**/Vagabondfile"
18 | Exclude:
19 | - "vendor/**/*"
20 | - "db/schema.rb"
21 | RunRailsCops: false
22 | DisplayCopNames: false
23 | StyleGuideCopsOnly: false
24 | Style/AccessModifierIndentation:
25 | Description: Check indentation of private/protected visibility modifiers.
26 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected
27 | Enabled: true
28 | EnforcedStyle: indent
29 | SupportedStyles:
30 | - outdent
31 | - indent
32 | Style/AlignHash:
33 | Description: Align the elements of a hash literal if they span more than one line.
34 | Enabled: true
35 | EnforcedHashRocketStyle: key
36 | EnforcedColonStyle: key
37 | EnforcedLastArgumentHashStyle: always_inspect
38 | SupportedLastArgumentHashStyles:
39 | - always_inspect
40 | - always_ignore
41 | - ignore_implicit
42 | - ignore_explicit
43 | Style/AlignParameters:
44 | Description: Align the parameters of a method call if they span more than one line.
45 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-double-indent
46 | Enabled: true
47 | EnforcedStyle: with_first_parameter
48 | SupportedStyles:
49 | - with_first_parameter
50 | - with_fixed_indentation
51 | Style/AndOr:
52 | Description: Use &&/|| instead of and/or.
53 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-and-or-or
54 | Enabled: true
55 | EnforcedStyle: always
56 | SupportedStyles:
57 | - always
58 | - conditionals
59 | Style/BarePercentLiterals:
60 | Description: Checks if usage of %() or %Q() matches configuration.
61 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-q-shorthand
62 | Enabled: true
63 | EnforcedStyle: bare_percent
64 | SupportedStyles:
65 | - percent_q
66 | - bare_percent
67 | Style/BracesAroundHashParameters:
68 | Description: Enforce braces style around hash parameters.
69 | Enabled: true
70 | EnforcedStyle: no_braces
71 | SupportedStyles:
72 | - braces
73 | - no_braces
74 | - context_dependent
75 | Style/CaseIndentation:
76 | Description: Indentation of when in a case/when/[else/]end.
77 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#indent-when-to-case
78 | Enabled: true
79 | IndentWhenRelativeTo: case
80 | SupportedStyles:
81 | - case
82 | - end
83 | IndentOneStep: false
84 | Style/ClassAndModuleChildren:
85 | Description: Checks style of children classes and modules.
86 | Enabled: false
87 | EnforcedStyle: nested
88 | SupportedStyles:
89 | - nested
90 | - compact
91 | Style/ClassCheck:
92 | Description: Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.
93 | Enabled: true
94 | EnforcedStyle: is_a?
95 | SupportedStyles:
96 | - is_a?
97 | - kind_of?
98 | Style/CollectionMethods:
99 | Description: Preferred collection methods.
100 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
101 | Enabled: true
102 | PreferredMethods:
103 | collect: map
104 | collect!: map!
105 | find: detect
106 | find_all: select
107 | reduce: inject
108 | Style/CommentAnnotation:
109 | Description: Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK,
110 | REVIEW).
111 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#annotate-keywords
112 | Enabled: false
113 | Keywords:
114 | - TODO
115 | - FIXME
116 | - OPTIMIZE
117 | - HACK
118 | - REVIEW
119 | Style/DotPosition:
120 | Description: Checks the position of the dot in multi-line method calls.
121 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
122 | Enabled: true
123 | EnforcedStyle: trailing
124 | SupportedStyles:
125 | - leading
126 | - trailing
127 | Style/EmptyLineBetweenDefs:
128 | Description: Use empty lines between defs.
129 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods
130 | Enabled: true
131 | AllowAdjacentOneLineDefs: false
132 | Style/EmptyLinesAroundBlockBody:
133 | Description: Keeps track of empty lines around block bodies.
134 | Enabled: true
135 | EnforcedStyle: no_empty_lines
136 | SupportedStyles:
137 | - empty_lines
138 | - no_empty_lines
139 | Style/EmptyLinesAroundClassBody:
140 | Description: Keeps track of empty lines around class bodies.
141 | Enabled: true
142 | EnforcedStyle: no_empty_lines
143 | SupportedStyles:
144 | - empty_lines
145 | - no_empty_lines
146 | Style/EmptyLinesAroundModuleBody:
147 | Description: Keeps track of empty lines around module bodies.
148 | Enabled: true
149 | EnforcedStyle: no_empty_lines
150 | SupportedStyles:
151 | - empty_lines
152 | - no_empty_lines
153 | Style/Encoding:
154 | Description: Use UTF-8 as the source file encoding.
155 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#utf-8
156 | Enabled: false
157 | EnforcedStyle: always
158 | SupportedStyles:
159 | - when_needed
160 | - always
161 | Style/FileName:
162 | Description: Use snake_case for source file names.
163 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
164 | Enabled: false
165 | Exclude: []
166 | Style/FirstParameterIndentation:
167 | Description: Checks the indentation of the first parameter in a method call.
168 | Enabled: true
169 | EnforcedStyle: special_for_inner_method_call_in_parentheses
170 | SupportedStyles:
171 | - consistent
172 | - special_for_inner_method_call
173 | - special_for_inner_method_call_in_parentheses
174 | Style/For:
175 | Description: Checks use of for or each in multiline loops.
176 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-for-loops
177 | Enabled: true
178 | EnforcedStyle: each
179 | SupportedStyles:
180 | - for
181 | - each
182 | Style/FormatString:
183 | Description: Enforce the use of Kernel#sprintf, Kernel#format or String#%.
184 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#sprintf
185 | Enabled: false
186 | EnforcedStyle: format
187 | SupportedStyles:
188 | - format
189 | - sprintf
190 | - percent
191 | Style/GlobalVars:
192 | Description: Do not introduce global variables.
193 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#instance-vars
194 | Enabled: false
195 | AllowedVariables: []
196 | Style/GuardClause:
197 | Description: Check for conditionals that can be replaced with guard clauses
198 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
199 | Enabled: false
200 | MinBodyLength: 1
201 | Style/HashSyntax:
202 | Description: 'Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a =>
203 | 1, :b => 2 }.'
204 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-literals
205 | Enabled: true
206 | EnforcedStyle: ruby19
207 | SupportedStyles:
208 | - ruby19
209 | - hash_rockets
210 | Style/IfUnlessModifier:
211 | Description: Favor modifier if/unless usage when you have a single-line body.
212 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
213 | Enabled: false
214 | MaxLineLength: 80
215 | Style/IndentationWidth:
216 | Description: Use 2 spaces for indentation.
217 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
218 | Enabled: true
219 | Width: 2
220 | Style/IndentHash:
221 | Description: Checks the indentation of the first key in a hash literal.
222 | Enabled: true
223 | EnforcedStyle: special_inside_parentheses
224 | SupportedStyles:
225 | - special_inside_parentheses
226 | - consistent
227 | Style/LambdaCall:
228 | Description: Use lambda.call(...) instead of lambda.(...).
229 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#proc-call
230 | Enabled: false
231 | EnforcedStyle: call
232 | SupportedStyles:
233 | - call
234 | - braces
235 | Style/Next:
236 | Description: Use `next` to skip iteration instead of a condition at the end.
237 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
238 | Enabled: false
239 | EnforcedStyle: skip_modifier_ifs
240 | MinBodyLength: 3
241 | SupportedStyles:
242 | - skip_modifier_ifs
243 | - always
244 | Style/NonNilCheck:
245 | Description: Checks for redundant nil checks.
246 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-non-nil-checks
247 | Enabled: true
248 | IncludeSemanticChanges: false
249 | Style/MethodDefParentheses:
250 | Description: Checks if the method definitions have or don't have parentheses.
251 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-parens
252 | Enabled: true
253 | EnforcedStyle: require_parentheses
254 | SupportedStyles:
255 | - require_parentheses
256 | - require_no_parentheses
257 | Style/MethodName:
258 | Description: Use the configured style when naming methods.
259 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
260 | Enabled: true
261 | EnforcedStyle: snake_case
262 | SupportedStyles:
263 | - snake_case
264 | - camelCase
265 | Style/MultilineOperationIndentation:
266 | Description: Checks indentation of binary operations that span more than one line.
267 | Enabled: true
268 | EnforcedStyle: aligned
269 | SupportedStyles:
270 | - aligned
271 | - indented
272 | Style/NumericLiterals:
273 | Description: Add underscores to large numeric literals to improve their readability.
274 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics
275 | Enabled: false
276 | MinDigits: 5
277 | Style/ParenthesesAroundCondition:
278 | Description: Don't use parentheses around the condition of an if/unless/while.
279 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-parens-if
280 | Enabled: true
281 | AllowSafeAssignment: true
282 | Style/PercentLiteralDelimiters:
283 | Description: Use `%`-literal delimiters consistently
284 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
285 | Enabled: false
286 | PreferredDelimiters:
287 | "%": "()"
288 | "%i": "()"
289 | "%q": "()"
290 | "%Q": "()"
291 | "%r": "{}"
292 | "%s": "()"
293 | "%w": "()"
294 | "%W": "()"
295 | "%x": "()"
296 | Style/PercentQLiterals:
297 | Description: Checks if uses of %Q/%q match the configured preference.
298 | Enabled: true
299 | EnforcedStyle: lower_case_q
300 | SupportedStyles:
301 | - lower_case_q
302 | - upper_case_q
303 | Style/PredicateName:
304 | Description: Check the names of predicate methods.
305 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
306 | Enabled: true
307 | NamePrefix:
308 | - is_
309 | - has_
310 | - have_
311 | NamePrefixBlacklist:
312 | - is_
313 | Style/RaiseArgs:
314 | Description: Checks the arguments passed to raise/fail.
315 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
316 | Enabled: false
317 | EnforcedStyle: exploded
318 | SupportedStyles:
319 | - compact
320 | - exploded
321 | Style/RedundantReturn:
322 | Description: Don't use return where it's not required.
323 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-explicit-return
324 | Enabled: true
325 | AllowMultipleReturnValues: false
326 | Style/RegexpLiteral:
327 | Description: Use %r for regular expressions matching more than `MaxSlashes` '/'
328 | characters. Use %r only for regular expressions matching more than `MaxSlashes`
329 | '/' character.
330 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-r
331 | Enabled: false
332 | MaxSlashes: 1
333 | Style/Semicolon:
334 | Description: Don't use semicolons to terminate expressions.
335 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon
336 | Enabled: true
337 | AllowAsExpressionSeparator: false
338 | Style/SignalException:
339 | Description: Checks for proper usage of fail and raise.
340 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
341 | Enabled: false
342 | EnforcedStyle: semantic
343 | SupportedStyles:
344 | - only_raise
345 | - only_fail
346 | - semantic
347 | Style/SingleLineBlockParams:
348 | Description: Enforces the names of some block params.
349 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
350 | Enabled: false
351 | Methods:
352 | - reduce:
353 | - a
354 | - e
355 | - inject:
356 | - a
357 | - e
358 | Style/SingleLineMethods:
359 | Description: Avoid single-line methods.
360 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
361 | Enabled: false
362 | AllowIfMethodIsEmpty: true
363 | Style/StringLiterals:
364 | Description: Checks if uses of quotes match the configured preference.
365 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
366 | Enabled: true
367 | EnforcedStyle: single_quotes
368 | SupportedStyles:
369 | - single_quotes
370 | - double_quotes
371 | Style/StringLiteralsInInterpolation:
372 | Description: Checks if uses of quotes inside expressions in interpolated strings
373 | match the configured preference.
374 | Enabled: true
375 | EnforcedStyle: double_quotes
376 | SupportedStyles:
377 | - single_quotes
378 | - double_quotes
379 | Style/SpaceAroundBlockParameters:
380 | Description: Checks the spacing inside and after block parameters pipes.
381 | Enabled: true
382 | EnforcedStyleInsidePipes: no_space
383 | SupportedStyles:
384 | - space
385 | - no_space
386 | Style/SpaceAroundEqualsInParameterDefault:
387 | Description: Checks that the equals signs in parameter default assignments have
388 | or don't have surrounding space depending on configuration.
389 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-around-equals
390 | Enabled: true
391 | EnforcedStyle: space
392 | SupportedStyles:
393 | - space
394 | - no_space
395 | Style/SpaceBeforeBlockBraces:
396 | Description: Checks that the left block brace has or doesn't have space before it.
397 | Enabled: true
398 | EnforcedStyle: space
399 | SupportedStyles:
400 | - space
401 | - no_space
402 | Style/SpaceInsideBlockBraces:
403 | Description: Checks that block braces have or don't have surrounding space. For
404 | blocks taking parameters, checks that the left brace has or doesn't have trailing
405 | space.
406 | Enabled: true
407 | EnforcedStyle: space
408 | SupportedStyles:
409 | - space
410 | - no_space
411 | EnforcedStyleForEmptyBraces: no_space
412 | SpaceBeforeBlockParameters: true
413 | Style/SpaceInsideHashLiteralBraces:
414 | Description: Use spaces inside hash literal braces - or don't.
415 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
416 | Enabled: true
417 | EnforcedStyle: space
418 | EnforcedStyleForEmptyBraces: no_space
419 | SupportedStyles:
420 | - space
421 | - no_space
422 | Style/SymbolProc:
423 | Description: Use symbols as procs instead of blocks when possible.
424 | Enabled: true
425 | IgnoredMethods:
426 | - respond_to
427 | Style/TrailingBlankLines:
428 | Description: Checks trailing blank lines and final newline.
429 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#newline-eof
430 | Enabled: true
431 | EnforcedStyle: final_newline
432 | SupportedStyles:
433 | - final_newline
434 | - final_blank_line
435 | Style/TrailingComma:
436 | Description: Checks for trailing comma in parameter lists and literals.
437 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas
438 | Enabled: false
439 | EnforcedStyleForMultiline: no_comma
440 | SupportedStyles:
441 | - comma
442 | - no_comma
443 | Style/TrivialAccessors:
444 | Description: Prefer attr_* methods to trivial readers/writers.
445 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#attr_family
446 | Enabled: false
447 | ExactNameMatch: false
448 | AllowPredicates: false
449 | AllowDSLWriters: false
450 | Whitelist:
451 | - to_ary
452 | - to_a
453 | - to_c
454 | - to_enum
455 | - to_h
456 | - to_hash
457 | - to_i
458 | - to_int
459 | - to_io
460 | - to_open
461 | - to_path
462 | - to_proc
463 | - to_r
464 | - to_regexp
465 | - to_str
466 | - to_s
467 | - to_sym
468 | Style/VariableName:
469 | Description: Use the configured style when naming variables.
470 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
471 | Enabled: true
472 | EnforcedStyle: snake_case
473 | SupportedStyles:
474 | - snake_case
475 | - camelCase
476 | Style/WhileUntilModifier:
477 | Description: Favor modifier while/until usage when you have a single-line body.
478 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier
479 | Enabled: false
480 | MaxLineLength: 80
481 | Style/WordArray:
482 | Description: Use %w or %W for arrays of words.
483 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-w
484 | Enabled: false
485 | MinSize: 0
486 | WordRegex: !ruby/regexp /\A[\p{Word}]+\z/
487 | Metrics/AbcSize:
488 | Description: A calculated magnitude based on number of assignments, branches, and
489 | conditions.
490 | Enabled: true
491 | Max: 15
492 | Metrics/BlockNesting:
493 | Description: Avoid excessive block nesting
494 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count
495 | Enabled: false
496 | Max: 3
497 | Metrics/ClassLength:
498 | Description: Avoid classes longer than 100 lines of code.
499 | Enabled: false
500 | CountComments: false
501 | Max: 100
502 | Metrics/CyclomaticComplexity:
503 | Description: A complexity metric that is strongly correlated to the number of test
504 | cases needed to validate a method.
505 | Enabled: false
506 | Max: 6
507 | Metrics/LineLength:
508 | Description: Limit lines to 80 characters.
509 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#80-character-limits
510 | Enabled: true
511 | Max: 80
512 | AllowURI: true
513 | URISchemes:
514 | - http
515 | - https
516 | Metrics/MethodLength:
517 | Description: Avoid methods longer than 10 lines of code.
518 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
519 | Enabled: false
520 | CountComments: false
521 | Max: 10
522 | Metrics/ParameterLists:
523 | Description: Avoid parameter lists longer than three or four parameters.
524 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
525 | Enabled: false
526 | Max: 5
527 | CountKeywordArgs: true
528 | Metrics/PerceivedComplexity:
529 | Description: A complexity metric geared towards measuring complexity for a human
530 | reader.
531 | Enabled: false
532 | Max: 7
533 | Lint/AssignmentInCondition:
534 | Description: Don't use assignment in conditions.
535 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
536 | Enabled: false
537 | AllowSafeAssignment: true
538 | Lint/EndAlignment:
539 | Description: Align ends correctly.
540 | Enabled: true
541 | AlignWith: keyword
542 | SupportedStyles:
543 | - keyword
544 | - variable
545 | Lint/DefEndAlignment:
546 | Description: Align ends corresponding to defs correctly.
547 | Enabled: true
548 | AlignWith: start_of_line
549 | SupportedStyles:
550 | - start_of_line
551 | - def
552 | Rails/ActionFilter:
553 | Description: Enforces consistent use of action filter methods.
554 | Enabled: false
555 | EnforcedStyle: action
556 | SupportedStyles:
557 | - action
558 | - filter
559 | Include:
560 | - app/controllers/**/*.rb
561 | Rails/DefaultScope:
562 | Description: Checks if the argument passed to default_scope is a block.
563 | Enabled: true
564 | Include:
565 | - app/models/**/*.rb
566 | Rails/HasAndBelongsToMany:
567 | Description: Prefer has_many :through to has_and_belongs_to_many.
568 | Enabled: true
569 | Include:
570 | - app/models/**/*.rb
571 | Rails/Output:
572 | Description: Checks for calls to puts, print, etc.
573 | Enabled: true
574 | Include:
575 | - app/**/*.rb
576 | - config/**/*.rb
577 | - db/**/*.rb
578 | - lib/**/*.rb
579 | Rails/ReadWriteAttribute:
580 | Description: Checks for read_attribute(:attr) and write_attribute(:attr, val).
581 | Enabled: true
582 | Include:
583 | - app/models/**/*.rb
584 | Rails/ScopeArgs:
585 | Description: Checks the arguments of ActiveRecord scopes.
586 | Enabled: true
587 | Include:
588 | - app/models/**/*.rb
589 | Rails/Validation:
590 | Description: Use validates :attribute, hash of validations.
591 | Enabled: true
592 | Include:
593 | - app/models/**/*.rb
594 | Style/InlineComment:
595 | Description: Avoid inline comments.
596 | Enabled: false
597 | Style/MethodCalledOnDoEndBlock:
598 | Description: Avoid chaining a method call on a do...end block.
599 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
600 | Enabled: false
601 | Style/SymbolArray:
602 | Description: Use %i or %I for arrays of symbols.
603 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-i
604 | Enabled: false
605 | Style/ExtraSpacing:
606 | Description: Do not use unnecessary spacing.
607 | Enabled: true
608 | Style/AccessorMethodName:
609 | Description: Check the naming of accessor methods for get_/set_.
610 | Enabled: false
611 | Style/Alias:
612 | Description: Use alias_method instead of alias.
613 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
614 | Enabled: false
615 | Style/AlignArray:
616 | Description: Align the elements of an array literal if they span more than one line.
617 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays
618 | Enabled: true
619 | Style/ArrayJoin:
620 | Description: Use Array#join instead of Array#*.
621 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#array-join
622 | Enabled: false
623 | Style/AsciiComments:
624 | Description: Use only ascii symbols in comments.
625 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-comments
626 | Enabled: false
627 | Style/AsciiIdentifiers:
628 | Description: Use only ascii symbols in identifiers.
629 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#english-identifiers
630 | Enabled: false
631 | Style/Attr:
632 | Description: Checks for uses of Module#attr.
633 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#attr
634 | Enabled: false
635 | Style/BeginBlock:
636 | Description: Avoid the use of BEGIN blocks.
637 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks
638 | Enabled: true
639 | Style/BlockComments:
640 | Description: Do not use block comments.
641 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-block-comments
642 | Enabled: true
643 | Style/BlockEndNewline:
644 | Description: Put end statement of multiline block on its own line.
645 | Enabled: true
646 | Style/Blocks:
647 | Description: Avoid using {...} for multi-line blocks (multiline chaining is always
648 | ugly). Prefer {...} over do...end for single-line blocks.
649 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
650 | Enabled: true
651 | Style/CaseEquality:
652 | Description: Avoid explicit use of the case equality operator(===).
653 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-case-equality
654 | Enabled: false
655 | Style/CharacterLiteral:
656 | Description: Checks for uses of character literals.
657 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-character-literals
658 | Enabled: false
659 | Style/ClassAndModuleCamelCase:
660 | Description: Use CamelCase for classes and modules.
661 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#camelcase-classes
662 | Enabled: true
663 | Style/ClassMethods:
664 | Description: Use self when defining module/class methods.
665 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#def-self-singletons
666 | Enabled: true
667 | Style/ClassVars:
668 | Description: Avoid the use of class variables.
669 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-class-vars
670 | Enabled: false
671 | Style/ColonMethodCall:
672 | Description: 'Do not use :: for method call.'
673 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#double-colons
674 | Enabled: false
675 | Style/CommentIndentation:
676 | Description: Indentation of comments.
677 | Enabled: true
678 | Style/ConstantName:
679 | Description: Constants should use SCREAMING_SNAKE_CASE.
680 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#screaming-snake-case
681 | Enabled: true
682 | Style/DefWithParentheses:
683 | Description: Use def with parentheses when there are arguments.
684 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#method-parens
685 | Enabled: true
686 | Style/DeprecatedHashMethods:
687 | Description: Checks for use of deprecated Hash methods.
688 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-key
689 | Enabled: false
690 | Style/Documentation:
691 | Description: Document classes and non-namespace modules.
692 | Enabled: false
693 | Style/DoubleNegation:
694 | Description: Checks for uses of double negation (!!).
695 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
696 | Enabled: false
697 | Style/EachWithObject:
698 | Description: Prefer `each_with_object` over `inject` or `reduce`.
699 | Enabled: false
700 | Style/ElseAlignment:
701 | Description: Align elses and elsifs correctly.
702 | Enabled: true
703 | Style/EmptyElse:
704 | Description: Avoid empty else-clauses.
705 | Enabled: true
706 | Style/EmptyLines:
707 | Description: Don't use several empty lines in a row.
708 | Enabled: true
709 | Style/EmptyLinesAroundAccessModifier:
710 | Description: Keep blank lines around access modifiers.
711 | Enabled: true
712 | Style/EmptyLinesAroundMethodBody:
713 | Description: Keeps track of empty lines around method bodies.
714 | Enabled: true
715 | Style/EmptyLiteral:
716 | Description: Prefer literals to Array.new/Hash.new/String.new.
717 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
718 | Enabled: false
719 | Style/EndBlock:
720 | Description: Avoid the use of END blocks.
721 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-END-blocks
722 | Enabled: true
723 | Style/EndOfLine:
724 | Description: Use Unix-style line endings.
725 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#crlf
726 | Enabled: true
727 | Style/EvenOdd:
728 | Description: Favor the use of Fixnum#even? && Fixnum#odd?
729 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#predicate-methods
730 | Enabled: false
731 | Style/FlipFlop:
732 | Description: Checks for flip flops
733 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-flip-flops
734 | Enabled: false
735 | Style/IfWithSemicolon:
736 | Description: Do not use if x; .... Use the ternary operator instead.
737 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs
738 | Enabled: false
739 | Style/IndentationConsistency:
740 | Description: Keep indentation straight.
741 | Enabled: true
742 | Style/IndentArray:
743 | Description: Checks the indentation of the first element in an array literal.
744 | Enabled: true
745 | Style/InfiniteLoop:
746 | Description: Use Kernel#loop for infinite loops.
747 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#infinite-loop
748 | Enabled: true
749 | Style/Lambda:
750 | Description: Use the new lambda literal syntax for single-line blocks.
751 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#lambda-multi-line
752 | Enabled: false
753 | Style/LeadingCommentSpace:
754 | Description: Comments should start with a space.
755 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#hash-space
756 | Enabled: true
757 | Style/LineEndConcatenation:
758 | Description: Use \ instead of + or << to concatenate two string literals at line
759 | end.
760 | Enabled: false
761 | Style/MethodCallParentheses:
762 | Description: Do not use parentheses for method calls with no arguments.
763 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-args-no-parens
764 | Enabled: true
765 | Style/ModuleFunction:
766 | Description: Checks for usage of `extend self` in modules.
767 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
768 | Enabled: false
769 | Style/MultilineBlockChain:
770 | Description: Avoid multi-line chains of blocks.
771 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#single-line-blocks
772 | Enabled: true
773 | Style/MultilineBlockLayout:
774 | Description: Ensures newlines after multiline block do statements.
775 | Enabled: true
776 | Style/MultilineIfThen:
777 | Description: Do not use then for multi-line if/unless.
778 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-then
779 | Enabled: true
780 | Style/MultilineTernaryOperator:
781 | Description: 'Avoid multi-line ?: (the ternary operator); use if/unless instead.'
782 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary
783 | Enabled: true
784 | Style/NegatedIf:
785 | Description: Favor unless over if for negative conditions (or control flow or).
786 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#unless-for-negatives
787 | Enabled: false
788 | Style/NegatedWhile:
789 | Description: Favor until over while for negative conditions.
790 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#until-for-negatives
791 | Enabled: false
792 | Style/NestedTernaryOperator:
793 | Description: Use one expression per branch in a ternary operator.
794 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-ternary
795 | Enabled: true
796 | Style/NilComparison:
797 | Description: Prefer x.nil? to x == nil.
798 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#predicate-methods
799 | Enabled: false
800 | Style/Not:
801 | Description: Use ! instead of not.
802 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#bang-not-not
803 | Enabled: false
804 | Style/OneLineConditional:
805 | Description: Favor the ternary operator(?:) over if/then/else/end constructs.
806 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
807 | Enabled: false
808 | Style/OpMethod:
809 | Description: When defining binary operators, name the argument other.
810 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#other-arg
811 | Enabled: false
812 | Style/PerlBackrefs:
813 | Description: Avoid Perl-style regex back references.
814 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
815 | Enabled: false
816 | Style/Proc:
817 | Description: Use proc instead of Proc.new.
818 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#proc
819 | Enabled: false
820 | Style/RedundantBegin:
821 | Description: Don't use begin blocks when they are not needed.
822 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#begin-implicit
823 | Enabled: true
824 | Style/RedundantException:
825 | Description: Checks for an obsolete RuntimeException argument in raise/fail.
826 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-explicit-runtimeerror
827 | Enabled: true
828 | Style/RedundantSelf:
829 | Description: Don't use self where it's not needed.
830 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-self-unless-required
831 | Enabled: true
832 | Style/RescueModifier:
833 | Description: Avoid using rescue in its modifier form.
834 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers
835 | Enabled: true
836 | Style/SelfAssignment:
837 | Description: Checks for places where self-assignment shorthand should have been
838 | used.
839 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#self-assignment
840 | Enabled: false
841 | Style/SingleSpaceBeforeFirstArg:
842 | Description: Checks that exactly one space is used between a method name and the
843 | first argument for method calls without parentheses.
844 | Enabled: true
845 | Style/SpaceAfterColon:
846 | Description: Use spaces after colons.
847 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
848 | Enabled: true
849 | Style/SpaceAfterComma:
850 | Description: Use spaces after commas.
851 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
852 | Enabled: true
853 | Style/SpaceAfterControlKeyword:
854 | Description: Use spaces after if/elsif/unless/while/until/case/when.
855 | Enabled: true
856 | Style/SpaceAfterMethodName:
857 | Description: Do not put a space between a method name and the opening parenthesis
858 | in a method definition.
859 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-no-spaces
860 | Enabled: true
861 | Style/SpaceAfterNot:
862 | Description: Tracks redundant space after the ! operator.
863 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-bang
864 | Enabled: true
865 | Style/SpaceAfterSemicolon:
866 | Description: Use spaces after semicolons.
867 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
868 | Enabled: true
869 | Style/SpaceBeforeComma:
870 | Description: No spaces before commas.
871 | Enabled: true
872 | Style/SpaceBeforeComment:
873 | Description: Checks for missing space between code and a comment on the same line.
874 | Enabled: true
875 | Style/SpaceBeforeSemicolon:
876 | Description: No spaces before semicolons.
877 | Enabled: true
878 | Style/SpaceAroundOperators:
879 | Description: Use spaces around operators.
880 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-operators
881 | Enabled: true
882 | Style/SpaceBeforeModifierKeyword:
883 | Description: Put a space before the modifier keyword.
884 | Enabled: true
885 | Style/SpaceInsideBrackets:
886 | Description: No spaces after [ or before ].
887 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-spaces-braces
888 | Enabled: true
889 | Style/SpaceInsideParens:
890 | Description: No spaces after ( or before ).
891 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-spaces-braces
892 | Enabled: true
893 | Style/SpaceInsideRangeLiteral:
894 | Description: No spaces inside range literals.
895 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-space-inside-range-literals
896 | Enabled: true
897 | Style/SpecialGlobalVars:
898 | Description: Avoid Perl-style global variables.
899 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
900 | Enabled: false
901 | Style/StructInheritance:
902 | Description: Checks for inheritance from Struct.new.
903 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-extend-struct-new
904 | Enabled: true
905 | Style/Tab:
906 | Description: No hard tabs.
907 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#spaces-indentation
908 | Enabled: true
909 | Style/TrailingWhitespace:
910 | Description: Avoid trailing whitespace.
911 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace
912 | Enabled: true
913 | Style/UnlessElse:
914 | Description: Do not use unless with else. Rewrite these with the positive case first.
915 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-else-with-unless
916 | Enabled: true
917 | Style/UnneededCapitalW:
918 | Description: Checks for %W when interpolation is not needed.
919 | Enabled: true
920 | Style/UnneededPercentQ:
921 | Description: Checks for %q/%Q when single quotes or double quotes would do.
922 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-q
923 | Enabled: true
924 | Style/UnneededPercentX:
925 | Description: Checks for %x when `` would do.
926 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-x
927 | Enabled: true
928 | Style/VariableInterpolation:
929 | Description: Don't interpolate global, instance and class variables directly in
930 | strings.
931 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
932 | Enabled: false
933 | Style/WhenThen:
934 | Description: Use when x then ... for one-line cases.
935 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
936 | Enabled: false
937 | Style/WhileUntilDo:
938 | Description: Checks for redundant do after while or until.
939 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-multiline-while-do
940 | Enabled: true
941 | Lint/AmbiguousOperator:
942 | Description: Checks for ambiguous operators in the first argument of a method invocation
943 | without parentheses.
944 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-as-args
945 | Enabled: false
946 | Lint/AmbiguousRegexpLiteral:
947 | Description: Checks for ambiguous regexp literals in the first argument of a method
948 | invocation without parenthesis.
949 | Enabled: false
950 | Lint/BlockAlignment:
951 | Description: Align block ends correctly.
952 | Enabled: true
953 | Lint/ConditionPosition:
954 | Description: Checks for condition placed in a confusing position relative to the
955 | keyword.
956 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#same-line-condition
957 | Enabled: false
958 | Lint/Debugger:
959 | Description: Check for debugger calls.
960 | Enabled: true
961 | Lint/DeprecatedClassMethods:
962 | Description: Check for deprecated class method calls.
963 | Enabled: false
964 | Lint/DuplicateMethods:
965 | Description: Check for duplicate methods calls.
966 | Enabled: true
967 | Lint/ElseLayout:
968 | Description: Check for odd code arrangement in an else block.
969 | Enabled: false
970 | Lint/EmptyEnsure:
971 | Description: Checks for empty ensure block.
972 | Enabled: true
973 | Lint/EmptyInterpolation:
974 | Description: Checks for empty string interpolation.
975 | Enabled: true
976 | Lint/EndInMethod:
977 | Description: END blocks should not be placed inside method definitions.
978 | Enabled: true
979 | Lint/EnsureReturn:
980 | Description: Do not use return in an ensure block.
981 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-return-ensure
982 | Enabled: true
983 | Lint/Eval:
984 | Description: The use of eval represents a serious security risk.
985 | Enabled: true
986 | Lint/HandleExceptions:
987 | Description: Don't suppress exception.
988 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
989 | Enabled: false
990 | Lint/InvalidCharacterLiteral:
991 | Description: Checks for invalid character literals with a non-escaped whitespace
992 | character.
993 | Enabled: false
994 | Lint/LiteralInCondition:
995 | Description: Checks of literals used in conditions.
996 | Enabled: false
997 | Lint/LiteralInInterpolation:
998 | Description: Checks for literals used in interpolation.
999 | Enabled: false
1000 | Lint/Loop:
1001 | Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while
1002 | for post-loop tests.
1003 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#loop-with-break
1004 | Enabled: false
1005 | Lint/ParenthesesAsGroupedExpression:
1006 | Description: Checks for method calls with a space before the opening parenthesis.
1007 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#parens-no-spaces
1008 | Enabled: false
1009 | Lint/RequireParentheses:
1010 | Description: Use parentheses in the method call to avoid confusion about precedence.
1011 | Enabled: false
1012 | Lint/RescueException:
1013 | Description: Avoid rescuing the Exception class.
1014 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-blind-rescues
1015 | Enabled: true
1016 | Lint/ShadowingOuterLocalVariable:
1017 | Description: Do not use the same name as outer local variable for block arguments
1018 | or block local variables.
1019 | Enabled: true
1020 | Lint/SpaceBeforeFirstArg:
1021 | Description: Put a space between a method name and the first argument in a method
1022 | call without parentheses.
1023 | Enabled: true
1024 | Lint/StringConversionInInterpolation:
1025 | Description: Checks for Object#to_s usage in string interpolation.
1026 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-to-s
1027 | Enabled: true
1028 | Lint/UnderscorePrefixedVariableName:
1029 | Description: Do not use prefix `_` for a variable that is used.
1030 | Enabled: false
1031 | Lint/UnusedBlockArgument:
1032 | Description: Checks for unused block arguments.
1033 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
1034 | Enabled: true
1035 | Lint/UnusedMethodArgument:
1036 | Description: Checks for unused method arguments.
1037 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
1038 | Enabled: true
1039 | Lint/UnreachableCode:
1040 | Description: Unreachable code.
1041 | Enabled: true
1042 | Lint/UselessAccessModifier:
1043 | Description: Checks for useless access modifiers.
1044 | Enabled: true
1045 | Lint/UselessAssignment:
1046 | Description: Checks for useless assignment to a local variable.
1047 | StyleGuide: https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars
1048 | Enabled: true
1049 | Lint/UselessComparison:
1050 | Description: Checks for comparison of something with itself.
1051 | Enabled: true
1052 | Lint/UselessElseWithoutRescue:
1053 | Description: Checks for useless `else` in `begin..end` without `rescue`.
1054 | Enabled: true
1055 | Lint/UselessSetterCall:
1056 | Description: Checks for useless setter call to a local variable.
1057 | Enabled: true
1058 | Lint/Void:
1059 | Description: Possible use of operator/literal/variable in void context.
1060 | Enabled: false
1061 | Rails/Delegate:
1062 | Description: Prefer delegate method for delegations.
1063 | Enabled: false
1064 |
--------------------------------------------------------------------------------
/.hound.yml:
--------------------------------------------------------------------------------
1 | ruby:
2 | config_file: .hound.ruby.yml
3 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | # Specify your gem's dependencies in selectivity-rails.gemspec
4 | gemspec
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Konrad Jurkowski
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://badge.fury.io/rb/selectivity-rails)
2 | [](https://codeclimate.com/github/msx2/selectivity-rails)
3 | [](https://gitter.im/msx2/selectivity-rails?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4 |
5 | # Selectivity.js for Rails' Asset Pipeline
6 |
7 | [Selectivity.js](https://github.com/arendjr/selectivity) is a modular and light-weight selection library for jQuery and Zepto.js.
8 |
9 | ## Installation and usage
10 |
11 | Add `selectivity-rails` to Gemfile of your Rails application and run `bundle install`:
12 |
13 | ```
14 | gem 'selectivity-rails'
15 | ```
16 |
17 | ### JavaScript
18 | Add the following to your JavaScript manifest, by default `app/assets/javascripts/application.js`:
19 |
20 | ```javascript
21 | //= require selectivity
22 | ```
23 |
24 | #### Internationalization (i18n)
25 | Selectivity.js uses English by default, however `selectivity-rails` supports multiple languages. Add the following to your JavaScript manifest, e.g. `app/assets/javascripts/application.js`:
26 |
27 | ```javascript
28 | //= require selectivity.xx
29 | ```
30 |
31 | where `xx` is the code of supported language. Currently supported are:
32 |
33 | Code | Language
34 | --- | ---
35 | `pl_PL` | Polish
36 |
37 | I18n file should be included **after** default `selectivity` script.
38 |
39 | ### Stylesheets
40 | Add the following to your stylesheet manifest, by default `app/assets/stylesheets/application.sass`:
41 |
42 | ```sass
43 | @import 'selectivity'
44 | ```
45 |
46 | If you use `application.css` default format, you might not be able to access mixins or variables. Use `.scss` or `.sass` syntax instead.
47 |
48 | For the basic styling supporting [`simple_form`](https://github.com/plataformatec/simple_form) and [Bootstrap](http://getbootstrap.com), import also `selectivity_bootstrap` stylesheet:
49 |
50 | ```sass
51 | @import 'selectivity'
52 | @import 'selectivity_bootstrap'
53 | ```
54 |
55 | #### Customization
56 | Selectivity.js is written in Sass and allows basic customization. For the list of all supported variables refer to [selectivity/variables.sass](https://github.com/msx2/selectivity-rails/blob/master/vendor/assets/stylesheets/selectivity/variables.sass)
57 |
58 | To use customization, import your `variables` file before `selectivity`:
59 |
60 | ```sass
61 | @import 'variables'
62 | @import 'selectivity'
63 | ```
64 |
65 | #### Icons: Font Awesome
66 | By default, Selectivity.js uses [Font Awesome](http://fortawesome.github.io/Font-Awesome) icons.
67 |
68 | If you don't use Font Awesome, you can install [`font-awesome-rails`](https://github.com/bokmann/font-awesome-rails) gem, or manually override styling for following CSS classes:
69 |
70 | ```sass
71 | .fa.fa-remove
72 | .fa.fa-chevron-right
73 | .fa.fa-sort-desc
74 | ```
75 |
76 | ## RSpec helpers
77 | `selectivity-rails` provides RSpec feature helper methods that allow user to select or unselect elements from both single and multiple select elements. Add the following to your `spec/rails_helper.rb` (or `spec/spec_helper.rb`):
78 |
79 | ```ruby
80 | require 'selectivity/rspec'
81 | ```
82 |
83 | This automatically configures RSpec by adding:
84 |
85 | ```ruby
86 | RSpec.configure do |config|
87 | config.include Selectivity::Rspec::FeatureHelpers, type: :feature, js: true
88 | end
89 | ```
90 |
91 | Configuration includes two additional methods for all `type: :feature, js: true` specs:
92 |
93 | ```ruby
94 | selectivity_select(value, options = {})
95 | selectivity_unselect(value, options = {})
96 | ```
97 |
98 | Both methods require `from: '...'` inside `options` hash that is either CSS path or field's label (requires `for` attribute!).
99 |
100 | ### Example usage
101 | To handle single select:
102 |
103 | ```ruby
104 | selectivity_select('Netherlands', from: 'Your country')
105 | selectivity_unselect('Netherlands', from: '#country')
106 | selectivity_select('Poland', from: '#country')
107 | ```
108 |
109 | To handle multiple select:
110 |
111 | ```ruby
112 | selectivity_select('Netherlands', 'Russia', 'Spain', from: 'Countries list')
113 | # or, by single value:
114 | selectivity_select('Poland', from: '#countries')
115 |
116 | selectivity_unselect('Russia', 'Spain', from: 'Countries list')
117 | # or, by single value:
118 | selectivity_unselect('Netherlands', from: '#countries')
119 | ```
120 |
121 | ## Demos and examples
122 | For detailed information on Selectivity.js possibilities and behavior, visit:
123 |
124 | * [**Sample Rails application**](https://github.com/msx2/selectivity-rails-sample-app)
125 | * [Selectivity.js repository](https://github.com/arendjr/selectivity)
126 | * [Selectivity.js gh-page](https://arendjr.github.io/selectivity)
127 |
128 | ## Contributing
129 |
130 | 1. Fork it
131 | 2. Create your feature branch (`git checkout -b my-new-feature`)
132 | 3. Commit your changes (`git commit -am 'Add some feature'`)
133 | 4. Push to the branch (`git push origin my-new-feature`)
134 | 5. Create new Pull Request
135 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | require "bundler/gem_tasks"
2 |
3 | namespace :vendor do
4 | desc 'Update vendored selectivity'
5 | task :update do
6 | require 'open-uri'
7 |
8 | root = 'https://raw.githubusercontent.com/arendjr/selectivity/master'
9 |
10 | src_uri = File.join(root, 'dist/selectivity-full.js')
11 |
12 | open(src_uri) do |f|
13 | dest_file = File.expand_path('../vendor/assets/javascripts/selectivity.js', __FILE__)
14 | puts "Writing `#{dest_file}' from `#{src_uri}'"
15 | File.write dest_file, f.read
16 | end
17 |
18 | Dir['vendor/assets/stylesheets/selectivity/*.sass'].each do |file|
19 | src_uri = File.join(root, "styles/selectivity/#{File.basename(file)}")
20 |
21 | open(src_uri) do |f|
22 | dest_file = File.expand_path("../#{file}", __FILE__)
23 | puts "Writing `#{dest_file}' from `#{src_uri}'"
24 | File.write dest_file, f.read
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/app/assets/javascripts/selectivity.pl_PL.js.coffee:
--------------------------------------------------------------------------------
1 | $(document).on 'ready page:load', ->
2 | $.fn.selectivity.Locale =
3 | ajaxError: (term) -> "Nie udało się pobrać wyników dla #{escape(term)}"
4 | loading: 'Ładowanie...'
5 | loadMore: 'Więcej...'
6 | needMoreCharacters: (numCharacters) -> "Wpisz jeszcze #{word_pluralize(numCharacters, 'znak', 'znaki', 'znaków')}"
7 | noResults: 'Brak wyników'
8 | noResultsForTerm: (term) -> "Brak wyników dla #{escape(term)}"
9 |
10 |
11 | word_pluralize = (number, wordSingle, wordFew, wordMany) ->
12 | number = Number(number)
13 |
14 | word = if number == 0 then wordMany
15 | else if number == 1 then wordSingle
16 | else if (number % 10) >= 2 && (number % 10) <= 4 && (number <= 10 || number >= 20)
17 | wordFew
18 | else
19 | wordMany
20 |
21 | "#{number} #{word}"
22 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/selectivity_bootstrap.sass:
--------------------------------------------------------------------------------
1 | $border-radius-base: 4px !default
2 |
3 | $input-bg: #fff !default
4 | $input-color: #555 !default
5 | $input-border: #ccc !default
6 |
7 |
8 | .form-control.selectivity-input
9 | width: 100%
10 | height: auto
11 | display: block
12 | padding: inherit
13 | border-color: $input-border
14 | border-radius: $border-radius-base
15 | color: $input-color
16 | background: $input-bg
17 |
18 | .selectivity-multiple-input-container,
19 | .selectivity-single-select
20 | color: $input-color
21 | background: $input-bg
22 |
23 | .selectivity-multiple-input-container
24 | padding: 0
25 |
26 | .selectivity-single-select
27 | padding: 2px
28 |
29 | .selectivity-single-result-container,
30 | .selectivity-caret
31 | top: 0.5em
32 |
33 |
34 | .form-horizontal
35 | .form-control.selectivity-input
36 | padding-left: 0
37 | padding-right: 0
38 |
39 | .selectivity-single-result-container
40 | padding-left: 6px
41 |
42 |
43 | .selectivity-dropdown
44 | margin-top: 2px
45 |
--------------------------------------------------------------------------------
/lib/selectivity/rails.rb:
--------------------------------------------------------------------------------
1 | require 'selectivity/rails/version'
2 |
3 | module Selectivity
4 | module Rails
5 | class Engine < ::Rails::Engine
6 | end
7 | end
8 | end
9 |
--------------------------------------------------------------------------------
/lib/selectivity/rails/version.rb:
--------------------------------------------------------------------------------
1 | module Selectivity
2 | module Rails
3 | VERSION = '0.2.0'
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/lib/selectivity/rspec.rb:
--------------------------------------------------------------------------------
1 | module Selectivity
2 | module Rspec
3 | module FeatureHelpers
4 |
5 | def selectivity_select(value, *args)
6 | options = args.extract_options!
7 |
8 | fail('Selectivity input not set!') unless options.has_key?(:from)
9 |
10 | from = options.delete(:from)
11 | input = find_selectivity_input(from, options)
12 | items = _selectivity_multiselect?(input) ? args.unshift(value).uniq : [value]
13 |
14 | items.each do |item|
15 | _selectivity_select!(input, item)
16 | end
17 | end
18 |
19 | def selectivity_unselect(value, *args)
20 | options = args.extract_options!
21 |
22 | fail('Selectivity input not set!') unless options.has_key?(:from)
23 |
24 | from = options.delete(:from)
25 | input = find_selectivity_input(from, options)
26 | items = _selectivity_multiselect?(input) ? args.unshift(value).uniq : [value]
27 |
28 | items.each do |item|
29 | if _selectivity_multiselect?(input)
30 | _selectivity_unselect_multiple!(input, item)
31 | else
32 | _selectivity_unselect_single!(input)
33 | end
34 | end
35 | end
36 |
37 | private
38 |
39 | def find_selectivity_input(from, options)
40 | label = first(:xpath, ".//label[contains(., '#{from}')]", options)
41 | if label.present?
42 | find(:div, "##{label[:for]}", options)
43 | else
44 | target = first(:xpath, ".//div[contains(., '#{from}')]", options) || first(:div, from, options)
45 | if target[:class].include?('selectivity-input')
46 | target
47 | else
48 | target.first('.selectivity-input')
49 | end
50 | end
51 | end
52 |
53 | def _selectivity_multiselect?(input)
54 | input.first('.selectivity-multiple-input-container').present?
55 | end
56 |
57 | def _selectivity_select!(input, item)
58 | input.click
59 |
60 | within 'div.selectivity-dropdown' do
61 | element = if page.driver.class.name =~ /poltergeist/i
62 | find('div.selectivity-result-item', text: item)
63 | else
64 | find(:xpath, ".//div[contains(@class,'selectivity-result-item')][text()='#{item}']")
65 | end
66 |
67 | if element.visible?
68 | page.evaluate_script("$('div.selectivity-result-item:contains(#{item})').trigger('click')")
69 | end
70 | end
71 | end
72 |
73 | def _selectivity_unselect_single!(input)
74 | input.first('.selectivity-single-selected-item-remove').click
75 | end
76 |
77 | def _selectivity_unselect_multiple!(input, value)
78 | input.first('.selectivity-multiple-selected-item', text: value)
79 | .first('.selectivity-multiple-selected-item-remove')
80 | .click
81 | end
82 |
83 | end
84 | end
85 | end
86 |
87 | RSpec.configure do |config|
88 | config.include Selectivity::Rspec::FeatureHelpers, type: :feature, js: true
89 | end
90 |
--------------------------------------------------------------------------------
/selectivity-rails.gemspec:
--------------------------------------------------------------------------------
1 | # coding: utf-8
2 | lib = File.expand_path('../lib', __FILE__)
3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4 | require 'selectivity/rails/version'
5 |
6 | Gem::Specification.new do |spec|
7 | spec.name = 'selectivity-rails'
8 | spec.version = Selectivity::Rails::VERSION
9 | spec.authors = ['Konrad Jurkowski']
10 | spec.email = ['konrad@jurkowski.me']
11 | spec.description = %q{Selectivity.js is a modular and light-weight selection library for jQuery and Zepto.js. This gem integrates Selectivity.js with Ruby on Rails.}
12 | spec.summary = %q{Integrate Selectivity.js with Ruby on Rails}
13 | spec.homepage = 'https://github.com/msx2/selectivity-rails'
14 | spec.license = 'MIT'
15 | spec.required_ruby_version = '>= 1.9.3'
16 |
17 | spec.files = `git ls-files`.split($/)
18 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20 | spec.require_paths = ['lib']
21 |
22 | spec.add_development_dependency 'bundler', '~> 1.3'
23 | spec.add_development_dependency 'rake'
24 | spec.add_development_dependency 'rails', '>= 3.0'
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity.sass:
--------------------------------------------------------------------------------
1 | @import 'selectivity/variables'
2 | @import 'selectivity/base'
3 | @import 'selectivity/dropdown'
4 | @import 'selectivity/input-types/*'
5 | @import 'selectivity/plugins/*'
6 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/base.sass:
--------------------------------------------------------------------------------
1 | /**
2 | * All CSS that comes with Selectivity.js can be used as is, or tweaked to your heart's content :)
3 | *
4 | * Please realize though there is no "API contract" regarding styling of CSS classes, meaning that
5 | * any customized CSS made may need to be updated without warning if you want to upgrade the
6 | * Selectivity version you use. You can mitigate this problem by using your own templates instead of
7 | * those defined in src/templates.js, since templates will at the very least continue working across
8 | * patch versions and any changes necessary to templates will be documented in the changelog.
9 | */
10 |
11 | .selectivity-clearfix
12 | clear: both
13 |
14 | .selectivity-input
15 | display: inline-block
16 | width: $selectivity-width
17 |
18 | select
19 | display: none
20 |
21 | .selectivity-input:focus
22 | outline: none
23 |
24 | .selectivity-placeholder
25 | color: $selectivity-placeholder-color
26 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/dropdown.sass:
--------------------------------------------------------------------------------
1 | /**
2 | * Dropdown
3 | */
4 |
5 | .selectivity-dropdown
6 | background: #fff
7 | border-radius: 4px
8 | box-shadow: 0 1px 5px 1px rgba(0, 0, 0, .15), 0 10px 16px 0 rgba(0, 0, 0, .2)
9 | position: fixed
10 | z-index: $selectivity-dropdown-z-index
11 |
12 | .selectivity-search-input-container
13 | border-bottom: 1px solid #eee
14 |
15 | .selectivity-search-input
16 | background: transparent
17 | border: 0
18 | outline: 0
19 | width: 100%
20 |
21 | .selectivity-results-container
22 | max-height: 28em
23 | overflow: auto
24 | position: relative
25 |
26 | .selectivity-load-more,
27 | .selectivity-result-item
28 | cursor: pointer
29 | padding: 7px
30 |
31 | .selectivity-result-children .selectivity-result-item
32 | padding-left: 17px
33 |
34 | .selectivity-load-more.highlight,
35 | .selectivity-result-item.highlight
36 | background: $selectivity-dropdown-highlight-bg
37 | color: $selectivity-dropdown-highlight-color
38 |
39 | .selectivity-result-item.disabled
40 | cursor: default
41 | color: #999
42 |
43 | .selectivity-result-item:first-child
44 | border-radius: 4px 4px 0 0
45 |
46 | .selectivity-dropdown.has-search-input .selectivity-result-item:first-child
47 | border-radius: 0
48 |
49 | .selectivity-result-label
50 | font-weight: bold
51 |
52 | .selectivity-load-more,
53 | .selectivity-result-item:last-child,
54 | .selectivity-result-children:last-child .selectivity-result-item:last-child
55 | border-radius: 0 0 4px 4px
56 |
57 | .selectivity-result-children .selectivity-result-item:last-child
58 | border-radius: 0
59 |
60 | .selectivity-error,
61 | .selectivity-loading,
62 | .selectivity-search-input-container,
63 | .selectivity-result-label
64 | padding: 7px
65 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/input-types/multiple.sass:
--------------------------------------------------------------------------------
1 | /**
2 | * Multi-selection input
3 | */
4 |
5 | .selectivity-multiple-input-container
6 | background: $selectivity-bg
7 | border-radius: $selectivity-border-radius
8 | cursor: text
9 | max-height: 10em
10 | min-height: calc(2em + 4px)
11 | overflow: auto
12 | padding: $selectivity-padding
13 |
14 | .selectivity-multiple-input-container .selectivity-placeholder
15 | height: calc(2em + 4px)
16 | line-height: calc(2em + 4px)
17 |
18 | .selectivity-multiple-input,
19 | input[type='text'].selectivity-multiple-input
20 | background-color: transparent
21 | border: none
22 | float: left
23 | font: inherit
24 | height: calc(2em + 4px)
25 | max-width: 100%
26 | outline: 0
27 | padding: 0
28 |
29 | &:focus
30 | background-color: transparent
31 | box-shadow: none
32 | outline: none
33 |
34 | .selectivity-multiple-input::-ms-clear
35 | display: none
36 |
37 | .selectivity-multiple-selected-item
38 | background: $selectivity-multiple-selected-bg
39 | border-radius: $selectivity-multiple-selected-border-radius
40 | color: $selectivity-multiple-selected-color
41 | cursor: default
42 | float: left
43 | line-height: 2em
44 | margin: 2px
45 | padding: 0 5px
46 | position: relative
47 | -moz-user-select: none
48 | -ms-user-select: none
49 | -webkit-user-select: none
50 | user-select: none
51 | white-space: nowrap
52 |
53 | &.highlighted
54 | background-color: $selectivity-multiple-selected-highlight-bg
55 |
56 | .selectivity-multiple-selected-item-remove
57 | color: $selectivity-multiple-selected-color
58 | cursor: pointer
59 | margin-left: -5px
60 | padding: 5px
61 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/input-types/single.sass:
--------------------------------------------------------------------------------
1 | /**
2 | * Single-selection input
3 | */
4 |
5 | .selectivity-single-select
6 | background: $selectivity-bg
7 | border-radius: $selectivity-border-radius
8 | cursor: pointer
9 | min-height: 2em
10 | padding: $selectivity-padding
11 | position: relative
12 | -moz-box-sizing: content-box
13 | -webkit-box-sizing: content-box
14 | box-sizing: content-box
15 |
16 | .selectivity-single-select-input
17 | opacity: 0
18 |
19 | .selectivity-single-result-container
20 | position: absolute
21 | top: 0.8em
22 | right: 15px
23 | left: 5px
24 | overflow: hidden
25 | text-overflow: ellipsis
26 | white-space: nowrap
27 |
28 | .selectivity-single-selected-item
29 | color: $selectivity-single-selected-color
30 |
31 | .selectivity-single-selected-item-remove
32 | color: $selectivity-single-selected-color
33 | float: right
34 | padding: 0 5px
35 |
36 | .selectivity-caret
37 | position: absolute
38 | right: 5px
39 | top: 0.7em
40 |
41 | @media only screen and (max-device-width: 480px)
42 | .selectivity-single-select
43 | background: $selectivity-bg
44 | border-radius: $selectivity-border-radius
45 |
46 | .selectivity-single-result-container
47 | right: 5px
48 |
49 | .selectivity-caret
50 | display: none
51 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/plugins/submenu.sass:
--------------------------------------------------------------------------------
1 | /**
2 | * Submenu
3 | */
4 |
5 | .selectivity-submenu-icon
6 | position: absolute
7 | right: 4px
8 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/selectivity/variables.sass:
--------------------------------------------------------------------------------
1 | $selectivity-dropdown-z-index: 1046 !default
2 |
3 | $selectivity-width: 250px !default
4 | $selectivity-padding: 5px !default
5 | $selectivity-border-radius: 2px !default
6 | $selectivity-bg: #eee !default
7 |
8 | $selectivity-placeholder-color: #999 !default
9 |
10 | $selectivity-single-selected-color: #000 !default
11 |
12 | $selectivity-multiple-selected-border-radius: 3px !default
13 | $selectivity-multiple-selected-bg: #4484c7 !default
14 | $selectivity-multiple-selected-color: #fff !default
15 | $selectivity-multiple-selected-highlight-bg: #ccc !default
16 |
17 | $selectivity-dropdown-highlight-bg: #4484c7 !default
18 | $selectivity-dropdown-highlight-color: #fff !default
19 |
--------------------------------------------------------------------------------