solargraph-rails 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8535143a29b76e1a9800e728bbc2c6d8d996dde200a162c4ad7b2747c859f3cb
4
- data.tar.gz: 8fb9ee00b1486f63489b788bbc49db1301027ae47928f0aec1c686bdd0f0b6d0
3
+ metadata.gz: 136534eb40ae838dfcc2a78abb2e6e0bc0c9cf187c6b1d86095dda51e876aa24
4
+ data.tar.gz: d90e381a7a65f81900252347da41b2b2b46721e9f3e57930a90c9e00f0b480b4
5
5
  SHA512:
6
- metadata.gz: 013c47d9b9b382bb11da4f8463aeb5bdf94afe71bdcac2c8bce2609d1d81cc3a7f9857bc2003665615d2538a2ca6be43550b3ba14a21144315011c2d607a8475
7
- data.tar.gz: 280e6f1520de2562a725da745d4d2295150660403c2eb02177cdbfbe3784e0c048d34363cbd431d59891226716c836517d0f197435cd01d5248252db56a9246c
6
+ metadata.gz: 770b2ae68e6baa102d4474925394e05750580bed3726abb7e965a04f320d4ac14d3108dd8a0360ae340971b522579178dcf2fca6df15cbdab2d3ecc2bc0a488f
7
+ data.tar.gz: 641c7f310938d271bcaeb58dc4aefbca9d5d61aa53f4a33272c38025cbf5a6e2da469920441c2f22d17dbae7ebc926ec5aedbfae6feea0622a84968784cc009d
@@ -1,9 +1,7 @@
1
- # This workflow uses actions that are not certified by GitHub.
2
- # They are provided by a third-party and are governed by
3
- # separate terms of service, privacy policy, and support
4
- # documentation.
5
- # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
- # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
1
+ # To debug locally:
2
+ # npm install -g act
3
+ # act act pull_request
4
+ #
7
5
 
8
6
  name: Ruby
9
7
 
@@ -14,32 +12,65 @@ on:
14
12
 
15
13
  jobs:
16
14
  test:
17
- # older versions of Ruby want openssl1 which is not on ubuntu-latest
18
- runs-on: ubuntu-20.04
15
+ runs-on: ubuntu-latest
19
16
  strategy:
20
17
  matrix:
21
18
  ruby-version:
22
- - "2.7"
23
19
  - "3.0"
20
+ # - "3.1"
21
+ # - "3.2"
22
+ # - "3.3"
23
+ # - "3.4"
24
24
  solargraph-version:
25
- - "0.44.3"
26
- - "0.45.0"
27
- - "0.46.0"
28
- - "0.47.2"
25
+ - "0.48.0"
26
+ - "0.49.0"
27
+ - "0.50.0"
28
+ - "0.51.2"
29
+ - "0.52.0"
30
+ - "0.54.6.alpha"
31
+ rails-version:
32
+ - "7"
29
33
  fail-fast: false
30
34
 
31
35
  steps:
32
36
  - uses: actions/checkout@v2
33
- - name: Cache RVM
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby-version }}
40
+ bundler: latest
41
+ bundler-cache: true
42
+
43
+
44
+ - name: Install child bundle
45
+ run: |
46
+ set -x
47
+ export MATRIX_SOLARGRAPH_VERSION="${{ matrix.solargraph-version }}"
48
+ export BUNDLE_PATH=$(pwd)/vendor/bundle
49
+ cd "spec/rails${{ matrix.rails-version }}"
50
+ bundle install
51
+
52
+ - name: cache gem annotations
34
53
  uses: actions/cache@v3
35
- id: rvm
54
+ id: dot-cache
36
55
  with:
37
- key: ${{ runner.os }}-rvm-${{ matrix.ruby-version }}
56
+ key: ${{ runner.os }}-dot-cache-${{ matrix.ruby-version }}
38
57
  path: |
39
- /home/runner/.rvm
40
- /home/runner/.yardoc
41
- #/usr/local/rvm/
58
+ /home/runner/.cache
59
+
60
+ - name: bundle list
61
+ run: bundle list && cat Gemfile.lock && find vendor -name Gemfile
62
+
42
63
  #- name: Setup upterm session
43
64
  # uses: lhotari/action-upterm@v1
44
- - name: Test
45
- run: "/bin/bash ./ci.sh ${{ matrix.ruby-version }} ${{ matrix.solargraph-version}}"
65
+
66
+ - name: RSpec
67
+ run: |
68
+ set -x
69
+ echo $MATRIX_SOLARGRAPH_VERSION
70
+ export MATRIX_SOLARGRAPH_VERSION="${{ matrix.solargraph-version }}"
71
+ export BUNDLE_PATH=$(pwd)/vendor/bundle
72
+ ruby --version
73
+ bundle install
74
+ bundle exec solargraph gems || true
75
+ bundle exec solargraph version
76
+ bundle exec rspec spec/solargraph-rails
data/.gitignore CHANGED
@@ -7,10 +7,6 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  .DS_Store
10
- spec/rails5/log/
11
- spec/rails5/tmp/
12
- spec/rails6/log/
13
- spec/rails6/tmp/
14
10
  spec/rails7/log/
15
11
  spec/rails7/tmp/
16
12
  .projections.json
@@ -19,3 +15,5 @@ spec/rails7/tmp/
19
15
  # rspec failure tracking
20
16
  .rspec_status
21
17
  Gemfile.lock
18
+ /.Gemfile
19
+ vendor
data/CHANGELOG.md CHANGED
@@ -2,6 +2,47 @@
2
2
 
3
3
  ## Changes
4
4
 
5
+ ### v1.1.2
6
+
7
+ Features / fixes:
8
+
9
+ - fix bad gemspec solargraph dependency
10
+ - additional pre-packaged Rails type definitions (Thanks, @grncdr!)
11
+
12
+ Internal improvements:
13
+
14
+ - Use normal ruby source for extra YARD annotations (Thanks, @grncdr!)
15
+ - Speed up CI for recent Solargraph version fresh builds
16
+ - spec reliability fixes
17
+ -
18
+
19
+ ### v1.1.1
20
+
21
+ New maintainer: @apiology
22
+
23
+ Features / fixes:
24
+
25
+ - support tsvector type columns in migrations (#55)
26
+ - support recent Solargraph releases
27
+ - fix incorrect return type in Walker.normalize_ast
28
+ - limit Solargraph versions to those that support global conventions for now pending new Solargraph release (<0.53 for now)
29
+ - limit Solargraph versions to tested versions (>0.48)
30
+ - additional built-in annotations for better completions and types
31
+ - work around ActiveSupport 7.0.x core\_ext Logger bug
32
+
33
+ Internal improvements:
34
+
35
+ - revive and improve CI workflow for higher quality releases (Huge thanks to @grncdr!)
36
+ - cache YARD gem annotations for faster GitHub workflows via RubyGems plugin
37
+ - track definition skips by Solargraph version
38
+ - remove testing of Rails 5/6; retain and revive Rails 7 testing
39
+ - sync type definitions with current functionality
40
+ - switch to more recent Solargraph releases in CI matrix
41
+ - support recent Solargraph versions in specs
42
+ - use `Solargraph::ApiMap.load_with_cache` when available in specs for eager type loading
43
+ - use .Gemfile pattern to allow local untracked Gemfile changes
44
+ - better support for updating definitions
45
+
5
46
  ### v1.1.0
6
47
 
7
48
  - remove pinned solargraph version
data/DEVELOPMENT.md CHANGED
@@ -4,36 +4,27 @@
4
4
 
5
5
  1. create fork and clone the repo
6
6
  2. install gem deps `bundle install`
7
- 3. install dummy rails5 app deps and build its yard cache
7
+ 3. install dummy Rails app deps and build its yard cache
8
8
 
9
9
  ```
10
- $ cd spec/rails5
11
- $ bundle install && yard gems
12
- $ cd ../../
13
- ```
14
-
15
- 3. install dummy rails6 app deps and build its yard cache
16
-
17
- ```
18
- $ cd spec/rails6
10
+ $ cd spec/rails7
19
11
  $ bundle install && yard gems
20
12
  $ cd ../../
21
13
  ```
14
+ 4. now tests should pass locally and you can try different changes
15
+ 5. submit PR
22
16
 
23
- 4. install dummy rails7 app deps and build its yard cache
17
+ ## Debugging workflow / test matrix issues locally
24
18
 
25
- ```
26
- $ cd spec/rails7
27
- $ bundle install && yard gems
28
- $ cd ../../
29
- ```
30
- 5. now tests should pass locally and you can try different changes
31
- 6. sumbit PR
19
+ ```sh
20
+ npm install -g act
21
+ act pull_request
22
+ ```
32
23
 
33
24
  ## Completion coverage tracking
34
25
 
35
26
  Solargraph-Rails uses a [set of yaml files](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/definitions) to track coverage of found completions.
36
- Those yaml files are generated at runtime from a dummy [rails5](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails5) or [rails6](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails6) app.
27
+ Those yaml files are generated at runtime from a dummy [Rails 7 app](https://github.com/iftheshoefritz/solargraph-rails/tree/master/spec/rails7).
37
28
 
38
29
  The main goal is to catch any regressions in case of any change. In case a method completion is marked completed and it is not found in solargraph completions, the tests will fail.
39
30
 
@@ -85,7 +76,19 @@ In case a new set of assertion files has to be created (for a new Rails version
85
76
  All you have to do is execute the script and pass it a path to rails app:
86
77
 
87
78
  ```
88
- ruby script/generate_definitions.rb spec/rails6
79
+ ruby script/generate_definitions.rb spec/rails7
89
80
  ```
90
81
 
91
82
  Make sure to review the script and uncomment relevant parts
83
+
84
+ ## Preparing a release (maintainers)
85
+
86
+ 1. Look up [most recent release](https://rubygems.org/gems/solargraph-rails)
87
+ 2. Open up commit list(https://github.com/iftheshoefritz/solargraph-rails/compare/v1.1.1...main)
88
+ 3. Update [CHANGELOG.md](./CHANGELOG.md)
89
+ 4. Flip to 'files changed view' and refine updates
90
+ 5. Bump [version](./lib/solargraph/rails/version.rb) appropriately
91
+ 6. Create branch, commit and merge changes - "Prepare for vX.Y.Z release", branch: prepare_vX.Y.Z_release
92
+ 7. `git config branch.main.remote`
93
+ 8. Ensure your local main branch is directly from iftheshoefritz:
94
+ 9. `git checkout main && git pull && bundle exec rake release`
data/Gemfile CHANGED
@@ -1,10 +1,52 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+
4
+ # Kind of ugly, but works. The setup-ruby action forces gems to be installed to vendor/bundle
5
+ # If we use it naively we end up with vendor/bundle and spec/rails7/vendor/bundle, which
6
+ # breaks all the tests because docs are generated in two different directories.
7
+ #
8
+ # So if we just install the rails deps at the same time, we have a single cache and a single
9
+ # directory for gems.
10
+ rails_version = ENV['MATRIX_RAILS_VERSION'] || '7'
11
+ instance_eval File.read(File.expand_path("spec/rails#{rails_version}/Gemfile", __dir__))
12
+
13
+ solargraph_version = (ENV['CI'] && ENV['MATRIX_SOLARGRAPH_VERSION'])
14
+
15
+ # ensure that YARD docs get cached by ruby/setup-ruby in GitHub
16
+ # Actions if using an older version of solargraph that needs user to
17
+ # run `yard gems` manually
18
+ if solargraph_version
19
+ solargraph_minor_version = solargraph_version.split('.')[1].to_i
20
+ solargraph_major_version = solargraph_version.split('.')[0].to_i
21
+ if solargraph_version && solargraph_major_version == 0 && solargraph_minor_version < 53
22
+ plugin 'auto_yard', path: File.expand_path('ci/auto_yard', __dir__)
23
+ STDERR.puts("Using auto_yard plugin at #{File.expand_path('ci/auto_yard', __dir__)}")
24
+ end
25
+ end
4
26
 
5
27
  group :development, :test do
6
- gem 'byebug'
7
28
  gem 'bundler-audit'
29
+ gem 'debug'
30
+ gem 'byebug'
8
31
  end
32
+
33
+ if rails_version == '7'
34
+ # https://stackoverflow.com/questions/79360526/uninitialized-constant-activesupportloggerthreadsafelevellogger-nameerror
35
+ gem "concurrent-ruby", '<=1.3.5'
36
+ end
37
+
9
38
  # Specify your gem's dependencies in solargraph_rails.gemspec
10
39
  gemspec
40
+
41
+ solargraph_force_ci_version = (ENV['CI'] && ENV['MATRIX_SOLARGRAPH_VERSION'])
42
+
43
+ if solargraph_force_ci_version == '0.54.6.alpha'
44
+ gem 'solargraph',
45
+ github: 'apiology/solargraph',
46
+ branch: 'v54-alpha'
47
+ # path: '../solargraph'
48
+ end
49
+
50
+ # Local gemfile for development tools, etc.
51
+ local_gemfile = File.expand_path(".Gemfile", __dir__)
52
+ instance_eval File.read local_gemfile if File.exist? local_gemfile
data/README.md CHANGED
@@ -74,16 +74,14 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ifthes
74
74
  3. install dummy rails app deps and build the yard cache:
75
75
 
76
76
  ```
77
- $ cd spec/rails5
77
+ $ cd spec/rails7
78
78
  $ bundle install && yard gems
79
79
  $ cd ../../
80
80
  ```
81
81
 
82
- (and the same for rails 6 and rails 7)
83
-
84
82
  4. now tests should pass locally and you can try different changes
85
83
 
86
- 5. sumbit PR
84
+ 5. submit PR
87
85
 
88
86
  ## License
89
87
 
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'auto_yard'
5
+ spec.version = '0.0.1'
6
+ spec.authors = ['Stephen Sugden']
7
+ spec.email = ['grncdr@users.noreply.github.com']
8
+
9
+ spec.summary = 'Run yard gems automatically after bundle install'
10
+ spec.description = spec.summary
11
+ spec.license = 'MIT'
12
+ spec.required_ruby_version = '>= 2.6.0'
13
+
14
+ spec.homepage = 'https://github.com'
15
+ spec.metadata['homepage_uri'] = spec.homepage
16
+
17
+ spec.files = ['plugins.rb']
18
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ Bundler::Plugin.add_hook('after-install-all') do
2
+ system('bundle exec yard gems')
3
+ cmd = 'bundle exec yard gems --plugin solargraph'
4
+ STDERR.puts("Installing yard info using #{cmd.inspect}")
5
+ # Attempt to run yard, and if it fails, try again - sometimes YARD gets indigestion on a given gem
6
+ system(cmd + ' || ' + cmd)
7
+ STDERR.puts("Installed yard info using #{cmd.inspect}")
8
+ rescue StandardError => e
9
+ STDERR.puts("Error running yard gems: #{e.message}")
10
+ STDERR.puts("Backtrace:\n#{e.backtrace}")
11
+ end
@@ -0,0 +1,5 @@
1
+ # annotations
2
+
3
+ Code in this directory is _not_ loaded or evaluated at runtime, either by solargraph or your application.
4
+
5
+ The code in [rails_api.rb](../rails_api.rb) loads each of these files inside a YARD `@!parse` directive.
@@ -0,0 +1,29 @@
1
+ class ActionController::Base
2
+ include ActionController::MimeResponds
3
+ include ActionController::Redirecting
4
+ include ActionController::Cookies
5
+ include AbstractController::Rendering
6
+ extend ActiveSupport::Callbacks::ClassMethods
7
+ extend ActiveSupport::Rescuable::ClassMethods
8
+ extend AbstractController::Callbacks::ClassMethods
9
+ extend ActionController::RequestForgeryProtection::ClassMethods
10
+
11
+ # @return [ActionDispatch::Response]
12
+ def response; end
13
+ # @return [ActionDispatch::Request]
14
+ def request; end
15
+ # @return [ActionDispatch::Request::Session]
16
+ def session; end
17
+ # @return [ActionDispatch::Flash::FlashHash]
18
+ def flash; end
19
+ end
20
+
21
+ class ActionController::Metal
22
+ # @return [ActionController::Parameters]
23
+ def params; end
24
+ end
25
+
26
+ class ActionController::Cookies
27
+ # @return [ActionDispatch::Cookies::CookieJar]
28
+ def cookies; end
29
+ end
@@ -0,0 +1,26 @@
1
+ module ActionDispatch
2
+ module Flash
3
+ class FlashHash
4
+ # @return [ActionDispatch::Flash::FlashNow]
5
+ def now; end
6
+ end
7
+ end
8
+
9
+ module Routing
10
+ class Mapper
11
+ include ActionDispatch::Routing::Mapper::Base
12
+ include ActionDispatch::Routing::Mapper::HttpHelpers
13
+ include ActionDispatch::Routing::Mapper::Redirection
14
+ include ActionDispatch::Routing::Mapper::Scoping
15
+ include ActionDispatch::Routing::Mapper::Concerns
16
+ include ActionDispatch::Routing::Mapper::Resources
17
+ include ActionDispatch::Routing::Mapper::CustomUrls
18
+ end
19
+
20
+ class RouteSet
21
+ # @yieldself [ActionDispatch::Routing::Mapper]
22
+ # @yieldreceiver [ActionDispatch::Routing::Mapper]
23
+ def draw; end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ class ActionMailer::Base
2
+ # @return [self]
3
+ def self.with(**params); end
4
+ #
5
+ # @return [ActionMailer::MessageDelivery]
6
+ def mail(**params); end
7
+ end
@@ -0,0 +1,54 @@
1
+ class ActiveRecord::ConnectionAdapters::SchemaStatements
2
+ # @yieldparam [ActiveRecord::ConnectionAdapters::TableDefinition]
3
+ def create_table; end
4
+ # @yieldparam [ActiveRecord::ConnectionAdapters::TableDefinition]
5
+ def create_join_table; end
6
+ # @yieldparam [ActiveRecord::ConnectionAdapters::Table]
7
+ def change_table; end
8
+ end
9
+
10
+ # this module doesn't really exist, it's here to avoid repeating these mixins
11
+ module ActiveRecord::RelationMethods
12
+ include Enumerable
13
+ include ActiveRecord::QueryMethods
14
+ include ActiveRecord::FinderMethods
15
+ include ActiveRecord::Calculations
16
+ include ActiveRecord::Batches
17
+ end
18
+
19
+ class ActiveRecord::Relation
20
+ include ActiveRecord::RelationMethods
21
+ end
22
+
23
+ class ActiveRecord::Base
24
+ extend Enumerable
25
+ extend ActiveRecord::QueryMethods
26
+ extend ActiveRecord::FinderMethods
27
+ extend ActiveRecord::Calculations
28
+ extend ActiveRecord::Batches
29
+ extend ActiveRecord::Associations::ClassMethods
30
+ extend ActiveRecord::Inheritance::ClassMethods
31
+ extend ActiveRecord::ModelSchema::ClassMethods
32
+ extend ActiveRecord::Transactions::ClassMethods
33
+ extend ActiveRecord::Scoping::Named::ClassMethods
34
+ extend ActiveRecord::RelationMethods
35
+ include ActiveRecord::Persistence
36
+ end
37
+
38
+ # @!override ActiveRecord::Batches#find_each
39
+ # @yieldparam_single_parameter
40
+
41
+ # @!override ActiveRecord::Calculations#count
42
+ # @return [Integer, Hash]
43
+ # @!override ActiveRecord::Calculations#pluck
44
+ # @overload pluck(one)
45
+ # @return [Array]
46
+ # @overload pluck(one, two, *more)
47
+ # @return [Array<Array>]
48
+
49
+ # @!override ActiveRecord::QueryMethods::WhereChain#not
50
+ # @return_single_parameter
51
+ # @!override ActiveRecord::QueryMethods::WhereChain#missing
52
+ # @return_single_parameter
53
+ # @!override ActiveRecord::QueryMethods::WhereChain#associated
54
+ # @return_single_parameter
@@ -0,0 +1,5 @@
1
+ # @!override ActiveSupport::Rescuable::ClassMethods#rescue_from
2
+ # @return [void]
3
+
4
+ # @!override ActiveSupport::DescendantsTracker#subclasses
5
+ # @return [Array<Class>]
@@ -0,0 +1,31 @@
1
+ require 'date'
2
+ require 'active_support/core_ext'
3
+
4
+ class Date
5
+ # @param form [Symbol]
6
+ # @return [Time]
7
+ def to_time(form = :local); end
8
+
9
+ # @return [Rational, self]
10
+ def -(other); end
11
+
12
+ # @return [self]
13
+ def +(other); end
14
+
15
+ # @return [String]
16
+ def readable_inspect; end
17
+
18
+ # @return [-1, 0, 1, nil]
19
+ def compare_with_coercion(other); end
20
+
21
+ # @return [-1, 0, 1, nil]
22
+ def <=>(other); end
23
+
24
+ # @return [::Time]
25
+ def to_time; end
26
+ end
27
+
28
+ class DateTime
29
+ # @return [String]
30
+ def readable_inspect; end
31
+ end
@@ -0,0 +1,7 @@
1
+ class Object
2
+ # @return [self, nil]
3
+ def presence; end
4
+
5
+ # @return [self, nil]
6
+ def presence_in(x); end
7
+ end
@@ -0,0 +1,14 @@
1
+ class Rails
2
+ # @return [Rails::Application]
3
+ def self.application; end
4
+ end
5
+
6
+ class Rails::Engine
7
+ # @return [ActionDispatch::Routing::RouteSet]
8
+ def routes; end
9
+ end
10
+
11
+ class Rails::Application
12
+ # @return [ActionDispatch::Routing::RouteSet]
13
+ def routes; end
14
+ end
@@ -0,0 +1,66 @@
1
+ # See issue #54
2
+ class Object
3
+ require 'abbrev'
4
+ require 'base64'
5
+ require 'benchmark'
6
+ require 'bigdecimal'
7
+ require 'bundler'
8
+ require 'cgi'
9
+ require 'coverage'
10
+ require 'csv'
11
+ require 'date'
12
+ require 'delegate'
13
+ require 'did_you_mean'
14
+ require 'digest'
15
+ require 'drb'
16
+ require 'English'
17
+ require 'erb'
18
+ require 'error_highlight'
19
+ require 'expect'
20
+ require 'fiddle'
21
+ require 'fileutils'
22
+ require 'find'
23
+ require 'forwardable'
24
+ require 'getoptlong'
25
+ require 'ipaddr'
26
+ require 'irb'
27
+ require 'json'
28
+ require 'kconv'
29
+ require 'logger'
30
+ require 'mkmf'
31
+ require 'monitor'
32
+ require 'mutex_m'
33
+ require 'objspace'
34
+ require 'observer'
35
+ require 'open3'
36
+ require 'openssl'
37
+ require 'open-uri'
38
+ require 'optionparser'
39
+ require 'optparse'
40
+ require 'ostruct'
41
+ require 'pathname'
42
+ require 'prettyprint'
43
+ require 'pstore'
44
+ require 'psych'
45
+ require 'racc'
46
+ require 'rdoc'
47
+ require 'readline'
48
+ require 'reline'
49
+ require 'resolv'
50
+ require 'resolv-replace'
51
+ require 'ripper'
52
+ require 'rubygems'
53
+ require 'securerandom'
54
+ require 'shellwords'
55
+ require 'singleton'
56
+ require 'socket'
57
+ require 'tempfile'
58
+ require 'timeout'
59
+ require 'time'
60
+ require 'tmpdir'
61
+ require 'tsort'
62
+ require 'un'
63
+ require 'uri'
64
+ require 'weakref'
65
+ require 'yaml'
66
+ end
@@ -0,0 +1,30 @@
1
+ require 'time'
2
+
3
+ class Time
4
+ # @return [Boolean]
5
+ def eql_with_coercion(other); end
6
+
7
+ # @return [-1, 0, 1, nil]
8
+ def compare_with_coercion(other); end
9
+
10
+ # @return [-1, 0, 1, nil]
11
+ def compare_without_coercion(other); end
12
+
13
+ # @return [-1, 0, 1, nil]
14
+ def <=>(other); end
15
+
16
+ # @return [Time]
17
+ def +(other); end
18
+
19
+ # @param seconds [Integer, Float]
20
+ # @param microseconds [Integer]
21
+ # @param utc [Boolean]
22
+ # @return [Time]
23
+ def self.at(seconds, microseconds = 0, utc = false); end
24
+
25
+ # @return [Time]
26
+ def to_time; end
27
+
28
+ # @return [Time]
29
+ def +(other); end
30
+ end
@@ -5,70 +5,18 @@ module Solargraph
5
5
  @instance ||= self.new
6
6
  end
7
7
 
8
- def global(yard_map)
9
- return [] if yard_map.required.empty?
10
-
11
- ann = File.read(File.dirname(__FILE__) + '/annotations.rb')
12
- source = Solargraph::Source.load_string(ann, 'annotations.rb')
13
- map = Solargraph::SourceMap.map(source)
14
-
15
- Solargraph.logger.debug(
16
- "[Rails][Rails] found #{map.pins.size} pins in annotations"
17
- )
18
-
19
- overrides =
20
- YAML
21
- .load_file(File.dirname(__FILE__) + '/types.yml')
22
- .map do |meth, data|
23
- if data['return']
24
- Util.method_return(meth, data['return'])
25
- elsif data['yieldself']
26
- Solargraph::Pin::Reference::Override.from_comment(
27
- meth,
28
- "@yieldself [#{data['yieldself'].join(',')}]"
29
- )
30
- elsif data['yieldparam']
31
- Solargraph::Pin::Reference::Override.from_comment(
32
- meth,
33
- "@yieldparam [#{data['yieldparam'].join(',')}]"
34
- )
35
- end
36
- end
37
-
38
- ns =
39
- Solargraph::Pin::Namespace.new(
40
- name: 'ActionController::Base',
41
- gates: ['ActionController::Base']
42
- )
43
-
44
- definitions = [
45
- Util.build_public_method(
46
- ns,
47
- 'response',
48
- types: ['ActionDispatch::Response'],
49
- location: Util.dummy_location('whatever.rb')
50
- ),
51
- Util.build_public_method(
52
- ns,
53
- 'request',
54
- types: ['ActionDispatch::Request'],
55
- location: Util.dummy_location('whatever.rb')
56
- ),
57
- Util.build_public_method(
58
- ns,
59
- 'session',
60
- types: ['ActionDispatch::Request::Session'],
61
- location: Util.dummy_location('whatever.rb')
62
- ),
63
- Util.build_public_method(
64
- ns,
65
- 'flash',
66
- types: ['ActionDispatch::Flash::FlashHash'],
67
- location: Util.dummy_location('whatever.rb')
68
- )
69
- ]
8
+ def extra_source_maps
9
+ @extra_source_maps ||= Dir[File.join(__dir__, 'annotations', '*.rb')].to_h do |path|
10
+ code = File.read(path)
11
+ source = Solargraph::Source.load_string(code, path)
12
+ map = Solargraph::SourceMap.map(source)
13
+ [File.basename(path, '.rb'), map]
14
+ end
15
+ end
70
16
 
71
- map.pins + definitions + overrides
17
+ # @param yard_map [YardMap]
18
+ def global(_yard_map)
19
+ extra_source_maps.values.flat_map(&:pins)
72
20
  end
73
21
 
74
22
  def local(source_map, ns)
@@ -19,6 +19,7 @@ module Solargraph
19
19
  inet: 'IPAddr',
20
20
  citext: 'String',
21
21
  binary: 'String',
22
+ tsvector: 'String',
22
23
  timestamp: 'ActiveSupport::TimeWithZone'
23
24
  }
24
25
 
@@ -86,7 +87,7 @@ module Solargraph
86
87
 
87
88
  def infer_table_names(ns)
88
89
  table_name = ns.name.tableize
89
- if ns.namespace.present?
90
+ if ns.namespace && !ns.namespace.empty?
90
91
  [ns.path.tableize.tr('/', '_'), table_name]
91
92
  else
92
93
  [table_name]
@@ -1,5 +1,5 @@
1
1
  module Solargraph
2
2
  module Rails
3
- VERSION = '1.1.0'
3
+ VERSION = '1.1.2'
4
4
  end
5
5
  end
@@ -49,15 +49,8 @@ module Solargraph
49
49
  end
50
50
  end
51
51
 
52
- # https://github.com/castwide/solargraph/issues/522
53
52
  def self.normalize_ast(source)
54
- ast = source.node
55
-
56
- if ast.is_a?(::Parser::AST::Node)
57
- ast
58
- else
59
- NodeParser.parse_with_comments(source.code, source.filename)
60
- end
53
+ NodeParser.parse_with_comments(source.code, source.filename)
61
54
  end
62
55
 
63
56
  def self.from_source(source)
@@ -1,18 +1,20 @@
1
1
  require 'solargraph'
2
+ require 'logger'
3
+ require 'active_support'
2
4
  require 'active_support/core_ext/string/inflections'
3
5
 
4
- require_relative 'solargraph/rails/util.rb'
5
- require_relative 'solargraph/rails/schema.rb'
6
- require_relative 'solargraph/rails/annotate.rb'
7
- require_relative 'solargraph/rails/autoload.rb'
8
- require_relative 'solargraph/rails/model.rb'
9
- require_relative 'solargraph/rails/devise.rb'
10
- require_relative 'solargraph/rails/walker.rb'
11
- require_relative 'solargraph/rails/rails_api.rb'
12
- require_relative 'solargraph/rails/delegate.rb'
13
- require_relative 'solargraph/rails/storage.rb'
14
- require_relative 'solargraph/rails/debug.rb'
15
- require_relative 'solargraph/rails/version.rb'
6
+ require_relative 'solargraph/rails/util'
7
+ require_relative 'solargraph/rails/schema'
8
+ require_relative 'solargraph/rails/annotate'
9
+ require_relative 'solargraph/rails/autoload'
10
+ require_relative 'solargraph/rails/model'
11
+ require_relative 'solargraph/rails/devise'
12
+ require_relative 'solargraph/rails/walker'
13
+ require_relative 'solargraph/rails/rails_api'
14
+ require_relative 'solargraph/rails/delegate'
15
+ require_relative 'solargraph/rails/storage'
16
+ require_relative 'solargraph/rails/debug'
17
+ require_relative 'solargraph/rails/version'
16
18
 
17
19
  module Solargraph
18
20
  module Rails
@@ -2,6 +2,10 @@ lib = File.expand_path('../lib', __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'solargraph/rails/version'
4
4
 
5
+
6
+ solargraph_force_ci_version = (ENV['CI'] && ENV['MATRIX_SOLARGRAPH_VERSION'])
7
+ solargraph_version = solargraph_force_ci_version ? [solargraph_force_ci_version] : [">= 0.48.0", '<0.53.0']
8
+
5
9
  Gem::Specification.new do |spec|
6
10
  spec.name = 'solargraph-rails'
7
11
  spec.version = Solargraph::Rails::VERSION
@@ -27,6 +31,11 @@ Gem::Specification.new do |spec|
27
31
  spec.add_development_dependency 'rake', '~> 12.3.3'
28
32
  spec.add_development_dependency 'rspec', '~> 3.0'
29
33
 
30
- spec.add_runtime_dependency 'solargraph'
34
+ # Solargraph temporarily dropped support for Convention.global in
35
+ # 0.53 - this should be lifted after it returns:
36
+ #
37
+ # https://github.com/castwide/solargraph/pull/877
38
+ spec.add_runtime_dependency 'solargraph', *solargraph_version
39
+
31
40
  spec.add_runtime_dependency 'activesupport'
32
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fritz Meissner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-02 00:00:00.000000000 Z
11
+ date: 2025-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 0.48.0
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: 0.53.0
62
65
  type: :runtime
63
66
  prerelease: false
64
67
  version_requirements: !ruby/object:Gem::Requirement
65
68
  requirements:
66
69
  - - ">="
67
70
  - !ruby/object:Gem::Version
68
- version: '0'
71
+ version: 0.48.0
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.53.0
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: activesupport
71
77
  requirement: !ruby/object:Gem::Requirement
@@ -102,10 +108,23 @@ files:
102
108
  - Rakefile
103
109
  - bin/console
104
110
  - bin/setup
105
- - ci.sh
111
+ - ci/auto_yard/.gitignore
112
+ - ci/auto_yard/auto_yard.gemspec
113
+ - ci/auto_yard/lib/.keep
114
+ - ci/auto_yard/plugins.rb
106
115
  - lib/solargraph-rails.rb
107
116
  - lib/solargraph/rails/annotate.rb
108
- - lib/solargraph/rails/annotations.rb
117
+ - lib/solargraph/rails/annotations/README.md
118
+ - lib/solargraph/rails/annotations/action_controller.rb
119
+ - lib/solargraph/rails/annotations/action_dispatch.rb
120
+ - lib/solargraph/rails/annotations/action_mailer.rb
121
+ - lib/solargraph/rails/annotations/active_record.rb
122
+ - lib/solargraph/rails/annotations/active_support.rb
123
+ - lib/solargraph/rails/annotations/date.rb
124
+ - lib/solargraph/rails/annotations/object.rb
125
+ - lib/solargraph/rails/annotations/rails.rb
126
+ - lib/solargraph/rails/annotations/stdlib_requires.rb
127
+ - lib/solargraph/rails/annotations/time.rb
109
128
  - lib/solargraph/rails/autoload.rb
110
129
  - lib/solargraph/rails/debug.rb
111
130
  - lib/solargraph/rails/delegate.rb
@@ -114,7 +133,6 @@ files:
114
133
  - lib/solargraph/rails/rails_api.rb
115
134
  - lib/solargraph/rails/schema.rb
116
135
  - lib/solargraph/rails/storage.rb
117
- - lib/solargraph/rails/types.yml
118
136
  - lib/solargraph/rails/util.rb
119
137
  - lib/solargraph/rails/version.rb
120
138
  - lib/solargraph/rails/walker.rb
@@ -124,7 +142,7 @@ homepage: https://github.com/iftheshoefritz/solargraph-rails
124
142
  licenses:
125
143
  - MIT
126
144
  metadata: {}
127
- post_install_message:
145
+ post_install_message:
128
146
  rdoc_options: []
129
147
  require_paths:
130
148
  - lib
@@ -139,8 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
157
  - !ruby/object:Gem::Version
140
158
  version: '0'
141
159
  requirements: []
142
- rubygems_version: 3.1.6
143
- signing_key:
160
+ rubygems_version: 3.3.27
161
+ signing_key:
144
162
  specification_version: 4
145
163
  summary: Solargraph plugin that adds Rails-specific code through a Convention
146
164
  test_files: []
data/ci.sh DELETED
@@ -1,34 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
- # when running in github actions:
4
- RVM_PATH=/home/runner/.rvm
5
- # when running locally using act:
6
- #RVM_PATH=/usr/local/rvm
7
- MATRIX_RUBY_VERSION=$1
8
- MATRIX_SOLARGRAPH_VERSION=$2
9
-
10
- if [[ ! -d $RVM_PATH ]]; then
11
- # this fetches the develop version; using -s stable should fetch the latest stable, but has a gpg error:
12
- curl -sSL https://get.rvm.io | bash -s
13
- fi
14
-
15
- # when running in github actions:
16
- source /home/runner/.rvm/scripts/rvm
17
- # when running locally in Act container:
18
- #source /usr/local/rvm/scripts/rvm
19
-
20
-
21
- #rvm package install openssl # hack because ubuntu won't give us openSSL
22
- rvm install ruby $MATRIX_RUBY_VERSION
23
- rvm use $MATRIX_RUBY_VERSION
24
- gem install bundler
25
-
26
- echo "s/gem 'solargraph'/gem 'solargraph', '${MATRIX_SOLARGRAPH_VERSION}'/" > command.sed
27
-
28
- (cd spec/rails5; sed -i -f ../../command.sed Gemfile; cat Gemfile; bundle install; yard gems)
29
- (cd spec/rails6; sed -i -f ../../command.sed Gemfile; cat Gemfile; bundle install; yard gems)
30
- (cd spec/rails7; sed -i -f ../../command.sed Gemfile; cat Gemfile; bundle install; yard gems)
31
-
32
- bundle install
33
-
34
- bundle exec rspec
@@ -1,50 +0,0 @@
1
- # The following comments fill some of the gaps in Solargraph's understanding of
2
- # Rails apps. Since they're all in YARD, they get mapped in Solargraph but
3
- # ignored at runtime.
4
- #
5
- # You can put this file anywhere in the project, as long as it gets included in
6
- # the workspace maps. It's recommended that you keep it in a standalone file
7
- # instead of pasting it into an existing one.
8
- #
9
- # @!parse
10
- # class ActionController::Base
11
- # include ActionController::MimeResponds
12
- # include ActionController::Redirecting
13
- # include ActionController::Cookies
14
- # include AbstractController::Rendering
15
- # extend ActiveSupport::Callbacks::ClassMethods
16
- # extend ActiveSupport::Rescuable::ClassMethods
17
- # extend AbstractController::Callbacks::ClassMethods
18
- # extend ActionController::RequestForgeryProtection::ClassMethods
19
- # end
20
- # class ActionDispatch::Routing::Mapper
21
- # include ActionDispatch::Routing::Mapper::Base
22
- # include ActionDispatch::Routing::Mapper::HttpHelpers
23
- # include ActionDispatch::Routing::Mapper::Redirection
24
- # include ActionDispatch::Routing::Mapper::Scoping
25
- # include ActionDispatch::Routing::Mapper::Concerns
26
- # include ActionDispatch::Routing::Mapper::Resources
27
- # include ActionDispatch::Routing::Mapper::CustomUrls
28
- # end
29
- # class Rails
30
- # # @return [Rails::Application]
31
- # def self.application; end
32
- # end
33
- # class Rails::Application
34
- # # @return [ActionDispatch::Routing::RouteSet]
35
- # def routes; end
36
- # end
37
- # class ActionDispatch::Routing::RouteSet
38
- # # @yieldself [ActionDispatch::Routing::Mapper]
39
- # def draw; end
40
- # end
41
- # class ActiveRecord::Base
42
- # extend ActiveRecord::QueryMethods
43
- # extend ActiveRecord::FinderMethods
44
- # extend ActiveRecord::Associations::ClassMethods
45
- # extend ActiveRecord::Inheritance::ClassMethods
46
- # extend ActiveRecord::ModelSchema::ClassMethods
47
- # extend ActiveRecord::Transactions::ClassMethods
48
- # extend ActiveRecord::Scoping::Named::ClassMethods
49
- # include ActiveRecord::Persistence
50
- # end
@@ -1,24 +0,0 @@
1
- ActionController::Metal#params:
2
- return: ["ActionController::Parameters"]
3
- ActiveRecord::FinderMethods#find:
4
- return: ["self", "Array<self>"]
5
- ActionController::Cookies#cookies:
6
- return: ["ActionDispatch::Cookies::CookieJar"]
7
- ActionDispatch::Flash::FlashHash#now:
8
- return: ["ActionDispatch::Flash::FlashNow"]
9
- ActiveRecord::QueryMethods#where:
10
- return: ["self", "ActiveRecord::Relation", "ActiveRecord::QueryMethods::WhereChain"]
11
- ActiveRecord::QueryMethods#not:
12
- return: ["ActiveRecord::QueryMethods::WhereChain"]
13
- ActiveRecord::FinderMethods#find_by:
14
- return: ["self", "nil"]
15
- Rails.application:
16
- return: ["Rails::Application"]
17
- ActionDispatch::Routing::RouteSet#draw:
18
- yieldself: ["ActionDispatch::Routing::Mapper"]
19
- ActiveRecord::ConnectionAdapters::SchemaStatements#create_table:
20
- yieldparam: ["ActiveRecord::ConnectionAdapters::TableDefinition"]
21
- ActiveRecord::ConnectionAdapters::SchemaStatements#create_join_table:
22
- yieldparam: ["ActiveRecord::ConnectionAdapters::TableDefinition"]
23
- ActiveRecord::ConnectionAdapters::SchemaStatements#change_table:
24
- yieldparam: ["ActiveRecord::ConnectionAdapters::Table"]