ko 0.1.2 → 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: 3e23069fa6e3d507cacf8baae87633f6537cb5254a9cd465b8e372519c0e0704
4
- data.tar.gz: e33170f4510c249229a33d33c9fdca7a2d54375240976618d9e0aa026c28a318
3
+ metadata.gz: 8111000c24eca5b3bf4932373abf3dc0ff3915134c704093a1a1550cfd85c94f
4
+ data.tar.gz: 96b71e12d39952af5077481f1f928a995a481c1c7c803b7c8cee2d139b94760e
5
5
  SHA512:
6
- metadata.gz: 8b6c6b37d7ec073ff85c9b444e3e764b547dea1b1959db64b05a2603d70b9b50a44742879bc5e5a6b938a76520cfa6879faf0b291e1c985245abdc632c1e62ec
7
- data.tar.gz: be5a5b7165da862a6f9482961185ee83845a335a69d0e648b367050c69ffe1abb7492e1124a6b99eaa5548f38fcf8463aab8f1bae7a23045fc0f5c38c4c9ad99
6
+ metadata.gz: 4ea2525e2db56568aee58f0bb626f3caa6471404f841a36b7f86d988789b7f83310585781d167e7e22b24a5f5e3a53d83971f6af08101483e251c5930dc07d50
7
+ data.tar.gz: ab1c24779d085876c6b10e080000ad5de892d930dd327837462ca77889b4d0df693ea9b50835862f7b2c14bb24339f877e3ab3da0a12d50a0909a219287ecdbf
data/Cargo.lock ADDED
@@ -0,0 +1,32 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "ko"
7
+ version = "0.1.0"
8
+ dependencies = [
9
+ "rutie",
10
+ ]
11
+
12
+ [[package]]
13
+ name = "lazy_static"
14
+ version = "1.4.0"
15
+ source = "registry+https://github.com/rust-lang/crates.io-index"
16
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
17
+
18
+ [[package]]
19
+ name = "libc"
20
+ version = "0.2.142"
21
+ source = "registry+https://github.com/rust-lang/crates.io-index"
22
+ checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
23
+
24
+ [[package]]
25
+ name = "rutie"
26
+ version = "0.8.4"
27
+ source = "registry+https://github.com/rust-lang/crates.io-index"
28
+ checksum = "5d97db4cbb9739b48364c38cc9a6ebabdc07b42bd87b60ab448e1f29eaebb2ac"
29
+ dependencies = [
30
+ "lazy_static",
31
+ "libc",
32
+ ]
data/Cargo.toml ADDED
@@ -0,0 +1,11 @@
1
+ [package]
2
+ name = "ko"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ [dependencies]
7
+ rutie = {version="0.8"}
8
+
9
+ [lib]
10
+ name = "ko"
11
+ crate-type = ["cdylib"]
data/Rakefile CHANGED
@@ -2,11 +2,25 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
8
+ RuboCop::RakeTask.new
7
9
 
8
- require "rubocop/rake_task"
10
+ def exec(*args) = system(args.join(" "), exception: true)
11
+ def cargo(*args) = exec("cargo", *args)
9
12
 
10
- RuboCop::RakeTask.new
13
+ task(:fix_fmt) { cargo("fmt") }
14
+ task(:fix_cargo) { cargo("fix --allow-dirty --allow-staged") }
15
+ task(:fix_clippy) { cargo("clippy --fix --allow-dirty --allow-staged") }
16
+ task(:fix_rubocop) { exec("bundle exec rubocop -A") }
17
+ task(fix: [:fix_fmt, :fix_cargo, :fix_clippy, :fix_rubocop])
18
+
19
+ task(:check_fmt) { cargo("fmt --check") }
20
+ task(:check_clippy) { cargo("clippy") }
21
+ task(:check_rubocop) { exec("bundle exec rubocop") }
22
+ task(check: [:check_fmt, :check_clippy, :check_rubocop])
11
23
 
12
- task default: [:spec, :rubocop]
24
+ task(:compile) { cargo("build --release") }
25
+ task(spec: :compile)
26
+ task(default: [:spec, :rubocop])
data/exe/ko CHANGED
@@ -9,23 +9,35 @@ end
9
9
  class MyObject < KO::Object
10
10
  signal :something
