pdftable-api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16bbd0ca966781fceef34ec2868a70a8f07d6fd8
4
+ data.tar.gz: e1f87787357625ceb86238f8133e458178b9d29f
5
+ SHA512:
6
+ metadata.gz: ad40f27962af08b5cf9d35f521349e2a7ad4d46ef827ed6c226a285c8814e36acf7195c8fc70249cab96ec152f00bec4faae4fa8ed8a4a6e0c7cee220092c77a
7
+ data.tar.gz: a2bb2deae7ffd96bda03b32c7c5c8919dd67d9669574dfdc5d3c03784be34c60adb8c106d068c5b9f3ddf17cf3eb7eb3dfeecbc6c86d3cd0f459995756449975
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ .DS_Store
12
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.3.0
6
+ before_install: gem install bundler -v 1.13.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pdftable-api.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Edgar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Pdftable-Api
2
+ [![Build Status](https://travis-ci.org/ej2015/pdftable-api.svg?branch=master)](https://travis-ci.org/ej2015/pdftable-api)
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/1cbdaca4ce5f83a9d898/maintainability)](https://codeclimate.com/github/ej2015/pdftable-api/maintainability)
4
+ [![CodeFactor](https://www.codefactor.io/repository/github/ej2015/pdftable-api/badge)](https://www.codefactor.io/repository/github/ej2015/pdftable-api)
5
+
6
+ A little client for pdftables.com API
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'pdftable-api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install pdftable-api
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ ## set your key in an initializer
27
+ Pdftable.configure do |p|
28
+ p.key = 'abcde'
29
+ end
30
+
31
+ ## initialize the client
32
+ client = Pdftable.client
33
+
34
+ ## get to work
35
+ client.remaining_pages
36
+ client.convert(file, format: 'xml')
37
+
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pdftable-api.
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
54
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pdftable/api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ require 'pdftable/version'
2
+ require 'pdftable/configuration'
3
+ require 'pdftable/client'
4
+ require 'pdftable/connection'
5
+ require 'rest-client'
6
+
7
+ module Pdftable
8
+
9
+ class << self
10
+ attr_writer :configuration
11
+
12
+ def configuration
13
+ @configuration ||= Configuration.instance
14
+ end
15
+
16
+ def configure
17
+ yield(configuration)
18
+ end
19
+
20
+ def client
21
+ Pdftable::Client.new
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,21 @@
1
+ module Pdftable
2
+ class Client
3
+
4
+ attr_reader :connection
5
+
6
+ def initialize(connection = nil )
7
+ @connection = connection || Pdftable::Connection.new
8
+ end
9
+
10
+ def convert(file_path, format: 'xml')
11
+ path = "/api"
12
+ connection.post(path, file: file_path, format: format)
13
+ end
14
+
15
+ def remaining_pages
16
+ path = "/api/remaining"
17
+ connection.get(path)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ require 'singleton'
2
+
3
+ module Pdftable
4
+ class Configuration
5
+ include Singleton
6
+
7
+ attr_accessor :host, :key
8
+
9
+ def initialize
10
+ @host = 'pdftables.com'
11
+ @key = nil
12
+ end
13
+
14
+
15
+ end
16
+ end
@@ -0,0 +1,39 @@
1
+ module Pdftable
2
+ class Connection
3
+
4
+ attr_reader :configuration
5
+
6
+ def initialize
7
+ @configuration = Pdftable::Configuration.instance
8
+ end
9
+
10
+ def get (path)
11
+ opt = { key: configuration.key }
12
+ res = RestClient.get url(path, opt)
13
+ parse_response(res)
14
+ end
15
+
16
+ def post (path, file:, format:)
17
+ opt = { key: configuration.key, format: format }
18
+ res = RestClient.post url(path, opt), file: File.new(file, 'rb')
19
+ parse_response(res)
20
+ #req = RestClient::Request.new method: :post, url: uri, payload: { multipart: true, file: File.new("pdf_table.pdf", 'rb')}, headers: {params: {key: 'abcde', format: "xml"}}
21
+ #response = req.execute
22
+ end
23
+
24
+ private
25
+
26
+ def url(path, opt)
27
+ URI::HTTPS.build(host: configuration.host, path: path, query: URI.encode_www_form(opt)).to_s
28
+ end
29
+
30
+ def parse_response(res)
31
+ res.body
32
+ end
33
+
34
+ end
35
+ end
36
+
37
+
38
+
39
+
@@ -0,0 +1,3 @@
1
+ module Pdftable
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pdftable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pdftable-api"
8
+ spec.version = Pdftable::VERSION
9
+ spec.authors = ["Edgar"]
10
+ spec.email = ["zorro.ej@gmail.com"]
11
+
12
+ spec.summary = %q{A simple client for PDFTable API}
13
+ spec.description = %q{Pdftable.client provides two methods: remaining_pages and convert}
14
+ spec.homepage = "https://github.com/ej2015/pdftable-api.git"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+ spec.required_ruby_version = ">=2.1.0"
24
+
25
+ spec.add_dependency "rest-client", "~> 2.0"
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "fakeweb", "~> 1.3.0"
30
+ spec.add_development_dependency "pry"
31
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pdftable-api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Edgar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.13'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: 'Pdftable.client provides two methods: remaining_pages and convert'
98
+ email:
99
+ - zorro.ej@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - lib/pdftable.rb
114
+ - lib/pdftable/client.rb
115
+ - lib/pdftable/configuration.rb
116
+ - lib/pdftable/connection.rb
117
+ - lib/pdftable/version.rb
118
+ - pdftable-api.gemspec
119
+ homepage: https://github.com/ej2015/pdftable-api.git
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.1.0
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.6.14
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: A simple client for PDFTable API
143
+ test_files: []