ruby-superparser 0.1.0 → 0.1.2

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: dd3ec2e737d36d5496e842dac973746f9db2de3400ba26eff4df4833a96ba01d
4
- data.tar.gz: c2b11e0282c9c4d4d8700709939ab5a4dbd364d9fbaff4a33484e81574a5a47c
3
+ metadata.gz: 27e79dbede1bacc8d5e082dd9e2eb06ce21d8f898d74e73a051e5cc507d3cfb4
4
+ data.tar.gz: 7acc5017d71d14d3112db73a19948a34e87871ccb78b2e577581b74601ebb829
5
5
  SHA512:
6
- metadata.gz: 5729012f101cdeece775f4216cb277573d65d1bee6b49345151ec4999804b71ac9996debfd1f70120e8366332fb7667e4fd65db17c1aea2fcf0d6cf893bd35bd
7
- data.tar.gz: 1b5d053e783d85b94a19ff9f822932bc938f5f591707c12cb28a61e57c0c72beffee33691b45d618b1588a0b77b514e69243cf2cecab765d65c58f3cb6f5a68d
6
+ metadata.gz: 12d019e44100ef67b924fc176ca3a644b126c536e52be08ddee240b49d665f6e7591abd63ccc5e58c12290760c1051a5750310a521e20fd37881e7fc89223dcc
7
+ data.tar.gz: 10ee3ccdb9b5990fe046c854430da080bf408f0756ca424118250e6306998dd4620102b6d868799daada7a17b6b82a717d4f3f32ccfbf4b1a22d8a418475949d
data/Gemfile.lock ADDED
@@ -0,0 +1,173 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby-superparser (0.1.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (7.0.4.3)
10
+ actionpack (= 7.0.4.3)
11
+ activesupport (= 7.0.4.3)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (7.0.4.3)
15
+ actionpack (= 7.0.4.3)
16
+ activejob (= 7.0.4.3)
17
+ activerecord (= 7.0.4.3)
18
+ activestorage (= 7.0.4.3)
19
+ activesupport (= 7.0.4.3)
20
+ mail (>= 2.7.1)
21
+ net-imap
22
+ net-pop
23
+ net-smtp
24
+ actionmailer (7.0.4.3)
25
+ actionpack (= 7.0.4.3)
26
+ actionview (= 7.0.4.3)
27
+ activejob (= 7.0.4.3)
28
+ activesupport (= 7.0.4.3)
29
+ mail (~> 2.5, >= 2.5.4)
30
+ net-imap
31
+ net-pop
32
+ net-smtp
33
+ rails-dom-testing (~> 2.0)
34
+ actionpack (7.0.4.3)
35
+ actionview (= 7.0.4.3)
36
+ activesupport (= 7.0.4.3)
37
+ rack (~> 2.0, >= 2.2.0)
38
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.0)
40
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
+ actiontext (7.0.4.3)
42
+ actionpack (= 7.0.4.3)
43
+ activerecord (= 7.0.4.3)
44
+ activestorage (= 7.0.4.3)
45
+ activesupport (= 7.0.4.3)
46
+ globalid (>= 0.6.0)
47
+ nokogiri (>= 1.8.5)
48
+ actionview (7.0.4.3)
49
+ activesupport (= 7.0.4.3)
50
+ builder (~> 3.1)
51
+ erubi (~> 1.4)
52
+ rails-dom-testing (~> 2.0)
53
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
54
+ activejob (7.0.4.3)
55
+ activesupport (= 7.0.4.3)
56
+ globalid (>= 0.3.6)
57
+ activemodel (7.0.4.3)
58
+ activesupport (= 7.0.4.3)
59
+ activerecord (7.0.4.3)
60
+ activemodel (= 7.0.4.3)
61
+ activesupport (= 7.0.4.3)
62
+ activestorage (7.0.4.3)
63
+ actionpack (= 7.0.4.3)
64
+ activejob (= 7.0.4.3)
65
+ activerecord (= 7.0.4.3)
66
+ activesupport (= 7.0.4.3)
67
+ marcel (~> 1.0)
68
+ mini_mime (>= 1.1.0)
69
+ activesupport (7.0.4.3)
70
+ concurrent-ruby (~> 1.0, >= 1.0.2)
71
+ i18n (>= 1.6, < 2)
72
+ minitest (>= 5.1)
73
+ tzinfo (~> 2.0)
74
+ builder (3.2.4)
75
+ concurrent-ruby (1.2.2)
76
+ crass (1.0.6)
77
+ date (3.3.3)
78
+ diff-lcs (1.5.0)
79
+ erubi (1.12.0)
80
+ globalid (1.1.0)
81
+ activesupport (>= 5.0)
82
+ i18n (1.13.0)
83
+ concurrent-ruby (~> 1.0)
84
+ loofah (2.20.0)
85
+ crass (~> 1.0.2)
86
+ nokogiri (>= 1.5.9)
87
+ mail (2.8.1)
88
+ mini_mime (>= 0.1.1)
89
+ net-imap
90
+ net-pop
91
+ net-smtp
92
+ marcel (1.0.2)
93
+ method_source (1.0.0)
94
+ mini_mime (1.1.2)
95
+ mini_portile2 (2.8.1)
96
+ minitest (5.18.0)
97
+ net-imap (0.3.4)
98
+ date
99
+ net-protocol
100
+ net-pop (0.1.2)
101
+ net-protocol
102
+ net-protocol (0.2.1)
103
+ timeout
104
+ net-smtp (0.3.3)
105
+ net-protocol
106
+ nio4r (2.5.9)
107
+ nokogiri (1.14.3)
108
+ mini_portile2 (~> 2.8.0)
109
+ racc (~> 1.4)
110
+ racc (1.6.2)
111
+ rack (2.2.7)
112
+ rack-test (2.1.0)
113
+ rack (>= 1.3)
114
+ rails (7.0.4.3)
115
+ actioncable (= 7.0.4.3)
116
+ actionmailbox (= 7.0.4.3)
117
+ actionmailer (= 7.0.4.3)
118
+ actionpack (= 7.0.4.3)
119
+ actiontext (= 7.0.4.3)
120
+ actionview (= 7.0.4.3)
121
+ activejob (= 7.0.4.3)
122
+ activemodel (= 7.0.4.3)
123
+ activerecord (= 7.0.4.3)
124
+ activestorage (= 7.0.4.3)
125
+ activesupport (= 7.0.4.3)
126
+ bundler (>= 1.15.0)
127
+ railties (= 7.0.4.3)
128
+ rails-dom-testing (2.0.3)
129
+ activesupport (>= 4.2.0)
130
+ nokogiri (>= 1.6)
131
+ rails-html-sanitizer (1.5.0)
132
+ loofah (~> 2.19, >= 2.19.1)
133
+ railties (7.0.4.3)
134
+ actionpack (= 7.0.4.3)
135
+ activesupport (= 7.0.4.3)
136
+ method_source
137
+ rake (>= 12.2)
138
+ thor (~> 1.0)
139
+ zeitwerk (~> 2.5)
140
+ rake (13.0.6)
141
+ rspec (3.12.0)
142
+ rspec-core (~> 3.12.0)
143
+ rspec-expectations (~> 3.12.0)
144
+ rspec-mocks (~> 3.12.0)
145
+ rspec-core (3.12.2)
146
+ rspec-support (~> 3.12.0)
147
+ rspec-expectations (3.12.3)
148
+ diff-lcs (>= 1.2.0, < 2.0)
149
+ rspec-support (~> 3.12.0)
150
+ rspec-mocks (3.12.5)
151
+ diff-lcs (>= 1.2.0, < 2.0)
152
+ rspec-support (~> 3.12.0)
153
+ rspec-support (3.12.0)
154
+ thor (1.2.1)
155
+ timeout (0.3.2)
156
+ tzinfo (2.0.6)
157
+ concurrent-ruby (~> 1.0)
158
+ websocket-driver (0.7.5)
159
+ websocket-extensions (>= 0.1.0)
160
+ websocket-extensions (0.1.5)
161
+ zeitwerk (2.6.7)
162
+
163
+ PLATFORMS
164
+ ruby
165
+
166
+ DEPENDENCIES
167
+ rails (>= 6.0)
168
+ rake (~> 13.0)
169
+ rspec (~> 3.0)
170
+ ruby-superparser!
171
+
172
+ BUNDLED WITH
173
+ 2.4.12
@@ -1,4 +1,9 @@
1
1
  # lib/generators/ruby_superparser/templates/initializer.rb
2
2
 
3
- api_key = ENV['SUPERPARSER_API_KEY']
4
- SUPERPARSER_CLIENT = RubySuperparser::Client.new(api_key)
3
+ RubySuperparser.init do |config|
4
+ config.api_key = ENV['SUPERPARSER_API_KEY']
5
+
6
+ config.async = lambda { |document_id|
7
+ SuperparserJob.perform_later(document_id)
8
+ }
9
+ end
@@ -0,0 +1,10 @@
1
+ # lib/generators/ruby_superparser/templates/superparser_job.rb
2
+
3
+ class SuperparserJob < ApplicationJob
4
+ queue_as :default
5
+
6
+ def perform(document_id)
7
+ document = ExternalDocument.find(document_id)
8
+ RubySuperparser.config.async.call(document)
9
+ end
10
+ end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Ruby
4
- module Superparser
5
- VERSION = "0.1.0"
6
- end
7
- end
3
+ module RubySuperparser
4
+ VERSION = '0.1.2'
5
+ end
@@ -0,0 +1,10 @@
1
+ module RubySuperparser
2
+ class Configuration
3
+ attr_accessor :api_key, :async
4
+
5
+ def initialize
6
+ @api_key = nil
7
+ @async = nil
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ # lib/ruby_superparser/superparser_integration.rb
2
+
3
+ module RubySuperparser
4
+ module SuperparserIntegration
5
+ extend ActiveSupport::Concern
6
+
7
+ class_methods do
8
+ def superparser_for_attached(attached_attribute, options = {})
9
+ after_save :process_document_with_superparser, if: "saved_change_to_attribute?(:#{attached_attribute})"
10
+
11
+ define_method :process_document_with_superparser do
12
+ if options[:async]
13
+ RubySuperparser.config.async.call(id)
14
+ else
15
+ superparser_client.parse_resume(send(attached_attribute))
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def superparser_client
24
+ @superparser_client ||= RubySuperparser::Client.new(RubySuperparser.config)
25
+ end
26
+
27
+ end
28
+ end
29
+
@@ -0,0 +1,16 @@
1
+ # lib/ruby_superparser.rb
2
+
3
+ require_relative 'ruby/superparser/version'
4
+ require_relative 'ruby_superparser/client'
5
+ require_relative 'ruby_superparser/configuration'
6
+ require_relative 'ruby_superparser/superparser_integration'
7
+
8
+ module RubySuperparser
9
+ def self.config
10
+ @config ||= Configuration.new
11
+ end
12
+
13
+ def self.init
14
+ yield config if block_given?
15
+ end
16
+ end
@@ -4,7 +4,7 @@ require_relative "lib/ruby/superparser/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "ruby-superparser"
7
- spec.version = Ruby::Superparser::VERSION
7
+ spec.version = RubySuperparser::VERSION
8
8
  spec.authors = ["JP Silvashy"]
9
9
  spec.email = ["jpsilvashy@gmail.com"]
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-superparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Silvashy
@@ -35,6 +35,7 @@ files:
35
35
  - ".rspec"
36
36
  - CHANGELOG.md
37
37
  - Gemfile
38
+ - Gemfile.lock
38
39
  - LICENSE.txt
39
40
  - README.md
40
41
  - Rakefile
@@ -42,8 +43,12 @@ files:
42
43
  - bin/setup
43
44
  - lib/generators/ruby_superparser/install_generator.rb
44
45
  - lib/generators/ruby_superparser/templates/initializer.rb
45
- - lib/ruby/superparser.rb
46
+ - lib/generators/ruby_superparser/templates/superparser_job.rb
46
47
  - lib/ruby/superparser/version.rb
48
+ - lib/ruby_superparser.rb
49
+ - lib/ruby_superparser/client.rb
50
+ - lib/ruby_superparser/configuration.rb
51
+ - lib/ruby_superparser/superparser_integration.rb
47
52
  - ruby-superparser.gemspec
48
53
  - sig/ruby/superparser.rbs
49
54
  homepage: https://github.com/jpsilvashy/ruby-superparser