11
11
 
12
- # def on_ready do
12
+ # def on_ready
13
13
  # pp("Ready #{id}")
14
14
  # end
15
15
  end
16
16
 
17
- MyApplication[] do
18
- x = MyObject["first"] do
19
- signal :blah
17
+ KO::Application[] do
18
+ KO::Object["1"] do
19
+ on_ready do
20
+ pp("Ready #{id}")
21
+ end
20
22
 
21
- MyObject["second"]
23
+ KO::Object["11"] do
24
+ on_ready do
25
+ pp("Ready #{id}")
26
+ end
27
+ end
28
+ end
22
29
 
30
+ KO::Object["2"] do
23
31
  on_ready do
24
32
  pp("Ready #{id}")
25
33
  end
34
+
35
+ KO::Object["22"] do
36
+ on_ready do
37
+ pp("Ready #{id}")
38
+ end
39
+ end
26
40
  end
27
- t = MyObject["third"]
28
- t.parent = x
29
41
  end
30
42
 
31
43
  pp MyApplication.instance
data/ext/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ task :default do
4
+ system("cargo build --release", exception: true)
5
+ end
data/ko.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/ko/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ko"
7
+ spec.version = KO::VERSION
8
+ spec.authors = ["Gleb Sinyavskiy"]
9
+ spec.email = ["zhulik.gleb@gmail.com"]
10
+
11
+ spec.summary = "KO"
12
+ spec.description = "KO"
13
+ spec.homepage = "https://github.com/zhulik/ko"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+
17
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ spec.files = Dir.glob("lib/**/*.rb") +
24
+ Dir.glob("exe/**/*") +
25
+ Dir.glob("Cargo*") +
26
+ Dir.glob("src/**/*.rs") +
27
+ [
28
+ "ext/Rakefile",
29
+ "ko.gemspec",
30
+ "Rakefile"
31
+ ]
32
+
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib", "src", "exe"]
36
+
37
+ spec.extensions << "ext/Rakefile"
38
+
39
+ spec.add_dependency "binding_of_caller", "~> 1.0.0"
40
+ spec.add_dependency "rutie", "~> 0.0.4"
41
+ spec.add_dependency "zeitwerk", "~> 2.6.0"
42
+
43
+ spec.metadata["rubygems_mfa_required"] = "true"
44
+ end
@@ -7,9 +7,9 @@ module KO
7
7
  def instance = $_KO_APP
8
8
  end
9
9
 
10
- def initialize(id: nil)
10
+ def initialize(id: nil, parent: nil)
11
11
  begin
12
- super(id: id || "app")
12
+ super(id: id || "app", parent:)
13
13
  rescue InvalidParent
14
14
  @parent = nil
15
15
  end
data/lib/ko/children.rb CHANGED
@@ -5,13 +5,13 @@ module KO
5
5
  include Enumerable
6
6
 
7
7
  def initialize
8
- @store = Set.new
8
+ @store = {}
9
9
  end
10
10
 
11
11
  # TODO: use index
12
12
  def [](id) = @store.find { _1.id == id }
13
13
 
14
- def add(obj) = @store << obj
14
+ def add(obj) = @store[obj] = obj
15
15
 
16
16
  def remove(obj)
17
17
  raise UnknownChildError unless @store.include?(obj)
@@ -19,10 +19,12 @@ module KO
19
19
  @store.delete(obj)
20
20
  end
21
21
 
22
+ def to_a = @store.keys
23
+
22
24
  def inspect = to_a.inspect
23
25
  def pretty_inspect = to_a.pretty_inspect
24
26
 
25
- def each(...) = @store.each(...)
27
+ def each(...) = @store.each_key(...)
26
28
  def count(...) = @store.count(...)
27
29
  end
28
30
  end
data/lib/ko/object.rb CHANGED
@@ -3,10 +3,11 @@
3
3
  module KO
4
4
  class Object
5
5
  extend Signals
6
+ extend Properties
6
7
 
7
8
  class << self
8
- def [](id = nil, &)
9
- new(id:).tap do |obj|
9
+ def [](id = nil, parent = nil, &)
10
+ new(id:, parent:).tap do |obj|
10
11
  obj.instance_exec(&) if block_given?
11
12
  obj.ready.emit
12
13
  end
@@ -17,9 +18,9 @@ module KO
17
18
 
18
19
  signal :ready
19
20
 
20
- def initialize(id: nil)
21
+ def initialize(id: nil, parent: nil)
21
22
  @id = id
22
- self.parent = find_parent
23
+ self.parent = parent || find_parent
23
24
  end
24
25
 
25
26
  def children = @children ||= Children.new
@@ -39,24 +40,19 @@ module KO
39
40
  end
40
41
 
41
42
  def remove_child(obj) = children.remove(obj)
42
-
43
43
  def [](id) = children[id]
44
-
45
- def app
46
- @app ||= begin
47
- obj = self
48
- obj = obj.parent until obj.parent.nil?
49
- obj
50
- end
51
- end
44
+ def app = KO::Application.instance
45
+ def _ = self
52
46
 
53
47
  def inspect
54
48
  id_str = id.nil? ? "" : "[#{id.inspect}]"
55
- "#<#{self.class}#{id_str} signals=#{signals.count} properties=0 children=#{children.count}>"
49
+ "#<#{self.class}#{id_str} signals=#{signals.count} properties=#{properties.count} children=#{children.count}>"
56
50
  end
57
51
 
58
52
  private
59
53
 
54
+ attr_writer :id
55
+
60
56
  def find_parent
61
57
  binding.callers[2..].each do |caller|
62
58
  obj = caller.receiver
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module KO
4
+ module Properties
5
+ def property(name, type, value: nil, on_change: nil) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity
6
+ types = [type].flatten
7
+ value ||= type.new if type.is_a?(Class)
8
+
9
+ raise TypeError if types.none? { value.is_a?(_1) }
10
+
11
+ signal :"#{name}_changed", type
12
+
13
+ define_method(name) do
14
+ return properties[name] if properties.key?(name)
15
+
16
+ properties[name] = value
17
+ end
18
+
19
+ define_method("#{name}=") do |new_value|
20
+ raise TypeError if types.none? { value.is_a?(_1) }
21
+
22
+ return new_value if new_value == properties[name]
23
+
24
+ properties[name] = new_value
25
+ send(on_change) if on_change
26
+ signals[:"#{name}_changed"].emit(new_value)
27
+ new_value
28
+ end
29
+ end
30
+
31
+ module InstanceMethods
32
+ def bind(prop_name, from, from_prop_name)
33
+ setter = method("#{prop_name}=")
34
+ setter.call(from.send(from_prop_name))
35
+
36
+ from.send("#{from_prop_name}_changed").connect(setter)
37
+ end
38
+
39
+ def properties = @properties ||= {}
40
+ end
41
+
42
+ def self.extended(base)
43
+ base.include(InstanceMethods)
44
+ end
45
+ end
46
+ end
@@ -3,12 +3,10 @@
3
3
  module KO
4
4
  module Signals
5
5
  class Connection
6
- attr_reader :callable, :mode, :signal
6
+ attr_reader :receiver, :mode, :signal
7
7
 
8
- def initialize(callable, signal, mode:, one_shot:)
9
- Validator.new(signal).validate_callable_type!(callable)
10
-
11
- @callable = callable
8
+ def initialize(receiver, signal, mode:, one_shot:)
9
+ @receiver = receiver
12
10
  @signal = signal
13
11
  @mode = mode
14
12
  @one_shot = one_shot
@@ -17,16 +15,14 @@ module KO
17
15
  def one_shot? = @one_shot
18
16
 
19
17
  def call(*args, force_direct: false) # rubocop:disable Lint/UnusedMethodArgument
20
- return @callable.call(*args) if @callable.is_a?(Method) || @callable.is_a?(Signal)
21
-
22
- @callable.send(signal.receiver_name, *args)
18
+ @receiver.call(*args)
23
19
  rescue StandardError => e
24
20
  warn(e)
21
+ ensure
22
+ disconnect if one_shot?
25
23
  end
26
24
 
27
- def disconnect
28
- @signal.disconnect(@callable)
29
- end
25
+ def disconnect = @signal.disconnect(@receiver)
30
26
  end
31
27
  end
32
28
  end
@@ -3,7 +3,7 @@
3
3
  module KO
4
4
  module Signals
