solargraph-rails 0.2.1 → 0.2.2.pre.1

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: 60dc687282db670b1cfa0b017c2e0d994f86e6adafca80d99eb4d455aaf2b68f
4
- data.tar.gz: 54f79f529ed0fee77b93d88d7a56868b040ded60aa836f001d27e26ddbef843d
3
+ metadata.gz: 42b094ca4d96b63dd47297f752e821904875c11eda1f2a367ab84da2862b5ff6
4
+ data.tar.gz: 60200f07c8ff06a580cd4f44aba81fe2313c12364bf23b9637c8a874b2769c2e
5
5
  SHA512:
6
- metadata.gz: b358c11d03830142a393eb55281fa149b8b784474c681c907b509784467cd4b8d6712de6afd1db135dd2794b7888aca02962f483a74b5897c1676440fa6b398e
7
- data.tar.gz: 3ebbd33b3f491a2e4a9e2a4b86ecfd08c6eab3a8f3475157fb36fb8683d361ebe000bfcad019b8740761407187e5b7ed3bd00483c388e1fcea5bc50c0523745d
6
+ metadata.gz: 55fb5b511f8ff2dc298d47063e4a602154cee613852a750ecc7fe77acdf1a9aa0686fbed86435180cf4c88dcb1038b7510b6ef9b1b58f4ff636d7f17cf34a475
7
+ data.tar.gz: b33e682d6b94cb029d741495c0e14719ffbc643273d8fbe96b88725cbcc085425710e6d95683646f107bc5d874dc2ed00b96e89149fe881d2b6113bba95c3eda
data/Gemfile.lock CHANGED
@@ -1,12 +1,19 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- solargraph-rails (0.2.0)
4
+ solargraph-rails (0.2.1)
5
+ activesupport
5
6
  solargraph (~> 0.41.1)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ activesupport (6.1.3.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
10
17
  ast (2.4.2)
11
18
  backport (1.1.2)
12
19
  benchmark (0.1.1)
@@ -14,14 +21,18 @@ GEM
14
21
  bundler (>= 1.2.0, < 3)
15
22
  thor (~> 1.0)
16
23
  byebug (11.1.3)
24
+ concurrent-ruby (1.1.9)
17
25
  diff-lcs (1.4.4)
18
26
  e2mmap (0.1.0)
27
+ i18n (1.8.10)
28
+ concurrent-ruby (~> 1.0)
19
29
  jaro_winkler (1.5.4)
20
30
  kramdown (2.3.1)
21
31
  rexml
22
32
  kramdown-parser-gfm (1.1.0)
23
33
  kramdown (~> 2.0)
24
34
  mini_portile2 (2.5.3)
35
+ minitest (5.14.4)
25
36
  nokogiri (1.11.6)
26
37
  mini_portile2 (~> 2.5.0)
27
38
  racc (~> 1.4)
@@ -76,8 +87,11 @@ GEM
76
87
  yard (~> 0.9, >= 0.9.24)
77
88
  thor (1.1.0)
78
89
  tilt (2.0.10)
90
+ tzinfo (2.0.4)
91
+ concurrent-ruby (~> 1.0)
79
92
  unicode-display_width (2.0.0)
80
93
  yard (0.9.26)
94
+ zeitwerk (2.4.2)
81
95
 
82
96
  PLATFORMS
83
97
  ruby
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'active_support/core_ext/string'
4
+
3
5
  module Solargraph
4
6
  module Rails
5
7
  class PinCreator
@@ -50,14 +52,47 @@ module Solargraph
50
52
  end
51
53
  end
52
54
 
55
+ parser.on_ruby_line do |line|
56
+ if line =~ /belongs_to\s+:([a-z_]*)/
57
+ belongs_to_reader = Regexp.last_match(1)
58
+
59
+ loc = Solargraph::Location.new(
60
+ path,
61
+ Solargraph::Range.from_to(
62
+ parser.current_line_number,
63
+ 0,
64
+ parser.current_line_number,
65
+ parser.current_line_length - 1
66
+ )
67
+ )
68
+ model_attrs << { name: belongs_to_reader, type: belongs_to_reader.camelize, location: loc }
69
+ elsif line =~ /has_many\s+:([a-z_]*)/
70
+ has_many_reader = Regexp.last_match(1)
71
+
72
+ loc = Solargraph::Location.new(
73
+ path,
74
+ Solargraph::Range.from_to(
75
+ parser.current_line_number,
76
+ 0,
77
+ parser.current_line_number,
78
+ parser.current_line_length - 1
79
+ )
80
+ )
81
+ model_attrs << {
82
+ name: has_many_reader,
83
+ type: "Array<#{has_many_reader.singularize.camelize}>",
84
+ location: loc
85
+ }
86
+ end
87
+ end
88
+
53
89
  parser.parse
54
90
 
55
91
  Solargraph::Logging.logger.info "Adding #{model_attrs.count} attributes as pins"
56
- # TODO have to return other types of pins too
57
92
  model_attrs.map do |attr|
58
93
  Solargraph::Pin::Method.new(
59
94
  name: attr[:name],
60
- comments: "@return [#{type_translation[attr[:type]]}]",
95
+ comments: "@return [#{type_translation.fetch(attr[:type], attr[:type])}]",
61
96
  location: attr[:location],
62
97
  closure: Solargraph::Pin::Namespace.new(name: module_names.join('::') + "::#{model_name}"),
63
98
  scope: :instance,
@@ -1,5 +1,5 @@
1
1
  module Solargraph
2
2
  module Rails
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2.pre.1'
4
4
  end
5
5
  end
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
 
28
28
  spec.add_runtime_dependency "solargraph", "~> 0.41.1"
29
+ spec.add_runtime_dependency "activesupport", "~> 6.1.3"
29
30
  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: 0.2.1
4
+ version: 0.2.2.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fritz Meissner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-01 00:00:00.000000000 Z
11
+ date: 2021-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.41.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 6.1.3
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 6.1.3
69
83
  description: Add reflection on ActiveModel dynamic attributes that will be created
70
84
  at runtime
71
85
  email:
@@ -108,9 +122,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
122
  version: '0'
109
123
  required_rubygems_version: !ruby/object:Gem::Requirement
110
124
  requirements:
111
- - - ">="
125
+ - - ">"
112
126
  - !ruby/object:Gem::Version
113
- version: '0'
127
+ version: 1.3.1
114
128
  requirements: []
115
129
  rubygems_version: 3.2.3
116
130
  signing_key: