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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2945e06d0233460a10e4b18b22244ce4a66d07e8
4
- data.tar.gz: ba2df459865f6b16eac0c9c9d1adab6a3703ef70
2
+ SHA256:
3
+ metadata.gz: adbd27566528f46d79e0fd15bf71936ed29382d6de0515557e274692bb427400
4
+ data.tar.gz: ad694d4c37d67c482573857938886cb8e2d212c38cf053f23f2846c73cea4efb
5
5
  SHA512:
6
- metadata.gz: de1f4128b9292f356a6a6ee5171c1da4f118a833059ca647e591df590d05e4070851bcf1fcd7dc24ee3343de836735d0fabce046b7f61c5ba22c73fd03e1b750
7
- data.tar.gz: 405de72715d2305d32df5829d84c9238e3f9aade26c7ef7cdd1c451716ff0872a069dd08ed1af193facca7c5ce4a7721688769f003927ea5e195d2a2114f8b63
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, *args)
5
- args << {} unless args.last.is_a?(Hash)
6
- args.last.merge!(Plugins::CsvSerializer::OPTS)
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(*args)
26
- args << {} unless args.last.is_a?(Hash)
27
- args.last[:headers] ||= [:identifier, *predicates]
24
+ def to_csv(opts)
25
+ opts[:headers] ||= [:identifier, *predicates]
28
26
 
29
- CSV.generate(*args) do |csv|
27
+ CSV.generate(**opts) do |csv|
30
28
  rows.each { |row| csv << row }
31
29
  end
32
30
  end
@@ -1,3 +1,3 @@
1
1
  module Pincushion
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end # module Pincushion
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
 
@@ -46,7 +46,7 @@ describe Pincushion do
46
46
  animals.predicates :herbivore
47
47
 
48
48
  elephants = animals.that_are(:herbivore)
49
- tiny_elephants = elephants.that_is.named("Tree Trunks")
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.1.3
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: 2016-02-15 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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
- rubyforge_project:
88
- rubygems_version: 2.5.1
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: