formkeep 0.0.4 → 0.0.5

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
2
  SHA1:
3
- metadata.gz: 3546579edb5c82ebe4f71cfe320a1fa8d99cf849
4
- data.tar.gz: 3c88d322497c57aa0e5b6c5393bb0af15a1dc53a
3
+ metadata.gz: 39010b85dae02b735ece32fba20d702fd3da5f76
4
+ data.tar.gz: 8780c7d4e51078f7ab0a079a3815c5b3feafbcbd
5
5
  SHA512:
6
- metadata.gz: 9964cf22048441282f6c3bf192f2bba58aa5cc6aaf9164a99b1c45217466d46f23ba3004aee9d91577436b67f2e7f9b9a35b636a24bc5fe5f505b11cb4699dd7
7
- data.tar.gz: 64946daf0ab1a3d931288233d2abab29ef06c67245436f6aeef29c0d74452aec19c62943bc2d4e1dcd9d1e80c04f8bcce3021a41099714301d2eca0c97c9b642
6
+ metadata.gz: e272a06f95e4b4d6c9b751ca0f3b78a8ca64f64d152e8194f3a424dd37eb3acee2b5d7f1ef5255d2cb4157e8d5d64719f782c3ac0ac24c70d4a36cb3f981fbaf
7
+ data.tar.gz: 894ca58ff3ab786fe8d4a1d723ef1cbc2cd1311b64a432602d7d7778af152f026791c9db2d370aaa645a145fcd95afcd875355906d8e941d49ee3faeb2067b66
@@ -3,6 +3,12 @@
3
3
  ## Unreleased
4
4
 
5
5
  - `formkeep add FORM_NAME`
6
+ ## 0.0.5 --- 2014-10-23
7
+
8
+ ### Changed
9
+
10
+ - changed `formkeep check` to `formkeep unread`
11
+
6
12
  ## 0.0.3 --- 2014-10-23
7
13
 
8
14
  ### Added
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  It should look something like this:
26
26
 
27
- ~~~
27
+ ~~~rb
28
28
  form_name: api_endpoint_url_in_full
29
29
  ~~~
30
30
 
@@ -32,8 +32,8 @@ You can have as many form entries as you like. They don't necessarily need to be
32
32
 
33
33
  ## Usage
34
34
 
35
- ~~~
36
- formkeep check FORM
35
+ ~~~rb
36
+ formkeep unread FORM
37
37
  ~~~
38
38
 
39
39
  ## Contributing
@@ -4,16 +4,16 @@ require 'formkeep'
4
4
  require 'slop'
5
5
 
6
6
  opts = Slop.parse do
7
- banner "Usage: formkeep check FORM"
7
+ banner "Usage: formkeep unread FORM"
8
8
  on :h, :help, "Display help"
9
9
  on :v, :version, "Display version" do
10
10
  puts Formkeep::VERSION
11
11
  exit
12
12
  end
13
13
 
14
- command 'check' do
14
+ command 'unread' do
15
15
  banner <<-EOF
16
- Usage: formkeep check FORM
16
+ Usage: formkeep unread FORM
17
17
 
18
18
  Please make sure you have a valid Formkeep API endpoint saved in ~/.formkeep.yaml
19
19
  EOF
@@ -28,4 +28,4 @@ opts = Slop.parse do
28
28
  end
29
29
  end
30
30
 
31
- puts opts unless ARGV[0] == 'check'
31
+ puts opts unless ARGV[0] == 'unread'
@@ -13,23 +13,27 @@ module Formkeep
13
13
 
14
14
  # @!attribute form
15
15
  # @return [String] name of Form to be used
16
+ # @since 0.0.4
16
17
  attr_accessor :form
17
18
 
18
19
  # Creates a Formkeep::Form object to make calling of other methods simpler.
19
20
  # @param [String] form name from `~/.formkeep.yaml`
20
21
  # @return [Formkeep::Form] Form object
22
+ # @since 0.0.4
21
23
  def initialize(form)
22
24
  @form = form
23
25
  end
24
26
 
25
27
  # @!group Getters
26
28
  # @return [Pstore] YAML::Store object
29
+ # @since 0.0.4
27
30
  def config
28
31
  YAML::Store.new("#{Dir.home}/.formkeep.yaml")
29
32
  end
30
33
 
31
34
  # @param [String] key to look up
32
35
  # @return [String] value of key
36
+ # @since 0.0.4
33
37
  def get_key(key)
34
38
  store = config
35
39
  store.transaction do
@@ -40,6 +44,7 @@ module Formkeep
40
44
  # @param [String] key to add/modify
41
45
  # @param [String] value to add/modify
42
46
  # @return [String] value that was added/modified
47
+ # @since 0.0.4
43
48
  def set_key(key, value)
44
49
  store = config
45
50
  store.transaction do
@@ -49,16 +54,19 @@ module Formkeep
49
54
 
50
55
  # Sets API endpoint
51
56
  # @return [String] API endpoint URL
57
+ # @since 0.0.4
52
58
  def api
53
59
  get_key(form)
54
60
  end
55
61
 
56
62
  # @return [String] text of API call
63
+ # @since 0.0.4
57
64
  def response
58
65
  Net::HTTP.get_response(URI(api)).body
59
66
  end
60
67
 
61
68
  # @return [Array] all submissions
69
+ # @since 0.0.4
62
70
  def submissions
63
71
  all = JSON.parse(response)["submissions"]
64
72
  all.reject { |sub| sub["spam"] }
@@ -66,16 +74,19 @@ module Formkeep
66
74
 
67
75
  # Latest submission info
68
76
  # @return [Hash] first submission from submissions array
77
+ # @since 0.0.4
69
78
  def latest_submission
70
79
  submissions[0]
71
80
  end
72
81
 
73
82
  # @return [String] name of latest submission
83
+ # @since 0.0.4
74
84
  def latest_name
75
85
  latest_submission.fetch("name")
76
86
  end
77
87
 
78
88
  # @return [String] email of latest submission
89
+ # @since 0.0.4
79
90
  def latest_email
80
91
  latest_submission.fetch("email")
81
92
  end
@@ -83,6 +94,7 @@ module Formkeep
83
94
 
84
95
  # @!group Parsers
85
96
  # @return [Array] all unread submissions
97
+ # @since 0.0.4
86
98
  def unread_submissions
87
99
  submissions.reject do |submission|
88
100
  submission.fetch("read_at")
@@ -90,6 +102,7 @@ module Formkeep
90
102
  end
91
103
 
92
104
  # @return [Array] all read submissions
105
+ # @since 0.0.4
93
106
  def read_submissions
94
107
  submissions.select do |submission|
95
108
  submission.fetch("read_at")
@@ -1,4 +1,4 @@
1
1
  module Formkeep
2
2
  # Sets version for RubyGems
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
@@ -4,6 +4,7 @@ describe Formkeep do
4
4
 
5
5
  let(:test) {Formkeep::Form.new("test")}
6
6
  let(:pixelsnatch) {Formkeep::Form.new("pixelsnatch")}
7
+ let(:subs) {pixelsnatch.submissions}
7
8
 
8
9
  it 'has a version number' do
9
10
  expect(Formkeep::VERSION).not_to be nil
@@ -14,10 +15,10 @@ describe Formkeep do
14
15
  end
15
16
 
16
17
  it "it pulls a submissions array" do
17
- expect(pixelsnatch.submissions.class).to eq(Array)
18
+ expect(subs.class).to eq(Array)
18
19
  end
19
20
 
20
21
  it "pulls the latest submission" do
21
- expect(pixelsnatch.latest_submission.class).to eq(Hash) if pixelsnatch.submissions.length > 0
22
+ expect(pixelsnatch.latest_submission.class).to eq(Hash) if subs.length > 0
22
23
  end
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formkeep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - brandonpittman