pincushion 0.1.0 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8eab64e433918cb3f0881c57abb7d09a4dd1bfac
4
- data.tar.gz: 4ca030d28f2cf4ef8b270d9a47e116cdf4a1e314
3
+ metadata.gz: 217f846dde4bd0ec90ee69747c5e766fd841077f
4
+ data.tar.gz: 5629f332f932df0ad0554860424f40c5fc3e0a70
5
5
  SHA512:
6
- metadata.gz: cb77a2fd89d401c263b68ab334ee3a5eeeefa816d9578be94bb537b800c7d7abaad7169c30dbb7ce44a8dfd1637699c9d9d895e46324f0a851396382c29f6a61
7
- data.tar.gz: 1b6df11775ecd620373e87767ae3e1c927541a0d9d0d145c0b56262ff4e2d357e09b151102563bf61866fdaaa4da8580a2e7d689526ec3ec40fc622f47e44c71
6
+ metadata.gz: 1e89c6a58f94dc875efe71cfd32fbf682dcb02cda2a79220e53bf6b67adf8fccaaa5468df074394f52e80c2a31c4c40c4c199fa09f4023dbf82c1aa832c53a55
7
+ data.tar.gz: f388bcaa354ca75e17d2d961e3767852b70c3c21d4b4c4b9eceb4cf587e43bee6a5ab3ab6845be8604ca309ef6f7ffe122c970e0aa5600abc5c0e83c7cdb2a1c
@@ -69,7 +69,7 @@ module Pincushion
69
69
 
70
70
  def all_predicates_hash
71
71
  obj = new ""
72
- predicate_pincushion_root.predicates.map { |p| [p, obj.is?(p)] }.to_h
72
+ Hash[predicate_pincushion_root.predicates.map { |p| [p, obj.is?(p)] }]
73
73
  end
74
74
 
75
75
  def identifiers
@@ -103,16 +103,16 @@ module Pincushion
103
103
 
104
104
  def that_are(*preds)
105
105
  Pincushion.validate(self, preds)
106
- mod = Module.new
107
- mod.include self
106
+ base = self
107
+ mod = Module.new { include base }
108
108
  mod.is(*preds)
109
109
  mod
110
110
  end
111
111
 
112
112
  def that_is(*preds)
113
113
  Pincushion.validate(self, preds)
114
- klass = Class.new
115
- klass.include self
114
+ base = self
115
+ klass = Class.new { include base }
116
116
  klass.is(*preds)
117
117
  klass
118
118
  end
@@ -141,7 +141,7 @@ module Pincushion
141
141
  end
142
142
 
143
143
  def all_predicates_hash
144
- all_predicates.map { |p| [p, is?(p)] }.to_h
144
+ Hash[all_predicates.map { |p| [p, is?(p)] }]
145
145
  end
146
146
 
147
147
  def is(*preds)
@@ -4,7 +4,7 @@ module Pincushion
4
4
  def self.from_csv(csv, *args)
5
5
  args << {} unless args.last.is_a?(Hash)
6
6
  args.last.merge!(Plugins::CsvSerializer::OPTS)
7
- from_rows(CSV.parse(csv, *args).map(&:to_h))
7
+ from_rows(CSV.parse(csv, *args).map(&:to_hash))
8
8
  end
9
9
 
10
10
  module Plugins
@@ -22,10 +22,11 @@ module Pincushion
22
22
  }.freeze
23
23
 
24
24
  module RootModuleMethods
25
- def to_csv(*args, **kwargs)
26
- kwargs[:headers] ||= [:identifier, *predicates]
25
+ def to_csv(*args)
26
+ args << {} unless args.last.is_a?(Hash)
27
+ args.last[:headers] ||= [:identifier, *predicates]
27
28
 
28
- CSV.generate(*args, **kwargs) do |csv|
29
+ CSV.generate(*args) do |csv|
29
30
  rows.each { |row| csv << row }
30
31
  end
31
32
  end
@@ -1,3 +1,3 @@
1
1
  module Pincushion
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end # module Pincushion
@@ -32,8 +32,7 @@ describe Pincushion do
32
32
  end
33
33
 
34
34
  it "can be used to define a category with properties" do
35
- animals = Module.new
36
- animals.include Pincushion
35
+ animals = Module.new { include Pincushion }
37
36
  animals.predicates :carnivore, :herbivore
38
37
  cat = animals.that_is(:carnivore).named("Mee-mow")
39
38
  mittens = animals.find("Mee-mow")
@@ -43,8 +42,7 @@ describe Pincushion do
43
42
  end
44
43
 
45
44
  it "doesn't allow unregistered predicates" do
46
- animals = Module.new
47
- animals.include Pincushion
45
+ animals = Module.new { include Pincushion }
48
46
  animals.predicates :herbivore
49
47
 
50
48
  assert_raises Pincushion::MissingPredicateError do
@@ -67,8 +65,7 @@ describe Pincushion do
67
65
  end
68
66
 
69
67
  it "doesn't allow unregistered predicates (empty set)" do
70
- animals = Module.new
71
- animals.include Pincushion
68
+ animals = Module.new { include Pincushion }
72
69
  assert_raises Pincushion::MissingPredicateError do
73
70
  animals.that_is(:carnivore)
74
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pincushion
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
  - Ben Miller