formkeep 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7670cea963a3c7a33db9ef8ac3d0e968cb0bb852
4
+ data.tar.gz: 330b85f4e7329bf3aafe0f6241e3d3bfa51019b0
5
+ SHA512:
6
+ metadata.gz: 2b555b7424a584c82f1de2273647e3cfc3027326ebb5d3f98de1e19f207da38ac7b0e80c14fd6a72dc0743edb3001a03dfaff4a5c999f720b30edaf152dd1bd1
7
+ data.tar.gz: c78de6382573c8b42e3b4f3f8c296c98f5e536cba2b8fd885b783dfa5a137693a61902d58422113bb6c60afda5a74ca160930ba25666d645f6fdaaa6cf232ca1
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Change Log
2
+
3
+ ## Unreleased
4
+
5
+ - `formkeep check`
6
+ - `formkeep unread`
7
+ - `formkeep latest`
8
+
9
+ ## 0.0.1 --- 2014-10-17
10
+
11
+ ### Added
12
+
13
+ - Initial commit
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in formkeep.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 brandonpittman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # Formkeep
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'formkeep'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install formkeep
20
+
21
+ ## Usage
22
+
23
+ ~~~rb
24
+ # Check for unread submissions
25
+ formkeep check
26
+ # Print unread submissions
27
+ formkeep unread
28
+ # Print newest submission
29
+ formkeep newest
30
+ ~~~
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/[my-github-username]/formkeep/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bin/formkeep ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'formkeep'
data/formkeep.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'formkeep/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "formkeep"
8
+ spec.version = Formkeep::VERSION
9
+ spec.authors = ["brandonpittman"]
10
+ spec.email = ["brandonpittman@gmail.com"]
11
+ spec.summary = %q{A library for interacting with the formkeep API.}
12
+ spec.description = %q{A library for interacting with the formkeep API.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/lib/formkeep.rb ADDED
@@ -0,0 +1,81 @@
1
+ require "formkeep/version"
2
+ require 'pp'
3
+ require 'json'
4
+ require 'net/http'
5
+ require 'yaml/store'
6
+
7
+ # @author Brandon Pittman
8
+ module Formkeep
9
+ class Cli
10
+
11
+ attr_accessor :form
12
+
13
+ def initialize(form)
14
+ @form = form
15
+ end
16
+
17
+ # @!group Getters
18
+ def config
19
+ YAML::Store.new("#{Dir.home}/.formkeep.yaml")
20
+ end
21
+
22
+ def get_key(key)
23
+ store = config
24
+ store.transaction do
25
+ store[key]
26
+ end
27
+ end
28
+
29
+ def set_key(key, value)
30
+ store = config
31
+ store.transaction do
32
+ store[key] = value
33
+ end
34
+ end
35
+
36
+ # Sets API endpoint
37
+ def api
38
+ get_key(form)
39
+ end
40
+
41
+ def response
42
+ Net::HTTP.get_response(URI(api)).body
43
+ end
44
+
45
+ def submissions
46
+ JSON.parse(response)["submissions"]
47
+ end
48
+
49
+ # Latest submission info
50
+ def latest_submission
51
+ submissions[0]
52
+ end
53
+
54
+ def latest_name
55
+ latest_submission.fetch("name")
56
+ end
57
+
58
+ def latest_email
59
+ latest_submission.fetch("email")
60
+ end
61
+ # @!endgroup
62
+
63
+ # @!group Parsers
64
+ def unread_submissions
65
+ submissions.reject do |submission|
66
+ submission.fetch("read_at")
67
+ end
68
+ end
69
+
70
+ def read_submissions
71
+ submissions.select do |submission|
72
+ submission.fetch("read_at")
73
+ end
74
+ end
75
+ # @!endgroup
76
+ end
77
+ end
78
+
79
+ form = Formkeep::Cli.new("pixelsnatch")
80
+ form.latest_submission.class # => Hash
81
+ form.submissions.class # => Array
@@ -0,0 +1,3 @@
1
+ module Formkeep
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Formkeep do
4
+
5
+ let(:test) {Formkeep::Cli.new("test")}
6
+ let(:pixelsnatch) {Formkeep::Cli.new("pixelsnatch")}
7
+
8
+ it 'has a version number' do
9
+ expect(Formkeep::VERSION).not_to be nil
10
+ end
11
+
12
+ it 'pulls the correct API endpoint from the config YAML file' do
13
+ expect(test.api).to eq("test")
14
+ end
15
+
16
+ it "it pulls a submissions array" do
17
+ expect(pixelsnatch.submissions.class).to eq(Array)
18
+ end
19
+
20
+ it "pulls the latest submission" do
21
+ expect(pixelsnatch.latest_submission.class).to eq(Hash)
22
+ end
23
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'formkeep'
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: formkeep
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - brandonpittman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-23 00:00:00.000000000 Z
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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A library for interacting with the formkeep API.
56
+ email:
57
+ - brandonpittman@gmail.com
58
+ executables:
59
+ - formkeep
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/formkeep
71
+ - formkeep.gemspec
72
+ - lib/formkeep.rb
73
+ - lib/formkeep/version.rb
74
+ - spec/formkeep_spec.rb
75
+ - spec/spec_helper.rb
76
+ homepage: ''
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: A library for interacting with the formkeep API.
100
+ test_files:
101
+ - spec/formkeep_spec.rb
102
+ - spec/spec_helper.rb
103
+ has_rdoc: