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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2ba9759675d9a9fef359a171ebc194abf23d958de334dd34bd28a60442f3a54
4
- data.tar.gz: 33d6459e24bd175b0c7ffa8aeec1fbddf220693acbc3526518f287079c14a63d
3
+ metadata.gz: c4bbdcabdffa226f66ec626b47187d1284f8580e7be42dcabd2a5768623d4751
4
+ data.tar.gz: d393432009cfa4a6de9cfccb41524f5d3905cb8eaf840dacd0e582141d9ab7c4
5
5
  SHA512:
6
- metadata.gz: '0870d6b8c9b9cd9fe7020f6727c26ad8031f028503f3e1a67c85e11542783b55d6d8f815bded7e2e08283294cad651b258d1a48f4f184a95fee0d31760e63e19'
7
- data.tar.gz: 177584f0a62b3a226c91e8dc906513bec5fb553b5b89187a446f68304ed500cff6ca14487927bbd10f6fbb85ef1158af455aa6aecdcaf2fa16cdad07e18a6115
6
+ metadata.gz: aecc346759f711981781aa760ee4d3092c7901ce187858f68d01b54e1f6f1ce7a14c65aea5e9378d2840fa329c2bb9487c6fbcb7c85546eb8ff53df1cf525882
7
+ data.tar.gz: 3018410c3cc714e74bbb973af0a5d335a0731b87f69745e75e2ceaeecd2414016beb9ee86df9c1da4e10ca752ca1bb2e8eeaeaae660c3366443fd97b0652dd6c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solargraph-rails-init (0.1.1)
4
+ solargraph-rails-init (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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.
@@ -1,25 +1,81 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- puts "Installing Solargraph gem..."
4
- `gem install solargraph`
5
-
6
- puts "Installing documentation. This might take a while..."
7
- `solargraph download-core`
8
- `yard gems`
9
- `solargraph bundle`
10
-
11
- unless File.exist?('.solargraph.yml')
12
- puts "Copying .solargraph.yml..."
13
- `curl -s https://gist.githubusercontent.com/cmer/024991c85c4de01dab17632b2dc7f064/raw > .solargraph.yml`
14
- else
15
- puts "Skipped copying .solargraph.yml. Already exists."
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
- unless File.exist?('config/definitions.rb')
19
- puts "Copying definitions.rb..."
20
- `curl -s https://gist.githubusercontent.com/castwide/28b349566a223dfb439a337aea29713e/raw > config/definitions.rb`
21
- else
22
- puts "Skipped copying .definitions.rb. Already exists."
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
- puts "Done!"
81
+ run
@@ -3,7 +3,7 @@
3
3
  module Solargraph
4
4
  module Rails
5
5
  module Init
6
- VERSION = "0.1.1"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
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.1.1
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-14 00:00:00.000000000 Z
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: