pincushion 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/pincushion/plugins/csv_serializer.rb +6 -8
- data/lib/pincushion/version.rb +1 -1
- data/lib/pincushion.rb +0 -3
- data/spec/pincushion_spec.rb +16 -1
- metadata +12 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: adbd27566528f46d79e0fd15bf71936ed29382d6de0515557e274692bb427400
|
4
|
+
data.tar.gz: ad694d4c37d67c482573857938886cb8e2d212c38cf053f23f2846c73cea4efb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1d878b8ec0d3a5f3609b1df590cf39b7b889563c4b566d25f02b3123a561f424b5623e91d9d736f5b1f370a836b5d33a643499a3ee3127a5744bd9ab3c8bf16
|
7
|
+
data.tar.gz: b854ce1141ccaaefb3580ba7336810c321b05ec4e13fefe73ba5265d60f4f7d957e248450bdff62ce6f2fb88945917c026e4a04a40f70fd062d6546528113e27
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'csv'
|
2
2
|
|
3
3
|
module Pincushion
|
4
|
-
def self.from_csv(csv,
|
5
|
-
|
6
|
-
|
7
|
-
from_rows(CSV.parse(csv, *args).map(&:to_hash))
|
4
|
+
def self.from_csv(csv, opts = {})
|
5
|
+
opts = opts.merge(Plugins::CsvSerializer::OPTS)
|
6
|
+
from_rows(CSV.parse(csv, **opts).map(&:to_hash))
|
8
7
|
end
|
9
8
|
|
10
9
|
module Plugins
|
@@ -22,11 +21,10 @@ module Pincushion
|
|
22
21
|
}.freeze
|
23
22
|
|
24
23
|
module RootModuleMethods
|
25
|
-
def to_csv(
|
26
|
-
|
27
|
-
args.last[:headers] ||= [:identifier, *predicates]
|
24
|
+
def to_csv(opts)
|
25
|
+
opts[:headers] ||= [:identifier, *predicates]
|
28
26
|
|
29
|
-
CSV.generate(
|
27
|
+
CSV.generate(**opts) do |csv|
|
30
28
|
rows.each { |row| csv << row }
|
31
29
|
end
|
32
30
|
end
|
data/lib/pincushion/version.rb
CHANGED
data/lib/pincushion.rb
CHANGED
@@ -54,9 +54,6 @@ module Pincushion
|
|
54
54
|
fail "Predicates can't be changed after initialization" if @predicates
|
55
55
|
@predicates = Set.new(preds)
|
56
56
|
is_not(*@predicates)
|
57
|
-
@predicates.each do |predicate|
|
58
|
-
alias_method(:"is_#{predicate}?", :"#{predicate}?")
|
59
|
-
end
|
60
57
|
end
|
61
58
|
end # module RootModuleMethods
|
62
59
|
|
data/spec/pincushion_spec.rb
CHANGED
@@ -46,7 +46,7 @@ describe Pincushion do
|
|
46
46
|
animals.predicates :herbivore
|
47
47
|
|
48
48
|
elephants = animals.that_are(:herbivore)
|
49
|
-
|
49
|
+
elephants.that_is.named("Tree Trunks")
|
50
50
|
|
51
51
|
assert_raises Pincushion::MissingPredicateError do
|
52
52
|
animals.that_is(:carnivore)
|
@@ -92,4 +92,19 @@ describe Pincushion do
|
|
92
92
|
animals.plugin :json_serializer
|
93
93
|
assert_equal animals.to_json, animal_data_json
|
94
94
|
end
|
95
|
+
|
96
|
+
it "creates question-mark methods, not is-methods" do
|
97
|
+
animals = Module.new { include Pincushion }
|
98
|
+
animals.predicates :herbivore
|
99
|
+
elephants = animals.that_is(:herbivore)
|
100
|
+
assert elephants.new("").herbivore?
|
101
|
+
|
102
|
+
assert_raises(NoMethodError) do
|
103
|
+
elephants.new("").is_herbivore
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_raises(NoMethodError) do
|
107
|
+
elephants.new("").is_herbivore?
|
108
|
+
end
|
109
|
+
end
|
95
110
|
end
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pincushion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Miller
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: rake
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- - "
|
17
|
+
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
19
|
+
version: '0'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- - "
|
24
|
+
- - ">="
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
26
|
+
version: '0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: minitest
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +38,7 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '5.0'
|
55
|
-
description:
|
41
|
+
description:
|
56
42
|
email: bmiller@rackspace.com
|
57
43
|
executables: []
|
58
44
|
extensions: []
|
@@ -69,13 +55,13 @@ homepage: https://github.com/bjmllr/pincushion
|
|
69
55
|
licenses:
|
70
56
|
- MIT
|
71
57
|
metadata: {}
|
72
|
-
post_install_message:
|
58
|
+
post_install_message:
|
73
59
|
rdoc_options: []
|
74
60
|
require_paths:
|
75
61
|
- lib
|
76
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
63
|
requirements:
|
78
|
-
- - "
|
64
|
+
- - ">="
|
79
65
|
- !ruby/object:Gem::Version
|
80
66
|
version: '2.0'
|
81
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -84,9 +70,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
70
|
- !ruby/object:Gem::Version
|
85
71
|
version: '0'
|
86
72
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
73
|
+
rubygems_version: 3.1.6
|
74
|
+
signing_key:
|
90
75
|
specification_version: 4
|
91
76
|
summary: Predicate-centric classification toolkit
|
92
77
|
test_files:
|