ffast 0.1.9 → 0.2.2

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
  SHA256:
3
- metadata.gz: 18d062e72ef849cb0b6533af8c6dc37a6612036faead3c53e1d0427a001e8f24
4
- data.tar.gz: 55b4dfdd79ee4b789fa7652760fb3516a49f68b7503d827042b78c5101fecee6
3
+ metadata.gz: ce52e9ab5a9d9da32683b21584af707cf5c87e460f3bd74297e9038ea38c5494
4
+ data.tar.gz: 2b68a433982c97f278829b95234aed4ea5e4aec19264f15f9bfbe8615da19c9a
5
5
  SHA512:
6
- metadata.gz: 813ca8cbe0bad2ce3f6dce1477820b68c00ac06021a3fd4263df9ea5634a6510ae0cac6cd178ffc8342b31bf7e956522a482d809dbcbe3500a488b6bc609a78a
7
- data.tar.gz: 7fb04918062ca0f972622fe69e8d6bb77631b1e7df9ba9aa5b1e37385c0cdbcd802324d6e46801a89e53d4f30b7fe92edf51ad3eba0252cf6fce5183c76f60de
6
+ metadata.gz: 246e52812d6f332636363e9f8dd960fa5e5ad3ecc50666007ae62041a212efc0e17f79dc01a675e15cd862f04bcc6771ac2ede3c8fd98c656b0efe7f34b67ffc
7
+ data.tar.gz: 641af33dbc8858631ae458bc53a4c1b7ce08c44da6788d0cdf7c8c3cae571a9bcb20630f3f9527aeea9a6023a920ac8fe8b0df83672b8280ab8415977114ff4b
data/.rubocop.yml CHANGED
@@ -8,11 +8,114 @@ AllCops:
8
8
  Exclude:
9
9
  - 'tmp/**/*'
10
10
  - 'examples/*'
11
- TargetRubyVersion: 2.3
11
+ TargetRubyVersion: 2.6
12
12
 
13
13
  Layout/LineLength:
14
14
  Enabled: false
15
15
 
16
+ Layout/EmptyLinesAroundAttributeAccessor:
17
+ Enabled: false
18
+
19
+ Layout/SpaceAroundMethodCallOperator:
20
+ Enabled: false
21
+
22
+ Lint/BinaryOperatorWithIdenticalOperands:
23
+ Enabled: true
24
+
25
+ Lint/DuplicateElsifCondition:
26
+ Enabled: false
27
+
28
+ Lint/DuplicateRescueException:
29
+ Enabled: false
30
+
31
+ Lint/EmptyConditionalBody:
32
+ Enabled: false
33
+
34
+ Lint/FloatComparison:
35
+ Enabled: false
36
+
37
+ Lint/MissingSuper:
38
+ Enabled: false
39
+
40
+ Lint/OutOfRangeRegexpRef:
41
+ Enabled: false
42
+
43
+ Lint/SelfAssignment:
44
+ Enabled: false
45
+
46
+ Lint/TopLevelReturnWithArgument:
47
+ Enabled: false
48
+
49
+ Lint/UnreachableLoop:
50
+ Enabled: false
51
+
52
+
53
+ Lint/DeprecatedOpenSSLConstant:
54
+ Enabled: false
55
+
56
+ Lint/MixedRegexpCaptureTypes:
57
+ Enabled: false
58
+
59
+ Lint/RaiseException:
60
+ Enabled: true
61
+
62
+ Lint/StructNewOverride:
63
+ Enabled: true
64
+
65
+ Style/AccessorGrouping:
66
+ Enabled: false
67
+
68
+ Style/ArrayCoercion:
69
+ Enabled: false
70
+
71
+ Style/BisectedAttrAccessor:
72
+ Enabled: true
73
+
74
+ Style/CaseLikeIf:
75
+ Enabled: true
76
+
77
+ Style/ExplicitBlockArgument:
78
+ Enabled: false
79
+
80
+ Style/ExponentialNotation:
81
+ Enabled: true
82
+
83
+ Style/GlobalStdStream:
84
+ Enabled: false
85
+
86
+ Style/HashAsLastArrayItem:
87
+ Enabled: false
88
+
89
+ Style/HashLikeCase:
90
+ Enabled: true
91
+
92
+ Style/OptionalBooleanParameter:
93
+ Enabled: true
94
+
95
+ Style/RedundantAssignment:
96
+ Enabled: true
97
+
98
+ Style/RedundantFetchBlock:
99
+ Enabled: true
100
+
101
+ Style/RedundantFileExtensionInRequire:
102
+ Enabled: true
103
+
104
+ Style/SingleArgumentDig:
105
+ Enabled: true
106
+
107
+ Style/StringConcatenation:
108
+ Enabled: true
109
+
110
+ Style/RedundantRegexpCharacterClass:
111
+ Enabled: false
112
+
113
+ Style/RedundantRegexpEscape:
114
+ Enabled: false
115
+
116
+ Style/SlicingWithRange:
117
+ Enabled: true
118
+
16
119
  Metrics/BlockLength:
