algebrick 0.2.3 → 0.2.4

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/algebrick.rb +12 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89c05ba82f9bb193d0cf67ba85d5fc8138d2a3a3
4
- data.tar.gz: 2dd790e7a2b66e0ae466c2422a053f7acd280e2d
3
+ metadata.gz: f09b0832f9a5c2edf4405f13da8043c747386e1d
4
+ data.tar.gz: 843e5ebce9cf043aad4ef00ca7392c4b67b14c2e
5
5
  SHA512:
6
- metadata.gz: db7d3e5b6f804119b92dd522cf1860fe6c26bf16b14be44c352f82b74728fc563a4665ed698f2fb7f63d8c70d84585abf14a4088cce580da735e6073237073d7
7
- data.tar.gz: ca7af9d723d0c8b57397be9b9cd259a274cd98970af2852257e0d52d786eea9b2e3f822a15abb6bf916b70d7cbda8c64a6ada87f34f9670673474f3f038e77e2
6
+ metadata.gz: fea697e5a2e76357ec555c439b8de4743de67aed5c22b45bdae7195c876583165ba670e2daee57419790d0601606bd3f440cbc9987692c3a7b6385dd9ab1f782
7
+ data.tar.gz: 9e27f6e488fa44b8fe1e6026396a610da4597b9b2030ac4303456b65703ae6d81b5672855a15afaef40c9b6845de2abd9b3f1d44a6c54c67a48c79a55427cda1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/lib/algebrick.rb CHANGED
@@ -606,15 +606,13 @@ module Algebrick
606
606
  alias_method :all_readers, :all_field_readers
607
607
  end
608
608
 
609
- class OuterShellImpl
609
+ class OuterShell
610
610
  include Shortcuts
611
611
 
612
- def run(&block)
612
+ def initialize(&block)
613
613
  instance_eval &block
614
614
  end
615
615
  end
616
-
617
- OuterShell = OuterShellImpl.new
618
616
  end
619
617
 
620
618
  def self.type(&block)
@@ -630,7 +628,7 @@ module Algebrick
630
628
  end
631
629
 
632
630
  def self.types(&block)
633
- DSL::OuterShell.run &block
631
+ DSL::OuterShell.new &block
634
632
  end
635
633
 
636
634
  module Matchers
@@ -695,8 +693,7 @@ module Algebrick
695
693
  end
696
694
 
697
695
  def assigns
698
- mine = @assign ? [@value] : []
699
- children.inject(mine) { |assigns, child| assigns + child.assigns }.tap do
696
+ collect_assigns.tap do
700
697
  return yield *assigns if block_given?
701
698
  end
702
699
  end
@@ -733,6 +730,11 @@ module Algebrick
733
730
 
734
731
  private
735
732
 
733
+ def collect_assigns
734
+ mine = @assign ? [@value] : []
735
+ children.inject(mine) { |assigns, child| assigns + child.assigns }
736
+ end
737
+
736
738
  def matchable!(obj)
737
739
  raise ArgumentError, 'object does not respond to :===' unless obj.respond_to? :===
738
740
  obj
@@ -802,15 +804,15 @@ module Algebrick
802
804
  super.select &:matched?
803
805
  end
804
806
 
805
- def assigns
807
+ private
808
+
809
+ def collect_assigns
806
810
  super.tap do |assigns|
807
811
  missing = assigns_size - assigns.size
808
812
  assigns.push(*::Array.new(missing))
809
813
  end
810
814
  end
811
815
 
812
- private
813
-
814
816
  def assigns_size
815
817
  # TODO is it efficient?
816
818
  super_children.map { |ch| ch.assigns.size }.max
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algebrick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Chalupa