5
5
  class Signal
6
- attr_reader :name, :arg_types, :connections
6
+ attr_reader :name, :arg_types, :connections, :parent
7
7
 
8
8
  def initialize(name, arg_types)
9
9
  @name = name
@@ -13,40 +13,52 @@ module KO
13
13
  @connections = {}
14
14
  end
15
15
 
16
- def dup = super().tap { _1.connections.clear }
16
+ def parent=(obj)
17
+ raise KO::SignalParentOverrideError unless @parent.nil?
18
+ raise KO::InvalidParent unless obj.is_a?(KO::Object)
17
19
 
18
- def receiver_name = "on_#{name}".to_sym
20
+ @parent = obj
21
+ end
22
+
23
+ def dup = self.class.new(name, arg_types)
24
+
25
+ def receiver_name = :"on_#{name}"
19
26
 
20
- # Only 3 ways to connect:
21
- # some_object.some_signal.connect(receiver) -> receiver#on_some_signal
22
- # some_object.some_signal.connect(receiver.method(:do_something)) -> receiver#do_something
23
- # some_object.some_signal.connect(receiver.another_signal) -> emits receiver#another_signal
24
- # Blocks, Procs and Lambda are not supported on purpose
25
- def connect(callable = nil, mode: :direct, one_shot: false)
26
- @validator.validate_callable!(callable)
27
+ def connect(receiver = nil, mode: :direct, one_shot: false, &block)
28
+ receiver = normalize_receiver(receiver) || block
29
+ @validator.validate_receiver!(receiver)
27
30
 
28
- Connection.new(callable, self, mode:, one_shot:).tap { @connections[callable] = _1 }
31
+ raise "ALREADY CONNECTED" if @connections.include?(receiver)
32
+
33
+ Connection.new(receiver, self, mode:, one_shot:).tap { @connections[receiver] = _1 }
29
34
  end
30
35
 
31
- def disconnect(callable)
32
- raise ArgumentError, "given callable is not connected to this signal" if @connections.delete(callable).nil?
36
+ def disconnect(receiver)
37
+ receiver = normalize_receiver(receiver)
38
+ raise ArgumentError, "given receiver is not connected to this signal" if @connections.delete(receiver).nil?
33
39
  end
34
40
 
35
41
  def emit(*args)
36
42
  @validator.validate_args!(args)
43
+
37
44
  notify_subscribers(args)
38
45
  end
39
46
 
40
- def inspect = "#<#{self.class}[#{name.inspect}] connections=#{@connections.count}>"
47
+ def inspect = "#<#{self.class}@#{object_id}[#{name.inspect}] connections=#{@connections.count}>"
41
48
 
42
49
  def call(...) = emit(...)
43
50
 
44
- def notify_subscribers(args)
45
- @connections.values.shuffle.each do |connection|
46
- connection.call(*args)
47
- ensure
48
- connection.disconnect if connection.one_shot?
49
- end
51
+ private
52
+
53
+ def notify_subscribers(args) = @connections.each_value { _1.call(*args) }
54
+
55
+ def normalize_receiver(receiver)
56
+ return if receiver.nil?
57
+ return receiver if receiver.respond_to?(:call)
58
+
59
+ return parent.method(receiver) if receiver.is_a?(Symbol)
60
+
61
+ receiver.method(receiver_name) if receiver.respond_to?(receiver_name)
50
62
  end
51
63
  end
52
64
  end
@@ -15,22 +15,26 @@ module KO
15
15
  raise KO::EmitError, "expected args: #{@signal.arg_types}. given: #{types}"
16
16
  end
17
17
 
18
- def validate_callable!(callable)
19
- callable = validate_callable_type!(callable)
20
- validate_signal_arity!(callable) if callable.is_a?(Signal)
18
+ def validate_receiver!(receiver)
19
+ validate_receiver_type!(receiver)
20
+ validate_signal_arity!(receiver) if receiver.is_a?(Signal)
21
21
  end
22
22
 
23
- def validate_callable_type!(callable)
24
- return callable if callable.is_a?(Signal) || callable.is_a?(Method)
23
+ def validate_receiver_type!(receiver)
24
+ name = @signal.receiver_name
25
+ return if receiver.respond_to?(:call) || receiver.respond_to?(name)
25
26
 
26
- return callable.method(@signal.receiver_name) if callable.respond_to?(@signal.receiver_name)
27
-
28
- raise ArgumentError, "callable must be a Signal, a Method, or must respond to #{@signal.receiver_name}"
27
+ raise ArgumentError, "receiver must be a Signal, callable or respond to #{name}: #{receiver.class}"
29
28
  end
30
29
 
31
30
  private
32
31
 
33
- def types_match?(types) = types.each.with_index.all? { _1.ancestors.include?(@signal.arg_types[_2]) }
32
+ def types_match?(types)
33
+ types.each.with_index.all? do |klass, i|
34
+ valid_types = [@signal.arg_types[i]].flatten
35
+ valid_types.any? { klass.ancestors.include?(_1) }
36
+ end
37
+ end
34
38
 
35
39
  def validate_signal_arity!(signal)
36
40
  return if signal.arg_types == @signal.arg_types
data/lib/ko/signals.rb CHANGED
@@ -7,19 +7,18 @@ module KO
7
7
  def respond_to_missing?(name, include_private = false); end
8
8
 
9
9
  def method_missing(name, *args, **params, &)
10
- sigs = signals.each.with_object({}) { |(_k, v), acc| acc[v.receiver_name] = v }
11
- super unless sigs.include?(name)
10
+ _, signal = signals.find { _2.receiver_name == name } || super
12
11
 
13
- define_singleton_method(name, &)
14
-
15
- sigs[name].connect(self)
12
+ signal.connect(&)
16
13
  end
17
14
 
18
15
  private
19
16
 
20
- def signals = @signals ||= self.class.signals.transform_values(&:dup)
21
-
22
- def emit(name, *args) = send(name).call(*args)
17
+ def signals
18
+ @signals ||= self.class.signals.transform_values do |s|
19
+ s.dup.tap { _1.parent = self }
20
+ end
21
+ end
23
22
  end
24
23
 
25
24
  module AddSignal
data/lib/ko/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KO
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/ko.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  require_relative "ko/version"
4
4
 
5
5
  require "zeitwerk"
6
-
7
6
  require "binding_of_caller"
7
+ require "rutie"
8
8
 
9
9
  loader = Zeitwerk::Loader.for_gem
