active_ksql 0.1.0.alpha.1 → 0.1.0.pre

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: b20299186218124c1dfb90e4d9c24182757d6c8586b98eeff4dedb7c9f7ef199
4
- data.tar.gz: a6b43eead19a6b9a15ad45251a96091728858bf6449b07d886404180ac3ef2bd
3
+ metadata.gz: ed32db6caaefec386bec8b56b10c5ae5ade155754979fcf9eef206bbd7047bdf
4
+ data.tar.gz: 23f1c2fc21198aab2fd93992e32b5bccef1c0ff737d9d4e590d4eec9f6214e68
5
5
  SHA512:
6
- metadata.gz: 28462710785bb2a04a5607281bdf59c32b015f29dd9b21c39f02732f8cb7a336b32879303adf355d7f998bc54aff5eb7f229906e7c90923b4850723dee61ca65
7
- data.tar.gz: '09e88ca0f9db991606ab76dea2dd2cfbe535e12e01676535d2703431a0090e4daba2ad015b702781d09c35c30518cf65171a8bdb6e23970e3553255d421d9e3c'
6
+ metadata.gz: 18ae1889a5b69e617241c6fb2aebdc3a09801aea2e3f3c0134d1f74a5f24fff8a14664fc72b14b857ed4ab45c97178036bbe09af19273c7fbe729b93ef58f3a6
7
+ data.tar.gz: bd3d778eff708977199b12006ce9180365172913ddb315e93014d7525e2d3cdb6b08afcf9610ef15c8e5b6904c5ae60f68a7a3dee90c42924babc88a728d5317
data/.rubocop.yml CHANGED
@@ -1,180 +1,13 @@
1
- # Allow longer lines and methods
2
- Layout/LineLength:
3
- Max: 240
4
-
5
- Metrics/MethodLength:
6
- Max: 30
7
-
8
- # Tests are declarative, no block length test
9
- Metrics/BlockLength:
10
- IgnoredMethods: ['describe', 'context', 'namespace']
11
-
12
1
  AllCops:
13
- TargetRubyVersion: 2.5
14
- # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
15
- # to ignore them, so only the ones explicitly set in this file are enabled.
16
- DisabledByDefault: true
17
- Exclude:
18
- - '**/templates/**/*'
19
- - '**/vendor/**/*'
20
- - '**/vendor/**/.*'
21
- - '**/node_modules/**/*'
22
- - 'actionpack/lib/action_dispatch/journey/parser.rb'
23
-
24
- # Prefer &&/|| over and/or.
25
- Style/AndOr:
26
- Enabled: true
27
-
28
- # Align `when` with `case`.
29
- Layout/CaseIndentation:
30
- Enabled: true
31
-
32
- # Align comments with method definitions.
33
- Layout/CommentIndentation:
34
- Enabled: true
35
-
36
- Layout/ElseAlignment:
37
- Enabled: true
38
-
39
- # Align `end` with the matching keyword or starting expression except for
40
- # assignments, where it should be aligned with the LHS.
41
- Layout/EndAlignment:
42
- Enabled: true
43
- EnforcedStyleAlignWith: variable
44
- AutoCorrect: true
45
-
46
- Layout/EmptyLineAfterMagicComment:
47
- Enabled: true
48
-
49
- # In a regular class definition, no empty lines around the body.
50
- Layout/EmptyLinesAroundClassBody:
51
- Enabled: true
52
-
53
- # In a regular method definition, no empty lines around the body.
54
- Layout/EmptyLinesAroundMethodBody:
55
- Enabled: true
56
-
57
- # In a regular module definition, no empty lines around the body.
58
- Layout/EmptyLinesAroundModuleBody:
59
- Enabled: true
60
-
61
- Layout/FirstArgumentIndentation:
62
- Enabled: true
63
-
64
- # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
65
- Style/HashSyntax:
66
- Enabled: true
67
-
68
- # Method definitions after `private` or `protected` isolated calls need one
69
- # extra level of indentation.
70
- Layout/IndentationConsistency:
71
- Enabled: true
72
- EnforcedStyle: indented_internal_methods
73
-
74
- # Two spaces, no tabs (for indentation).
75
- Layout/IndentationWidth:
76
- Enabled: true
77
-
78
- Layout/LeadingCommentSpace:
79
- Enabled: true
80
-
81
- Layout/SpaceAfterColon:
82
- Enabled: true
83
-
84
- Layout/SpaceAfterComma:
85
- Enabled: true
86
-
87
- Layout/SpaceAroundEqualsInParameterDefault:
88
- Enabled: true
2
+ TargetRubyVersion: 2.4
89
3
 
90
- Layout/SpaceAroundKeyword:
91
- Enabled: true
92
-
93
- Layout/SpaceAroundOperators:
94
- Enabled: true
95
-
96
- Layout/SpaceBeforeComma:
97
- Enabled: true
98
-
99
- Layout/SpaceBeforeFirstArg:
100
- Enabled: true
101
-
102
- Style/DefWithParentheses:
103
- Enabled: true
104
-
105
- # Defining a method with parameters needs parentheses.
106
- Style/MethodDefParentheses:
107
- Enabled: true
108
-
109
- # Style/FrozenStringLiteralComment:
110
- # Enabled: true
111
- # EnforcedStyle: always
112
- # Exclude:
113
- # - 'actionview/test/**/*.builder'
114
- # - 'actionview/test/**/*.ruby'
115
- # - 'actionpack/test/**/*.builder'
116
- # - 'actionpack/test/**/*.ruby'
117
- # - 'activestorage/db/migrate/**/*.rb'
118
- # - 'db/migrate/**/*.rb'
119
- # - 'db/*.rb'
120
-
121
- # Use `foo {}` not `foo{}`.
122
- Layout/SpaceBeforeBlockBraces:
123
- Enabled: true
124
-
125
- # Use `foo { bar }` not `foo {bar}`.
126
- Layout/SpaceInsideBlockBraces:
127
- Enabled: true
128
-
129
- # Use `{ a: 1 }` not `{a:1}`.
130
- Layout/SpaceInsideHashLiteralBraces:
131
- Enabled: true
132
-
133
- Layout/SpaceInsideParens:
134
- Enabled: true
135
-
136
- # Check quotes usage according to lint rule below.
137
4
  Style/StringLiterals:
138
5
  Enabled: true
139
- EnforcedStyle: single_quotes
6
+ EnforcedStyle: double_quotes
140
7
 
141
- # Detect hard tabs, no hard tabs.
142
- Layout/IndentationStyle:
8
+ Style/StringLiteralsInInterpolation:
143
9
  Enabled: true
10
+ EnforcedStyle: double_quotes
144
11
 
145
- # Blank lines should not have any spaces.
146
- Layout/TrailingEmptyLines:
147
- Enabled: true
148
-
149
- # No trailing whitespace.
150
- Layout/TrailingWhitespace:
151
- Enabled: true
152
-
153
- # Use quotes for string literals when they are enough.
154
- Style/RedundantPercentQ:
155
- Enabled: true
156
-
157
- # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
158
- Lint/RequireParentheses:
159
- Enabled: true
160
-
161
- Lint/RedundantStringCoercion:
162
- Enabled: true
163
-
164
- # Supports --auto-correct
165
- Style/RedundantSelf:
166
- Description: Don't use self where it's not needed.
167
- StyleGuide: https://github.com/rubocop-hq/ruby-style-guide#no-self-unless-required
168
- Enabled: true
169
-
170
- Style/RedundantReturn:
171
- Enabled: true
172
- AllowMultipleReturnValues: true
173
-
174
- Style/Semicolon:
175
- Enabled: true
176
- AllowAsExpressionSeparator: true
177
-
178
- # Prefer Foo.method over Foo::method
179
- Style/ColonMethodCall:
180
- Enabled: true
12
+ Layout/LineLength:
13
+ Max: 120
data/README.md CHANGED
@@ -1,23 +1,15 @@
1
- ![][ruby-shield]
1
+ # ActiveKsql
2
2
 
3
- <p align="center">
4
- <img width="200" src="https://user-images.githubusercontent.com/50866745/147449973-a743b690-fef4-4b97-86d3-cc01f1695118.png" >
5
- </p>
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_ksql`. To experiment with that code, run `bin/console` for an interactive prompt.
6
4
 
7
-
8
- # ActiveKsql
9
-
10
- [![GitHub license](https://badgen.net/github/license/Naereen/Strapdown.js)](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) ![gem](https://img.shields.io/badge/gem-0.1.0.alpha-blue) [![stability-alpha](https://img.shields.io/badge/stability-alpha-f4d03f.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#alpha)
11
-
12
- ActiveKsql allows you to perform SQL requests to your ksqlDB server.
13
- You can find the ksqlDB official documentation [here](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/quick-reference/).
5
+ TODO: Delete this and the text above, and describe your gem
14
6
 
15
7
  ## Installation
16
8
 
17
9
  Add this line to your application's Gemfile:
18
10
 
19
11
  ```ruby
20
- gem 'active_ksql', '0.1.0.alpha.1'
12
+ gem 'active_ksql'
21
13
  ```
22
14
 
23
15
  And then execute:
@@ -30,77 +22,18 @@ Or install it yourself as:
30
22
 
31
23
  ## Usage
32
24
 
33
- The gem is currently under development although you can start using the beta version.
34
-
35
- ### Configuration
36
-
37
- Run `rails generate active_ksql` to generate the gem initializer.
38
-
39
- ```Ruby
40
- ActiveKsql.configure do |config|
41
- config.host = "http://localhost:8088"
42
- config.api_key = ""
43
- config.api_secret = ""
44
- end
45
- ```
46
-
47
- ### API Client
48
-
49
- At the moment the client allows you to run [queries](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/query-endpoint/) and to execute [statements](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/).
50
-
51
- ### Queries
52
-
53
- To run queries you can use the client's `query` method, like so:
54
-
55
- ```Ruby
56
- client = ActiveKsql::Api.new
57
-
58
- client.query("SELECT * FROM pageviews EMIT CHANGES;", {
59
- streams_properties: {
60
- "ksql.streams.auto.offset.reset": "earliest"
61
- }
62
- })
63
- ```
64
-
65
- Optional arguments are:
66
-
67
- - streams_properties
68
-
69
- ### Statements
70
-
71
- Same as for queries you can use the client's `ksql` method, like so:
72
-
73
- ```Ruby
74
- client = ActiveKsql::Api.new
75
-
76
- client.ksql("CREATE STREAM pageviews_home AS SELECT * FROM pageviews_original WHERE pageid='home';", {
77
- streams_properties: {
78
- "ksql.streams.auto.offset.reset": "earliest"
79
- }
80
- })
81
- ```
82
-
83
- Optional arguments are:
84
-
85
- - streams_properties
86
- - session_variables
87
- - command_sequence_number
88
-
25
+ TODO: Write usage instructions here
89
26
 
90
27
  ## Development
91
28
 
92
- The gem will soon act as an ORM.
93
- We're planning to develop and release enhancements early 2022.
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
94
32
 
95
33
  ## Contributing
96
34
 
97
- Bug reports and pull requests are welcome on GitHub at https://github.com/LapoElisacci/active_ksql.
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_ksql.
98
36
 
99
37
  ## License
100
38
 
101
39
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
102
-
103
- <!--- MARKDOWN LINKS --->
104
-
105
- [ruby-shield]: https://img.shields.io/badge/Ruby-CC342D?style=for-the-badge&logo=ruby&logoColor=white
106
-
data/bin/console CHANGED
@@ -1,22 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'bundler/setup'
5
- require 'active_ksql'
4
+ require "bundler/setup"
5
+ require "active_ksql"
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
9
9
 
10
10
  # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require 'pry'
11
+ # require "pry"
12
12
  # Pry.start
13
13
 
14
- require 'irb'
15
-
16
- ActiveKsql.configure do |config|
17
- config.host = 'http://localhost:8088'
18
- config.api_key = ''
19
- config.api_secret = ''
20
- end
21
-
14
+ require "irb"
22
15
  IRB.start(__FILE__)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveKsql
4
- VERSION = '0.1.0.alpha.1'
4
+ VERSION = "0.1.0.pre"
5
5
  end
data/lib/active_ksql.rb CHANGED
@@ -1,21 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # require 'active_support'
4
- # require 'active_model'
5
-
6
- require_relative 'active_ksql/version'
7
- require_relative 'active_ksql/configuration'
8
- require_relative 'active_ksql/api'
3
+ require_relative "active_ksql/version"
9
4
 
10
5
  module ActiveKsql
11
6
  class Error < StandardError; end
12
-
13
- class << self
14
- attr_accessor :config
15
-
16
- def configure
17
- self.config = ActiveKsql::Configuration.new
18
- yield(config)
19
- end
20
- end
7
+ # Your code goes here...
21
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_ksql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha.1
4
+ version: 0.1.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lapo
@@ -10,6 +10,34 @@ bindir: exe
10
10
  cert_chain: []
11
11
  date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: httparty
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -33,21 +61,15 @@ extra_rdoc_files: []
33
61
  files:
34
62
  - ".rspec"
35
63
  - ".rubocop.yml"
36
- - ".ruby_version"
37
64
  - CHANGELOG.md
38
65
  - Gemfile
39
- - Gemfile.lock
40
66
  - LICENSE.txt
41
67
  - README.md
42
68
  - Rakefile
43
69
  - bin/console
44
70
  - bin/setup
45
71
  - lib/active_ksql.rb
46
- - lib/active_ksql/api.rb
47
- - lib/active_ksql/configuration.rb
48
72
  - lib/active_ksql/version.rb
49
- - lib/generators/active_ksql.rb
50
- - lib/generators/templates/initializer.rb
51
73
  homepage: https://github.com/LapoElisacci/ksql
52
74
  licenses:
53
75
  - MIT
data/.ruby_version DELETED
@@ -1 +0,0 @@
1
- 3.0.2
data/Gemfile.lock DELETED
@@ -1,64 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- active_ksql (0.1.0.pre)
5
- httparty (~> 0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- diff-lcs (1.5.0)
12
- httparty (0.20.0)
13
- mime-types (~> 3.0)
14
- multi_xml (>= 0.5.2)
15
- mime-types (3.4.1)
16
- mime-types-data (~> 3.2015)
17
- mime-types-data (3.2021.1115)
18
- multi_xml (0.6.0)
19
- parallel (1.21.0)
20
- parser (3.0.3.2)
21
- ast (~> 2.4.1)
22
- rainbow (3.0.0)
23
- rake (13.0.6)
24
- regexp_parser (2.2.0)
25
- rexml (3.2.5)
26
- rspec (3.10.0)
27
- rspec-core (~> 3.10.0)
28
- rspec-expectations (~> 3.10.0)
29
- rspec-mocks (~> 3.10.0)
30
- rspec-core (3.10.1)
31
- rspec-support (~> 3.10.0)
32
- rspec-expectations (3.10.1)
33
- diff-lcs (>= 1.2.0, < 2.0)
34
- rspec-support (~> 3.10.0)
35
- rspec-mocks (3.10.2)
36
- diff-lcs (>= 1.2.0, < 2.0)
37
- rspec-support (~> 3.10.0)
38
- rspec-support (3.10.3)
39
- rubocop (1.24.0)
40
- parallel (~> 1.10)
41
- parser (>= 3.0.0.0)
42
- rainbow (>= 2.2.2, < 4.0)
43
- regexp_parser (>= 1.8, < 3.0)
44
- rexml
45
- rubocop-ast (>= 1.15.0, < 2.0)
46
- ruby-progressbar (~> 1.7)
47
- unicode-display_width (>= 1.4.0, < 3.0)
48
- rubocop-ast (1.15.0)
49
- parser (>= 3.0.1.1)
50
- ruby-progressbar (1.11.0)
51
- unicode-display_width (2.1.0)
52
-
53
- PLATFORMS
54
- ruby
55
- x86_64-darwin-20
56
-
57
- DEPENDENCIES
58
- active_ksql!
59
- rake (~> 13.0)
60
- rspec (~> 3.0)
61
- rubocop (~> 1.7)
62
-
63
- BUNDLED WITH
64
- 2.2.28
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ActiveKsql
6
- #
7
- # KsqlDB API Client
8
- #
9
- class Api
10
- attr_accessor :base_uri, :client, :headers
11
-
12
- KSQL_ENDPOINT = 'ksql'
13
- QUERY_ENDPOINT = 'query'
14
-
15
- def initialize
16
- @base_uri = ActiveKsql.config.host
17
- @headers = {
18
- 'Accept' => 'application/vnd.ksql.v1+json; q=0.9, application/json; q=0.5',
19
- 'Authorization' => "Basic #{ActiveKsql.config.api_key}:#{ActiveKsql.config.api_secret}"
20
- }
21
- @client = HTTParty
22
- end
23
-
24
- #
25
- # Perform requests to the /ksql endpoint of ksqlDB REST API
26
- #
27
- # @param [String] sql The ksqlDB SQL Statement
28
- # @param [Hash] streams_properties ksqlDB streamsProperties param
29
- # @param [Hash] session_variables ksqlDB sessionVariables param
30
- # @param [Int] command_sequence_number ksqlDB commandSequenceNumber param
31
- #
32
- # @return [Hash/Array] Request response
33
- #
34
- def ksql(sql, streams_properties: nil, session_variables: nil, command_sequence_number: nil)
35
- post(KSQL_ENDPOINT, body: { ksql: sql, streamsProperties: streams_properties, sessionVariables: session_variables, commandSequenceNumber: command_sequence_number }.compact)
36
- end
37
-
38
- #
39
- # Perform requests to the /query endpoint of ksqlDB REST API
40
- #
41
- # @param [String] sql The ksqlDB SQL Statement
42
- # @param [Hash] streams_properties ksqlDB streamsProperties param
43
- #
44
- # @return [Hash/Array] Request response
45
- #
46
- def query(sql, streams_properties: nil)
47
- post(QUERY_ENDPOINT, body: { ksql: sql, streamsProperties: streams_properties }.compact)
48
- end
49
-
50
- private
51
-
52
- #
53
- # Perform the HTTP Request
54
- #
55
- # @param [String] endpoint ksqlDB REST API Endpoint
56
- # @param [Hash] body HTTP Request Body
57
- #
58
- # @return [Hash/Array] Request response
59
- #
60
- def post(endpoint, body: {})
61
- client.post("#{base_uri}/#{endpoint}", headers: headers, body: body.to_json).parsed_response
62
- end
63
- end
64
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveKsql
4
- #
5
- # Ksql configuration
6
- #
7
- class Configuration
8
- attr_accessor :host, :api_key, :api_secret
9
- end
10
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators'
4
-
5
- # Creates the ActiveKsql initializer file for Rails apps.
6
- #
7
- # @example Invokation from terminal
8
- # rails generate active_ksql
9
- #
10
- class ActiveKsqlGenerator < Rails::Generators::Base
11
- desc "Description:\n This creates a Rails initializer for Ksql"
12
-
13
- source_root File.expand_path('templates', __dir__)
14
-
15
- desc 'Configures Ksql to connect to ksqlDB'
16
- def generate_layout
17
- template 'initializer.rb', 'config/initializers/active_ksql.rb'
18
- end
19
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActiveKsql.configure do |config|
4
- config.host = "http://localhost:8088"
5
- config.api_key = ""
6
- config.api_secret = ""
7
- end