17
120
  Exclude:
18
121
  - 'spec/**/*'
data/.sourcelevel.yml ADDED
@@ -0,0 +1,2 @@
1
+ pull_requests:
2
+ comments: false
data/.travis.yml CHANGED
@@ -6,7 +6,7 @@ env:
6
6
  rvm:
7
7
  - 2.6.3
8
8
  before_install:
9
- gem install bundler -v 1.16.1
9
+ gem install bundler -v 2.1.4
10
10
  before_script:
11
11
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
12
  - chmod +x ./cc-test-reporter
data/Fastfile CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  # Fastfile is loaded when you start an expression with a dot.
4
3
  #
5
4
  # You can introduce shortcuts or methods that can be embedded during your
6
5
  # command line interactions with fast.
7
6
  #
8
7
  # Let's say you'd like to show the version that is over the version file
9
- Fast.shortcut(:version, '(casgn nil VERSION (str _))', 'lib/fast/version.rb')
8
+ version_file = Dir['lib/*/version.rb'].first
9
+ Fast.shortcut(:version, '(casgn nil VERSION (str _))', version_file)
10
10
 
11
11
  # Show all classes that inherits Fast::Find
12
12
  Fast.shortcut(:finders, '(class ... (const nil Find)', 'lib')
@@ -21,7 +21,7 @@ Fast.shortcut(:parser, '(class (const nil ExpressionParser)', 'lib/fast.rb')
21
21
 
22
22
  # Use `fast .bump_version` to rewrite the version file
23
23
  Fast.shortcut :bump_version do
24
- rewrite_file('(casgn nil VERSION (str _)', 'lib/fast/version.rb') do |node|
24
+ rewrite_file('(casgn nil VERSION (str _)', version_file) do |node|
25
25
  target = node.children.last.loc.expression
26
26
  pieces = target.source.split('.').map(&:to_i)
27
27
  pieces.reverse.each_with_index do |fragment, i|
@@ -35,3 +35,59 @@ Fast.shortcut :bump_version do
35
35
  replace(target, "'#{pieces.join('.')}'")
36
36
  end
37
37
  end
38
+
39
+ # List all shortcut with comments
40
+ Fast.shortcut :shortcuts do
41
+ fast_files.each do |file|
42
+ lines = File.readlines(file).map { |line| line.chomp.gsub(/\s*#/, '').strip }
43
+ result = capture_file('(send _ :shortcut $(sym _) ...)', file)
44
+ result = [result] unless result.is_a? Array
45
+ result.each do |capture|
46
+ target = capture.loc.expression
47
+ puts "fast .#{target.source[1..].ljust(30)} # #{lines[target.line - 2]}"
48
+ end
49
+ end
50
+ end
51
+
52
+ # Use to walkthrough the docs files with fast examples
53
+ # fast .intro
54
+ Fast.shortcut :intro do
55
+ ARGV << File.join(File.dirname(__FILE__), 'docs', 'walkthrough.md')
56
+
57
+ Fast.shortcuts[:walk].run
58
+ end
59
+
60
+ # Useful for `fast .walk file.md` but not required by the library.
61
+ private
62
+ def require_or_install_tty_md
63
+ require 'tty-markdown'
64
+ rescue LoadError
65
+ puts 'Installing tty-markdown gem to better engage you :)'
66
+ Gem.install('tty-markdown')
67
+ puts 'Done! Now, back to our topic \o/'
68
+ system('clear')
69
+ retry
70
+ end
71
+
72
+ # Interactive command line walkthrough
73
+ # fast .walk docs/walkthrough.md
74
+ Fast.shortcut :walk do
75
+ require_or_install_tty_md
76
+ file = ARGV.last
77
+ execute = ->(line) { system(line) }
78
+ walk = ->(line) { line.each_char { |c| sleep(0.02) and print(c) } }
79
+ File.readlines(file).each do |line|
80
+ case line
81
+ when /^fast /
82
+ walk[line]
83
+ execute[line]
84
+ when /^\$ /
85
+ walk[line]
86
+ execute[line[2..]]
87
+ when /^!{3}\s/
88
+ # Skip warnings that are only for web tutorials
89
+ else
90
+ walk[TTY::Markdown.parse(line)]
91
+ end
92
+ end
93
+ end