fbtiles 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 26741482264c9fba4eed922152c6730886fc2cef
4
+ data.tar.gz: 788f40357ace003f6832e998ecc8b2f8a74a2729
5
+ SHA512:
6
+ metadata.gz: 24723239226b3064d25548ebae4969ed3d7461eb4fd89ce1d2a89873e927fb2dcec8b0e933155cdfce588211dbb95f2357cb15322cd326a808a5667e78a2c990
7
+ data.tar.gz: cd4ee6c1719fdcc409abc1da693a96ac27ce634fe4908996120660c6aff0ad65519bd24323bed4e4d14ee588177d8f4f3a9eec7d4fed3f469fc49960399e988a
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-ci
2
+ repo_token: bHo0gKCb64EfN05PCL7fTtN7dzX9BWXL6
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ vendor/
2
+ .bundle/
3
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format Fuubar
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fbtiles.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Michael Pellon
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,21 @@
1
+ # FBTiles
2
+ [![Build Status](https://travis-ci.org/p3ll0n/fbtiles-ruby.png)](https://travis-ci.org/p3ll0n/fbtiles-ruby])
3
+ [![Coverage Status](https://coveralls.io/repos/p3ll0n/fbtiles-ruby/badge.png)](https://coveralls.io/r/p3ll0n/fbtiles-ruby)
4
+ [![Code Climate](https://codeclimate.com/github/p3ll0n/fbtiles-ruby.png)](https://codeclimate.com/github/p3ll0n/fbtiles-ruby)
5
+ [![Dependency Status](https://gemnasium.com/p3ll0n/fbtiles-ruby.png)](https://gemnasium.com/p3ll0n/fbtiles-ruby)
6
+
7
+ Utilities for [FBTiles](https://github.com/foreflight/fbtiles) tilesets.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'fbtiles'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install fbtiles
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = 'spec/**/*_spec.rb'
8
+ end
9
+
10
+ task default: :test
data/fbtiles.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fbtiles/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fbtiles"
8
+ spec.version = FBTiles::VERSION
9
+ spec.authors = ["Michael Pellon"]
10
+ spec.email = ["michael@p3ll0n.net"]
11
+ spec.description = %q{FBTiles utilities}
12
+ spec.summary = %q{FBTiles utilities}
13
+ spec.homepage = "https://github.com/p3ll0n/fbtiles"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_dependency (RUBY_PLATFORM == 'java' ? 'jdbc-sqlite3' : 'sqlite3')
22
+ spec.add_dependency 'sequel', '~> 4.5.0'
23
+
24
+ spec.add_development_dependency 'rake', '~> 10.1.0'
25
+ spec.add_development_dependency 'minitest', '~> 5.1.0'
26
+ spec.add_development_dependency 'coveralls', '~> 0.7.0'
27
+ end
@@ -0,0 +1,72 @@
1
+ require 'sequel'
2
+
3
+ module FBTiles
4
+ class Database
5
+
6
+ #
7
+ attr_reader :path
8
+
9
+ def initialize(path = nil)
10
+ storage_type = path ? "//#{path}" : ':memory:'
11
+
12
+ @path = path
13
+ @db = Sequel.connect("#{self.class.driver}:#{storage_type}")
14
+
15
+ create_schema!
16
+ end # def initialize
17
+
18
+ def self.driver
19
+ @driver ||= RUBY_PLATFORM == 'java' ? 'jdbc:sqlite' : 'sqlite'
20
+ end # def self.driver
21
+
22
+ def adapter
23
+ @db
24
+ end # def adapter
25
+
26
+ def insert_bounds(records)
27
+ @db[:bounds].multi_insert(records)
28
+ end # def insert_bounds
29
+
30
+ def insert_datatypes(records)
31
+ @db[:datatypes].multi_insert(records)
32
+ end # def insert_datatypes
33
+
34
+ def insert_tiles(records)
35
+ @db[:tiles].multi_insert(records)
36
+ end # def insert_tiles
37
+
38
+ def create_schema!
39
+ @db.create_table :bounds do
40
+ Integer :zoom
41
+ Integer :collared
42
+ Integer :maxX
43
+ Integer :maxY
44
+ Integer :minX
45
+ Integer :minY
46
+
47
+ primary_key [:zoom, :collared]
48
+ end
49
+
50
+ @db.create_table :datatypes do
51
+ Integer :id, :primary_key => true
52
+ Text :datatype # PNG or JPG only!
53
+
54
+ index :datatype, unique: true, name: 'datatypes_idx'
55
+ end
56
+
57
+ @db.create_table :tiles do
58
+ Integer :tilekey, :primary_key => true
59
+ Integer :zoom_level
60
+ Integer :tile_row
61
+ Integer :tile_column
62
+ Blob :tile_data
63
+ Integer :tile_datatypes_id
64
+ Blob :tile_collar_data
65
+ Integer :tile_collar_datatypes_id
66
+
67
+ index [:zoom_level, :tile_row, :tile_column], name: 'tiles_idx'
68
+ end
69
+ end # def create_schema!
70
+
71
+ end # class Database
72
+ end # module FBTiles
@@ -0,0 +1,3 @@
1
+ module FBTiles
2
+ VERSION = "0.1.0"
3
+ end # module FBTiles
@@ -0,0 +1 @@
1
+ require 'fbtiles/database'
data/lib/fbtiles.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "fbtiles/version"
2
+ require 'fbtiles/writer'
3
+
4
+ module FBTiles
5
+ end
@@ -0,0 +1,55 @@
1
+ require_relative '../spec_helper'
2
+ require 'tmpdir'
3
+
4
+ describe FBTiles do
5
+ describe 'Database' do
6
+ let(:db) do
7
+ FBTiles::Database.new
8
+ end
9
+
10
+ let(:adapter) do
11
+ db.adapter
12
+ end
13
+
14
+ describe '#create_schema!' do
15
+ it 'has bounds table' do
16
+ adapter.table_exists?(:bounds).must_equal true
17
+ end
18
+
19
+ it 'has datatypes table' do
20
+ adapter.table_exists?(:datatypes).must_equal true
21
+ end
22
+
23
+ it 'has tiles table' do
24
+ adapter.table_exists?(:tiles).must_equal true
25
+ end
26
+
27
+ it 'has datatypes index' do
28
+ expected_index = { datatypes_idx: { unique: true, columns: [:datatype] } }
29
+
30
+ adapter.indexes(:datatypes).must_equal expected_index
31
+ end
32
+
33
+ it 'has tiles index' do
34
+ expected_index = { tiles_idx: { unique: false, columns: [:zoom_level, :tile_row, :tile_column] } }
35
+
36
+ adapter.indexes(:tiles).must_equal expected_index
37
+ end
38
+
39
+ it 'has tile_zoom index' do
40
+ expected_index = { tiles_zoom_idx: { unique: false, columns: [:zoom_level] } }
41
+ end
42
+ end
43
+
44
+ it '.driver' do
45
+ FBTiles::Database.driver.must_match(/\A(jdbc\:)?sqlite\z/)
46
+ end
47
+
48
+ it '#insert_bounds' do
49
+ db.insert_bounds([{zoom: 0, collared: 0, maxX: 0, maxY: 0, minX: 0, minY: 0}])
50
+
51
+ adapter[:bounds].first(zoom: 0, collared: 0, maxX: 0, maxY: 0, minX: 0, minY: 0).wont_be_nil
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+ require 'fbtiles'
2
+ require 'sequel'
3
+ require 'minitest/autorun'
4
+ require 'coveralls'
5
+
6
+ Coveralls.wear!
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fbtiles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Pellon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jdbc-sqlite3
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ requirement: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: sequel
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 4.5.0
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: 4.5.0
39
+ prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 10.1.0
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ~>
51
+ - !ruby/object:Gem::Version
52
+ version: 10.1.0
53
+ prerelease: false
54
+ type: :development
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 5.1.0
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 5.1.0
67
+ prerelease: false
68
+ type: :development
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.0
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ~>
79
+ - !ruby/object:Gem::Version
80
+ version: 0.7.0
81
+ prerelease: false
82
+ type: :development
83
+ description: FBTiles utilities
84
+ email:
85
+ - michael@p3ll0n.net
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .coveralls.yml
91
+ - .gitignore
92
+ - .rspec
93
+ - .travis.yml
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - fbtiles.gemspec
99
+ - lib/fbtiles.rb
100
+ - lib/fbtiles/database.rb
101
+ - lib/fbtiles/version.rb
102
+ - lib/fbtiles/writer.rb
103
+ - spec/fbtiles/database_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: https://github.com/p3ll0n/fbtiles
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.1.9
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: FBTiles utilities
129
+ test_files:
130
+ - spec/fbtiles/database_spec.rb
131
+ - spec/spec_helper.rb