10
10
  loader.inflector.inflect(
@@ -13,6 +13,8 @@ loader.inflector.inflect(
13
13
  loader.setup
14
14
 
15
15
  module KO
16
+ Rutie.new(:ko).init "Init_ko", __dir__
17
+
16
18
  class Error < StandardError; end
17
19
 
18
20
  class InvalidParent < Error
@@ -29,4 +31,5 @@ module KO
29
31
 
30
32
  class UnknownChildError < Error; end
31
33
  class EmitError < Error; end
34
+ class SignalParentOverrideError < Error; end
32
35
  end
data/src/lib.rs ADDED
@@ -0,0 +1,7 @@
1
+ use rutie::{Module, Object};
2
+
3
+ #[allow(non_snake_case)]
4
+ #[no_mangle]
5
+ pub extern "C" fn Init_ko() {
6
+ Module::new("KO").define(|_module| {});
7
+ }
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-09 00:00:00.000000000 Z
11
+ date: 2023-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: async
14
+ name: binding_of_caller
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.5.0
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.5.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: binding_of_caller
28
+ name: rutie
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 0.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: 0.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zeitwerk
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -57,29 +57,27 @@ email:
57
57
  - zhulik.gleb@gmail.com
58
58
  executables:
59
59
  - ko
60
- extensions: []
60
+ extensions:
61
+ - ext/Rakefile
61
62
  extra_rdoc_files: []
62
63
  files:
63
- - ".overcommit.yml"
64
- - ".rspec"
65
- - ".rubocop.yml"
66
- - ".tool-versions"
67
- - CODE_OF_CONDUCT.md
68
- - Gemfile
69
- - Gemfile.lock
70
- - LICENSE.txt
71
- - README.md
64
+ - Cargo.lock
65
+ - Cargo.toml
72
66
  - Rakefile
73
67
  - exe/ko
68
+ - ext/Rakefile
69
+ - ko.gemspec
74
70
  - lib/ko.rb
75
71
  - lib/ko/application.rb
76
72
  - lib/ko/children.rb
77
73
  - lib/ko/object.rb
74
+ - lib/ko/properties.rb
78
75
  - lib/ko/signals.rb
79
76
  - lib/ko/signals/connection.rb
80
77
  - lib/ko/signals/signal.rb
81
78
  - lib/ko/signals/validator.rb
82
79
  - lib/ko/version.rb
80
+ - src/lib.rs
83
81
  homepage: https://github.com/zhulik/ko
84
82
  licenses:
85
83
  - MIT
@@ -90,6 +88,8 @@ post_install_message:
90
88
  rdoc_options: []
91
89
  require_paths:
92
90
  - lib
91
+ - src
92
+ - exe
93
93
  required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
data/.overcommit.yml DELETED
@@ -1,4 +0,0 @@
1
- PreCommit:
2
- RuboCop:
3
- enabled: true
4
- on_warn: fail # Treat all warnings as failures
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format progress
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,50 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 3.2
3
- NewCops: enable
4
- SuggestExtensions: false
5
-
6
- require:
7
- - rubocop-performance
8
- - rubocop-rspec
9
-
10
- Layout/LineLength:
11
- Max: 120
12
- Exclude:
13
- - spec/**/*_spec.rb
14
-
15
- Metrics/BlockLength:
16
- Exclude:
17
- - spec/**/*_spec.rb
18
- - "*.gemspec"
19
-
20
- Metrics/MethodLength:
21
- Max: 10
22
-
23
- RSpec/NamedSubject:
24
- Enabled: false
25
-
26
- Style/StringLiterals:
27
- Enabled: true
28
- EnforcedStyle: double_quotes
29
-
30
- Style/StringLiteralsInInterpolation:
31
- Enabled: true
32
- EnforcedStyle: double_quotes
33
-
34
- Style/Documentation:
35
- Enabled: false
36
-
37
- Style/SymbolArray:
38
- EnforcedStyle: brackets
39
-
40
- Style/WordArray:
41
- EnforcedStyle: brackets
42
-
43
- Style/NumberedParametersLimit:
44
- Max: 2
45
-
46
- RSpec/EmptyExampleGroup:
47
- AutoCorrect: false
48
-
49
- RSpec/NestedGroups:
50
- Max: 5
data/.tool-versions DELETED
@@ -1,2 +0,0 @@
1
- ruby 3.2.1
2
-
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at zhulik.gleb@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile DELETED
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in ko.gemspec
6
- gemspec
7
-
8
- group :development, :test do
9
- gem "overcommit", require: false
10
- gem "rake", require: false
11
- gem "rspec", require: false
12
- gem "rubocop", require: false
13
- gem "rubocop-performance", require: false
14
- gem "rubocop-rspec", require: false
15
- gem "simplecov", require: false
16
- gem "solargraph", require: false
17
-
18
- gem "async-rspec"
19
- end
data/Gemfile.lock DELETED
@@ -1,141 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- ko (0.1.2)
5
- async (~> 2.5.0)
6
- binding_of_caller (~> 1.0.0)
7
- zeitwerk (~> 2.6.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ast (2.4.2)
13
- async (2.5.0)
14
- console (~> 1.10)
15
- io-event (~> 1.1)
16
- timers (~> 4.1)
17
- async-rspec (1.16.1)
18
- rspec (~> 3.0)
19
- rspec-files (~> 1.0)
20
- rspec-memory (~> 1.0)
21
- backport (1.2.0)
22
- benchmark (0.2.1)
23
- binding_of_caller (1.0.0)
24
- debug_inspector (>= 0.0.1)
25
- childprocess (4.1.0)
26
- console (1.16.2)
27
- fiber-local
28
- debug_inspector (1.1.0)
29
- diff-lcs (1.5.0)
30
- docile (1.4.0)
31
- e2mmap (0.1.0)
32
- fiber-local (1.0.0)
33
- iniparse (1.5.0)
34
- io-event (1.1.7)
35
- jaro_winkler (1.5.4)
36
- json (2.6.3)
37
- kramdown (2.4.0)
38
- rexml
39
- kramdown-parser-gfm (1.1.0)
40
- kramdown (~> 2.0)
41
- nokogiri (1.14.2-x86_64-linux)
42
- racc (~> 1.4)
43
- overcommit (0.60.0)
44
- childprocess (>= 0.6.3, < 5)
45
- iniparse (~> 1.4)
46
- rexml (~> 3.2)
47
- parallel (1.22.1)
48
- parser (3.2.1.0)
49
- ast (~> 2.4.1)
50
- racc (1.6.2)
51
- rainbow (3.1.1)
52
- rake (13.0.6)
53
- regexp_parser (2.7.0)
54
- reverse_markdown (2.1.1)
55
- nokogiri
56
- rexml (3.2.5)
57
- rspec (3.12.0)
58
- rspec-core (~> 3.12.0)
59
- rspec-expectations (~> 3.12.0)
60
- rspec-mocks (~> 3.12.0)
61
- rspec-core (3.12.1)
62
- rspec-support (~> 3.12.0)
63
- rspec-expectations (3.12.2)
64
- diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.12.0)
66
- rspec-files (1.1.3)
67
- rspec (~> 3.0)
68
- rspec-memory (1.0.3)
69
- rspec (~> 3.0)
70
- rspec-mocks (3.12.3)
71
- diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.12.0)
73
- rspec-support (3.12.0)
74
- rubocop (1.46.0)
75
- json (~> 2.3)
76
- parallel (~> 1.10)
77
- parser (>= 3.2.0.0)
78
- rainbow (>= 2.2.2, < 4.0)
79
- regexp_parser (>= 1.8, < 3.0)
80
- rexml (>= 3.2.5, < 4.0)
81
- rubocop-ast (>= 1.26.0, < 2.0)
82
- ruby-progressbar (~> 1.7)
83
- unicode-display_width (>= 2.4.0, < 3.0)
84
- rubocop-ast (1.26.0)
85
- parser (>= 3.2.1.0)
86
- rubocop-capybara (2.17.1)
87
- rubocop (~> 1.41)
88
- rubocop-performance (1.16.0)
89
- rubocop (>= 1.7.0, < 2.0)
90
- rubocop-ast (>= 0.4.0)
91
- rubocop-rspec (2.19.0)
92
- rubocop (~> 1.33)
93
- rubocop-capybara (~> 2.17)
94
- ruby-progressbar (1.11.0)
95
- simplecov (0.22.0)
96
- docile (~> 1.1)
97
- simplecov-html (~> 0.11)
98
- simplecov_json_formatter (~> 0.1)
99
- simplecov-html (0.12.3)
100
- simplecov_json_formatter (0.1.4)
101
- solargraph (0.48.0)
102
- backport (~> 1.2)
103
- benchmark
104
- bundler (>= 1.17.2)
105
- diff-lcs (~> 1.4)
106
- e2mmap
107
- jaro_winkler (~> 1.5)
108
- kramdown (~> 2.3)
109
- kramdown-parser-gfm (~> 1.1)
110
- parser (~> 3.0)
111
- reverse_markdown (>= 1.0.5, < 3)
112
- rubocop (>= 0.52)
113
- thor (~> 1.0)
114
- tilt (~> 2.0)
115
- yard (~> 0.9, >= 0.9.24)
116
- thor (1.2.1)
117
- tilt (2.1.0)
118
- timers (4.3.5)
119
- unicode-display_width (2.4.2)
120
- webrick (1.7.0)
121
- yard (0.9.28)
122
- webrick (~> 1.7.0)
123
- zeitwerk (2.6.7)
124
-
125
- PLATFORMS
126
- x86_64-linux
127
-
128
- DEPENDENCIES
129
- async-rspec
130
- ko!
131
- overcommit
132
- rake
133
- rspec
134
- rubocop
135
- rubocop-performance
136
- rubocop-rspec
137
- simplecov
138
- solargraph
139
-
140
- BUNDLED WITH
141
- 2.4.6
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2023 Gleb Sinyavskiy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # KO
2
-
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- 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/ko`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- 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.
26
-
27
- 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).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ko. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/ko/blob/main/CODE_OF_CONDUCT.md).
32
-
33
- ## License
34
-
35
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
36
-
37
- ## Code of Conduct
38
-
39
- Everyone interacting in the KO project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ko/blob/main/CODE_OF_CONDUCT.md).