spoom 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e66609da288328708122f32555a990ea5f4f72d311f9c40038df3a9b22759de
4
- data.tar.gz: 782237d97b66b1a60d0fd83f931aecbba40d23869d178d0d9196ed4ab4f0a0c1
3
+ metadata.gz: 120fef71dbc1eb301d6425be852e9bd96554114865f5350c0bb5553fe16fbdaf
4
+ data.tar.gz: a50b10a8f28d7a96c9167ccf457116b61ef300f06d9dcce44801528355fc22cf
5
5
  SHA512:
6
- metadata.gz: bda11074ba04efcede0f9cef4bfbb1d441dac8ac56ca2fcf5190dd174c59903b0ac53b8f9ab1166b14d9a3016128a1025fb68b6a449c5d763ecc7bc2778059c0
7
- data.tar.gz: '0987432e65a6114e8b802892bd7602bc0bcf43dc2f1f9d3f920d79c003c2968d4f429f9e564d05721e5836505c3350d86205d04ad6b84d01c1882aa541736ff6'
6
+ metadata.gz: 4c306c8d3bbe04aa4874fc95d826989d226a5b20d3548048c0e485ae27678e32f79e63c0a7e98e3b743e116622a2161e75f04c0ca75214c1c78ece75977f6ce4
7
+ data.tar.gz: d5745d54bfc4caf3daf584231647dc299ce572888555304c8f4334aac495fec0d61457e60281a2c0e4992c4ef19d1b923e17151f006a4f436c7cddbf366b733c
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Spoom
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/spoom`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Useful tools for Sorbet enthusiasts.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,17 +20,36 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ ### Parsing Sorbet config
24
+
25
+ Parses a Sorbet config file:
26
+
27
+ ```ruby
28
+ config = Spoom::Sorbet::Config.parse_file("sorbet/config")
29
+ puts config.paths # "."
30
+ ```
31
+
32
+ Parses a Sorbet config string:
33
+
34
+ ```ruby
35
+ config = Spoom::Sorbet::Config.parse_string(<<~CONFIG)
36
+ a
37
+ --file=b
38
+ --ignore=c
39
+ CONFIG
40
+ puts config.paths # "a", "b"
41
+ puts config.ignore # "c"
42
+ ```
26
43
 
27
44
  ## Development
28
45
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Don't forget to run `bin/sanity` before pushing your changes.
30
47
 
31
48
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
49
 
33
50
  ## Contributing
34
51
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/spoom. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/spoom. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
53
 
37
54
  ## License
38
55
 
@@ -40,4 +57,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
57
 
41
58
  ## Code of Conduct
42
59
 
43
- Everyone interacting in the Spoom project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/spoom/blob/master/CODE_OF_CONDUCT.md).
60
+ Everyone interacting in the Spoom project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shopify/spoom/blob/master/CODE_OF_CONDUCT.md).
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "spoom/version"
3
+ require "sorbet-runtime"
4
4
 
5
- module Spoom
6
- class Error < StandardError; end
7
- end
5
+ require "spoom/version"
6
+ require "spoom/sorbet/config"
@@ -0,0 +1,99 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Spoom
5
+ module Sorbet
6
+ # Parse Sorbet config files
7
+ #
8
+ # Parses a Sorbet config file:
9
+ #
10
+ # ```ruby
11
+ # config = Spoom::Sorbet::Config.parse_file("sorbet/config")
12
+ # puts config.paths # "."
13
+ # ```
14
+ #
15
+ # Parses a Sorbet config string:
16
+ #
17
+ # ```ruby
18
+ # config = Spoom::Sorbet::Config.parse_string(<<~CONFIG)
19
+ # a
20
+ # --file=b
21
+ # --ignore=c
22
+ # CONFIG
23
+ # puts config.paths # "a", "b"
24
+ # puts config.ignore # "c"
25
+ # ```
26
+ class Config
27
+ extend T::Sig
28
+
29
+ sig { returns(T::Array[String]) }
30
+ attr_reader :paths, :ignore
31
+
32
+ sig { void }
33
+ def initialize
34
+ @paths = T.let([], T::Array[String])
35
+ @ignore = T.let([], T::Array[String])
36
+ end
37
+
38
+ class << self
39
+ extend T::Sig
40
+
41
+ sig { params(sorbet_config_path: String).returns(Spoom::Sorbet::Config) }
42
+ def parse_file(sorbet_config_path)
43
+ parse_string(File.read(sorbet_config_path))
44
+ end
45
+
46
+ sig { params(sorbet_config: String).returns(Spoom::Sorbet::Config) }
47
+ def parse_string(sorbet_config)
48
+ config = Config.new
49
+ ignore = T.let(false, T::Boolean)
50
+ skip = T.let(false, T::Boolean)
51
+ sorbet_config.each_line do |line|
52
+ line = line.strip
53
+ case line
54
+ when /^--ignore$/
55
+ ignore = true
56
+ next
57
+ when /^--ignore=/
58
+ config.ignore << parse_option(line)
59
+ next
60
+ when /^--file$/
61
+ next
62
+ when /^--file=/
63
+ config.paths << parse_option(line)
64
+ next
65
+ when /^--dir$/
66
+ next
67
+ when /^--dir=/
68
+ config.paths << parse_option(line)
69
+ next
70
+ when /^--.*=/
71
+ next
72
+ when /^--/
73
+ skip = true
74
+ when /^-.*=?/
75
+ next
76
+ else
77
+ if ignore
78
+ config.ignore << line
79
+ ignore = false
80
+ elsif skip
81
+ skip = false
82
+ else
83
+ config.paths << line
84
+ end
85
+ end
86
+ end
87
+ config
88
+ end
89
+
90
+ private
91
+
92
+ sig { params(line: String).returns(String) }
93
+ def parse_option(line)
94
+ T.must(line.split("=").last).strip
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spoom
4
- VERSION = "0.0.0"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spoom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Terrasa
@@ -107,6 +107,7 @@ files:
107
107
  - Rakefile
108
108
  - exe/spoom
109
109
  - lib/spoom.rb
110
+ - lib/spoom/sorbet/config.rb
110
111
  - lib/spoom/version.rb
111
112
  homepage: https://github.com/Shopify/spoom
112
113
  licenses: