solargraph-rails-init 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/exe/solargraph-rails-init +75 -19
- data/lib/solargraph/rails/init/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4bbdcabdffa226f66ec626b47187d1284f8580e7be42dcabd2a5768623d4751
|
4
|
+
data.tar.gz: d393432009cfa4a6de9cfccb41524f5d3905cb8eaf840dacd0e582141d9ab7c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aecc346759f711981781aa760ee4d3092c7901ce187858f68d01b54e1f6f1ce7a14c65aea5e9378d2840fa329c2bb9487c6fbcb7c85546eb8ff53df1cf525882
|
7
|
+
data.tar.gz: 3018410c3cc714e74bbb973af0a5d335a0731b87f69745e75e2ceaeecd2414016beb9ee86df9c1da4e10ca752ca1bb2e8eeaeaae660c3366443fd97b0652dd6c
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,7 @@ A simple script that configures Solargraph to work with Rails. It acts as a shor
|
|
4
4
|
|
5
5
|
```bash
|
6
6
|
gem install solargraph
|
7
|
+
gem install solargraph-rails --pre # if --solargraph-rails-gem is specified
|
7
8
|
solargraph download-core
|
8
9
|
yard gems
|
9
10
|
solargraph bundle
|
@@ -12,13 +13,17 @@ curl -s https://gist.githubusercontent.com/castwide/28b349566a223dfb439a337aea29
|
|
12
13
|
```
|
13
14
|
|
14
15
|
|
15
|
-
## Installation
|
16
|
+
## Installation & Usage
|
16
17
|
|
17
18
|
Run the following commands in your Rails app root directory:
|
18
19
|
|
19
20
|
```bash
|
20
21
|
gem install solargraph-rails-init
|
21
22
|
solargraph-rails-init
|
23
|
+
|
24
|
+
# See also:
|
25
|
+
solargraph-rails-init --help
|
26
|
+
solargraph-rails-init --solargraph-rails-gem # also add/initialize the optional solargraph-rails gem
|
22
27
|
```
|
23
28
|
|
24
29
|
Run `solargraph-rails-init` again if you install new gems or change your Ruby version.
|
data/exe/solargraph-rails-init
CHANGED
@@ -1,25 +1,81 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
require 'optparse'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
SOLARGRAPH_YML = ".solargraph.yml"
|
7
|
+
DEFINITIONS_RB = "config/definitions.rb"
|
8
|
+
|
9
|
+
def run
|
10
|
+
parse_options
|
11
|
+
exec_cmd "gem install solargraph", title: "Installing Solargraph gem..."
|
12
|
+
exec_cmd "solargraph download-core", title: "Installing documentation. This might take a while..."
|
13
|
+
exec_cmd "yard gems"
|
14
|
+
exec_cmd "solargraph bundle"
|
15
|
+
|
16
|
+
unless File.exist?(SOLARGRAPH_YML)
|
17
|
+
exec_cmd "curl -s https://gist.githubusercontent.com/cmer/024991c85c4de01dab17632b2dc7f064/raw > #{SOLARGRAPH_YML}", title: "Copying .solargraph.yml..."
|
18
|
+
else
|
19
|
+
puts "Skipped copying .solargraph.yml. Already exists."
|
20
|
+
end
|
21
|
+
|
22
|
+
unless File.exist?(DEFINITIONS_RB)
|
23
|
+
exec_cmd "curl -s https://gist.githubusercontent.com/castwide/28b349566a223dfb439a337aea29713e/raw > #{DEFINITIONS_RB}", title: "Copying definitions.rb..."
|
24
|
+
else
|
25
|
+
puts "Skipped copying .definitions.rb. Already exists."
|
26
|
+
end
|
27
|
+
|
28
|
+
install_sgr if install_sgr?
|
29
|
+
|
30
|
+
puts "Done!"
|
31
|
+
end
|
32
|
+
|
33
|
+
def exec_cmd(cmd, title: nil)
|
34
|
+
puts title if title
|
35
|
+
out = `#{cmd}`
|
36
|
+
if $? != 0
|
37
|
+
puts out
|
38
|
+
puts "\nAn error as occured. Aborting.\n"
|
39
|
+
exit 1
|
40
|
+
end
|
16
41
|
end
|
17
42
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
43
|
+
def install_sgr?
|
44
|
+
@options[:sgr]
|
45
|
+
end
|
46
|
+
|
47
|
+
def install_sgr
|
48
|
+
exec_cmd "gem install solargraph-rails --pre", title: "Installing `solargraph-rails` gem..."
|
49
|
+
|
50
|
+
puts "Add `solargraph-rails` plugin to #{SOLARGRAPH_YML}"
|
51
|
+
h = YAML.load_file(SOLARGRAPH_YML)
|
52
|
+
h['plugins'] ||= []
|
53
|
+
h['plugins'] << 'solargraph-rails' unless h['plugins'].include?('solargraph-rails')
|
54
|
+
|
55
|
+
File.open(SOLARGRAPH_YML, "w") do |file|
|
56
|
+
file.write h .to_yaml
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def parse_options
|
61
|
+
@options = {}
|
62
|
+
optparse = OptionParser.new do |opts|
|
63
|
+
# Set a banner, displayed at the top of the help screen.
|
64
|
+
opts.banner = "Usage: solargraph-rails-init [options]"
|
65
|
+
|
66
|
+
@options[:sgr] = false
|
67
|
+
opts.on('-g', '--solargraph-rails-gem', 'Install and configure the solargraph-rails gem') do
|
68
|
+
@options[:sgr] = true
|
69
|
+
end
|
70
|
+
|
71
|
+
# This displays the help screen, all programs are assumed to have this option.
|
72
|
+
opts.on('-h', '--help', 'Display this screen') do
|
73
|
+
puts opts
|
74
|
+
exit
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
optparse.parse!
|
23
79
|
end
|
24
80
|
|
25
|
-
|
81
|
+
run
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph-rails-init
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Mercier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple script that configures Solargraph to work with Rails.
|
14
14
|
email:
|