doattend 0.1.2 → 0.1.3

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: 4c8f939f5c50767f5eb9bafad844ad915438a4fc
4
- data.tar.gz: 921f1443be878ba218ace7f2971556d7988196db
3
+ metadata.gz: 9257a343d6da9bd6015e07ec91feae08c48a5235
4
+ data.tar.gz: ff4d675b947331de7c90b7e03d06632bf0fae795
5
5
  SHA512:
6
- metadata.gz: f5a45681208778c0e4b2c4b448fb119ee6a1e4edb35eca86935f4131c66f9af104437d5a0032647c31f4a46e71f19aa8b12ec36268d94748dc2c69ccab42b15d
7
- data.tar.gz: cf5f684471e6b01993d14cf598a9cb5ee5215a9b266637900ee8aef943ee25604b056409a6996de71f61d4b83330e2647e33dd21ce111b2e4feba96277e8b842
6
+ metadata.gz: ce5c83f4d8c37cdcf8cca38943cf7c2f62e9409e3dd01980d1eee283449aaf1a908416e9e559b91ae254fc02307dfb41052120b771a865594943aeedeb775bc1
7
+ data.tar.gz: a2add6d1308a2056ddb6de495ed03af94bcf0c10729a7fbe904bc1f8a079b2bc36ebac55bc8ac93a428191712fcc0c88ec465afe62f6d54e818e86288821888c
data/README.md CHANGED
@@ -64,7 +64,7 @@ Run the following generator to generate config/doattend.yml
64
64
  #### Find a participant by ticket number
65
65
  doattend.participant.find('TICKET_NUMBER')
66
66
 
67
- #### Ascertain whether a key == value
67
+ #### Ascertain a count whether a key == value
68
68
  doattend.participant.ascertain('KEY', 'VALUE')
69
69
 
70
70
  Eg.:
@@ -76,11 +76,17 @@ Run the following generator to generate config/doattend.yml
76
76
  Eg.:
77
77
  doattend.participant.registered.on(Date.new(2013,5,8))
78
78
 
79
+ #### Return array of participant objects based on a single condition
80
+ doattend.participant.where('KEY', 'VALUE')
81
+
82
+ Eg.:
83
+ doattend.participant.where('Nationality', 'Indian')
84
+
79
85
  #### Pluck a field from all participants
80
86
  doattend.participant.pluck('FIELD_NAME')
81
87
 
82
88
  Eg.:
83
- doattend.participant.pluck('Gender')
89
+ doattend.participant.pluck('Email')
84
90
 
85
91
  ## Contributing
86
92
 
@@ -25,11 +25,14 @@ module Doattend
25
25
  end
26
26
 
27
27
  # Count occurences of key/value.
28
+ # Looks like this method is redundant.
29
+ # TODO: Remove this in the next version
28
30
  def ascertain(k, v)
29
31
  if self.general_info.include? k
30
32
  self.result.count{ |p| p[k] == v.downcase }
31
33
  else
32
- self.result.map{ |p| p['participant_information'].select{ |i| i['desc'].strip.downcase == k.split('_').join(' ').downcase and i['info'].strip.downcase == v.downcase } }.flatten.size
34
+ #self.result.map{ |p| p['participant_information'].select{ |i| i['desc'].strip.downcase == k.split('_').join(' ').downcase and i['info'].strip.downcase == v.downcase } }.flatten.size
35
+ get_participant_info(k, v).size
33
36
  end
34
37
  end
35
38
 
@@ -41,7 +44,26 @@ module Doattend
41
44
  def on(date)
42
45
  self.result.select{ |p| Date.iso8601(p['Date']).strftime == date.strftime }
43
46
  end
44
-
47
+
48
+ # Return participant object(s) with a specified key/value.
49
+ def where(k, v)
50
+ if self.general_info.include? k
51
+ self.result.select{ |p| p[k].downcase == v.downcase }
52
+ else
53
+ get_participant_info(k.downcase, v)
54
+ end
55
+ end
56
+
57
+ private
58
+ def get_participant_info(k, v)
59
+ participants = []
60
+ self.result.each do |p|
61
+ p['participant_information'].each do |pz|
62
+ participants << p if pz['desc'] == k and pz['info'].downcase == v.downcase
63
+ end
64
+ end
65
+ participants
66
+ end
45
67
 
46
68
  end
47
69
 
@@ -1,3 +1,3 @@
1
1
  module Doattend
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -34,4 +34,8 @@ describe Doattend::Participant do
34
34
  @doattend.participant.registered.on(Date.new(2013,5,8)).should be_kind_of Array
35
35
  end
36
36
 
37
+ it "should return a participant object(s) based on a condition that is an Array" do
38
+ @doattend.participant.where('Gender', 'Male').should be_instance_of Array
39
+ end
40
+
37
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doattend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swaroop SM
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-09 00:00:00.000000000 Z
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler