carve 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +13 -0
- data/carve.gemspec +2 -1
- data/lib/carve.rb +1 -0
- data/lib/carve/event.rb +18 -0
- data/lib/carve/version.rb +1 -1
- data/spec/carve/document_spec.rb +1 -1
- data/spec/carve/event_spec.rb +52 -0
- data/spec/carve/version_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -1
- metadata +31 -41
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -38,8 +38,21 @@ Replace the url with a url of the PDF or Microsoft Word file you choose.
|
|
38
38
|
|
39
39
|
$ Carve::Document.pages("id_of_document")
|
40
40
|
|
41
|
+
### List Events
|
42
|
+
|
43
|
+
```bash
|
44
|
+
$ Carve::Event.all
|
45
|
+
$ Carve::Event.all(:type => "document.done", :count => 100)
|
46
|
+
```
|
47
|
+
|
41
48
|
## Contributing
|
42
49
|
|
50
|
+
0. Add your application configuration to your .env file in the root of this project
|
51
|
+
|
52
|
+
```bash
|
53
|
+
$ echo "CARVE_SECRET_API_KEY=yourkey" > .env
|
54
|
+
```
|
55
|
+
|
43
56
|
1. Fork it
|
44
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
58
|
3. export CARVE_SECRET_API_KEY="your_test_secret_api_key"
|
data/carve.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["scott@scottmotte.com"]
|
11
11
|
gem.description = %q{Ruby bindings for the Carve.io API.}
|
12
12
|
gem.summary = %q{Convert documents or webpages to PDF and PNGs}
|
13
|
-
gem.homepage = "http://
|
13
|
+
gem.homepage = "http://github.com/scottmotte/carve-ruby"
|
14
14
|
|
15
15
|
gem.add_dependency "faraday"
|
16
16
|
gem.add_dependency "faraday_middleware"
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency "pry"
|
20
20
|
gem.add_development_dependency "rake"
|
21
21
|
gem.add_development_dependency "rspec"
|
22
|
+
gem.add_development_dependency "dotenv"
|
22
23
|
|
23
24
|
gem.files = `git ls-files`.split($/)
|
24
25
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/carve.rb
CHANGED
data/lib/carve/event.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Carve
|
2
|
+
class Event
|
3
|
+
#
|
4
|
+
# Api calls
|
5
|
+
#
|
6
|
+
def self.all(options={})
|
7
|
+
url = ["events.json?"]
|
8
|
+
url << "type=#{options[:type]}" if options[:type]
|
9
|
+
url << "count=#{options[:count]}" if options[:count]
|
10
|
+
url << "offset=#{options[:offset]}" if options[:offset]
|
11
|
+
|
12
|
+
url = url.join("&")
|
13
|
+
|
14
|
+
response = Carve.request.get url
|
15
|
+
RecursiveOpenStruct.new(response.body, :recurse_over_arrays => true)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/carve/version.rb
CHANGED
data/spec/carve/document_spec.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Carve::Event do
|
4
|
+
let(:subject) { Carve::Event }
|
5
|
+
|
6
|
+
context "incorrect secret api key" do
|
7
|
+
before do
|
8
|
+
Carve.secret_api_key = "incorrect_secret_api_key"
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "attempt .all" do
|
12
|
+
before do
|
13
|
+
@response = subject.all
|
14
|
+
end
|
15
|
+
|
16
|
+
it do
|
17
|
+
@response.success.should be_false
|
18
|
+
@response.error.message.should_not be_empty
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "correct secret api key" do
|
24
|
+
before do
|
25
|
+
Carve.secret_api_key = ENV['CARVE_SECRET_API_KEY']
|
26
|
+
end
|
27
|
+
|
28
|
+
describe ".all" do
|
29
|
+
before do
|
30
|
+
@response = subject.all(attrs)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "default" do
|
34
|
+
let(:attrs) { {} }
|
35
|
+
|
36
|
+
it do
|
37
|
+
@response.success.should be_true
|
38
|
+
@response.events.count.should eq 10
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "filters" do
|
43
|
+
let(:attrs) { {count: 20, type: "document.done"} }
|
44
|
+
|
45
|
+
it do
|
46
|
+
@response.success.should be_true
|
47
|
+
@response.events.count.should eq 20
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/carve/version_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,8 @@ require 'rubygems'
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'pry'
|
4
4
|
require 'carve'
|
5
|
+
require 'dotenv'
|
6
|
+
Dotenv.load
|
5
7
|
|
6
8
|
Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
|
7
9
|
|
@@ -17,4 +19,4 @@ end
|
|
17
19
|
|
18
20
|
def set_secret_and_public_api_keys!
|
19
21
|
Carve.secret_api_key = ENV['CARVE_SECRET_API_KEY']
|
20
|
-
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &16773280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *16773280
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: faraday_middleware
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &16772380 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :runtime
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *16772380
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: recursive-open-struct
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &16771960 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :runtime
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *16771960
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: pry
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &16771500 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: '0'
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
57
|
+
version_requirements: *16771500
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: rake
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &16787420 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ! '>='
|
@@ -85,15 +65,10 @@ dependencies:
|
|
85
65
|
version: '0'
|
86
66
|
type: :development
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
68
|
+
version_requirements: *16787420
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
70
|
name: rspec
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirement: &16787000 !ruby/object:Gem::Requirement
|
97
72
|
none: false
|
98
73
|
requirements:
|
99
74
|
- - ! '>='
|
@@ -101,12 +76,18 @@ dependencies:
|
|
101
76
|
version: '0'
|
102
77
|
type: :development
|
103
78
|
prerelease: false
|
104
|
-
version_requirements:
|
79
|
+
version_requirements: *16787000
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: dotenv
|
82
|
+
requirement: &16786540 !ruby/object:Gem::Requirement
|
105
83
|
none: false
|
106
84
|
requirements:
|
107
85
|
- - ! '>='
|
108
86
|
- !ruby/object:Gem::Version
|
109
87
|
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *16786540
|
110
91
|
description: Ruby bindings for the Carve.io API.
|
111
92
|
email:
|
112
93
|
- scott@scottmotte.com
|
@@ -123,12 +104,14 @@ files:
|
|
123
104
|
- carve.gemspec
|
124
105
|
- lib/carve.rb
|
125
106
|
- lib/carve/document.rb
|
107
|
+
- lib/carve/event.rb
|
126
108
|
- lib/carve/version.rb
|
127
109
|
- spec/carve/document_spec.rb
|
110
|
+
- spec/carve/event_spec.rb
|
128
111
|
- spec/carve/version_spec.rb
|
129
112
|
- spec/carve_spec.rb
|
130
113
|
- spec/spec_helper.rb
|
131
|
-
homepage: http://
|
114
|
+
homepage: http://github.com/scottmotte/carve-ruby
|
132
115
|
licenses: []
|
133
116
|
post_install_message:
|
134
117
|
rdoc_options: []
|
@@ -140,20 +123,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
123
|
- - ! '>='
|
141
124
|
- !ruby/object:Gem::Version
|
142
125
|
version: '0'
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
hash: 4310452240879777070
|
143
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
130
|
none: false
|
145
131
|
requirements:
|
146
132
|
- - ! '>='
|
147
133
|
- !ruby/object:Gem::Version
|
148
134
|
version: '0'
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
hash: 4310452240879777070
|
149
138
|
requirements: []
|
150
139
|
rubyforge_project:
|
151
|
-
rubygems_version: 1.8.
|
140
|
+
rubygems_version: 1.8.11
|
152
141
|
signing_key:
|
153
142
|
specification_version: 3
|
154
143
|
summary: Convert documents or webpages to PDF and PNGs
|
155
144
|
test_files:
|
156
145
|
- spec/carve/document_spec.rb
|
146
|
+
- spec/carve/event_spec.rb
|
157
147
|
- spec/carve/version_spec.rb
|
158
148
|
- spec/carve_spec.rb
|
159
149
|
- spec/spec_helper.rb
|