tzf 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 +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Cargo.lock +1036 -0
- data/Cargo.toml +13 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +24 -0
- data/lib/tzf/ffi_ext.rb +15 -0
- data/lib/tzf/libtzf.so +0 -0
- data/lib/tzf/version.rb +5 -0
- data/lib/tzf.rb +15 -0
- data/sig/tzf_rs_rb.rbs +4 -0
- data/src/lib.rs +17 -0
- data/tzf.gemspec +38 -0
- metadata +79 -0
data/Cargo.toml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
[package]
|
2
|
+
name = "tzf"
|
3
|
+
version = "0.1.0"
|
4
|
+
edition = "2021"
|
5
|
+
|
6
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
7
|
+
|
8
|
+
[lib]
|
9
|
+
crate-type = ["cdylib"]
|
10
|
+
|
11
|
+
[dependencies]
|
12
|
+
lazy_static = "1.4.0"
|
13
|
+
tzf-rs = "0.3.0"
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in tzf.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
|
12
|
+
gem "rubocop", "~> 1.21"
|
13
|
+
gem "rubocop-rake", "~> 0.6"
|
14
|
+
gem "rubocop-rspec", "~> 2.18"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
tzf (0.1.0)
|
5
|
+
ffi (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
ffi (1.15.5)
|
13
|
+
json (2.6.3)
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.2.0.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
rainbow (3.1.1)
|
18
|
+
rake (13.0.6)
|
19
|
+
regexp_parser (2.6.1)
|
20
|
+
rexml (3.2.5)
|
21
|
+
rspec (3.12.0)
|
22
|
+
rspec-core (~> 3.12.0)
|
23
|
+
rspec-expectations (~> 3.12.0)
|
24
|
+
rspec-mocks (~> 3.12.0)
|
25
|
+
rspec-core (3.12.0)
|
26
|
+
rspec-support (~> 3.12.0)
|
27
|
+
rspec-expectations (3.12.2)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.12.0)
|
30
|
+
rspec-mocks (3.12.3)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-support (3.12.0)
|
34
|
+
rubocop (1.41.1)
|
35
|
+
json (~> 2.3)
|
36
|
+
parallel (~> 1.10)
|
37
|
+
parser (>= 3.1.2.1)
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
40
|
+
rexml (>= 3.2.5, < 4.0)
|
41
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
42
|
+
ruby-progressbar (~> 1.7)
|
43
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
44
|
+
rubocop-ast (1.24.0)
|
45
|
+
parser (>= 3.1.1.0)
|
46
|
+
rubocop-capybara (2.17.1)
|
47
|
+
rubocop (~> 1.41)
|
48
|
+
rubocop-rake (0.6.0)
|
49
|
+
rubocop (~> 1.0)
|
50
|
+
rubocop-rspec (2.18.1)
|
51
|
+
rubocop (~> 1.33)
|
52
|
+
rubocop-capybara (~> 2.17)
|
53
|
+
ruby-progressbar (1.11.0)
|
54
|
+
unicode-display_width (2.3.0)
|
55
|
+
|
56
|
+
PLATFORMS
|
57
|
+
x86_64-linux
|
58
|
+
|
59
|
+
DEPENDENCIES
|
60
|
+
rake (~> 13.0)
|
61
|
+
rspec (~> 3.0)
|
62
|
+
rubocop (~> 1.21)
|
63
|
+
rubocop-rake (~> 0.6)
|
64
|
+
rubocop-rspec (~> 2.18)
|
65
|
+
tzf!
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.4.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Kevin McCormack
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# tzf-rb
|
2
|
+
|
3
|
+
Time zone lookup using [tzf-rs](https://github.com/ringsaturn/tzf-rs).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add tzf
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install tzf
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```rb
|
18
|
+
require 'tzf'
|
19
|
+
|
20
|
+
TZF.tz_name(40.74771675713742, -73.99350390136448)
|
21
|
+
# => "America/New_York"
|
22
|
+
```
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
Requirements:
|
27
|
+
|
28
|
+
- (Rust)[https://www.rust-lang.org/learn/get-started]
|
29
|
+
- (Ruby)[https://www.ruby-lang.org]
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tzf. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/tzf/blob/main/CODE_OF_CONDUCT.md).
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Everyone interacting in the tzf project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tzf/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
desc "Build rust dependencies"
|
13
|
+
task :rust_build do
|
14
|
+
`cargo rustc --release`
|
15
|
+
`cp ./target/release/libtzf.so ./lib/tzf/`
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Clean rust dependencies"
|
19
|
+
task :rust_clean do
|
20
|
+
`cargo clean`
|
21
|
+
`rm -f ./lib/tzf/libtzf.so`
|
22
|
+
end
|
23
|
+
|
24
|
+
task default: %i[rust_build spec rubocop]
|
data/lib/tzf/ffi_ext.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ffi"
|
4
|
+
|
5
|
+
module TZF
|
6
|
+
##
|
7
|
+
# Interface to tsf-rs Rust library.
|
8
|
+
#
|
9
|
+
module RS
|
10
|
+
extend FFI::Library
|
11
|
+
|
12
|
+
ffi_lib File.expand_path("libtzf.so", __dir__)
|
13
|
+
attach_function :get_tz_name, %i[double double], :string
|
14
|
+
end
|
15
|
+
end
|
data/lib/tzf/libtzf.so
ADDED
Binary file
|
data/lib/tzf/version.rb
ADDED
data/lib/tzf.rb
ADDED
data/sig/tzf_rs_rb.rbs
ADDED
data/src/lib.rs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
use lazy_static::lazy_static;
|
2
|
+
use std::ffi::CString;
|
3
|
+
use tzf_rs::DefaultFinder;
|
4
|
+
|
5
|
+
lazy_static! {
|
6
|
+
static ref FINDER: DefaultFinder = DefaultFinder::new();
|
7
|
+
}
|
8
|
+
|
9
|
+
#[no_mangle]
|
10
|
+
pub extern fn get_tz_name(lat: f64, lng: f64) -> CString {
|
11
|
+
// let finder = DefaultFinder::new();
|
12
|
+
|
13
|
+
// Create a CString so we can read this in Ruby with FFI
|
14
|
+
let tz_name = CString::new(FINDER.get_tz_name(lng, lat));
|
15
|
+
|
16
|
+
return tz_name.unwrap();
|
17
|
+
}
|
data/tzf.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/tzf/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "tzf"
|
7
|
+
spec.version = TZF::VERSION
|
8
|
+
spec.authors = ["Kevin McCormack"]
|
9
|
+
spec.email = ["kevin@mccormack.tech"]
|
10
|
+
|
11
|
+
spec.summary = "Ruby time zone lookup interface using tzf-rs"
|
12
|
+
spec.description = "Ruby time zone lookup interface using tzf-rs."
|
13
|
+
spec.homepage = "https://github.com/HarlemSquirrel/tzf-rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/HarlemSquirrel/tzf-rb"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/HarlemSquirrel/tzf-rb/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Uncomment to register a new dependency of your gem
|
33
|
+
spec.add_dependency "ffi", "~> 1.0"
|
34
|
+
|
35
|
+
# For more information and examples about making a new gem, check out our
|
36
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
37
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tzf
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin McCormack
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffi
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
description: Ruby time zone lookup interface using tzf-rs.
|
28
|
+
email:
|
29
|
+
- kevin@mccormack.tech
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- ".rubocop.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- CODE_OF_CONDUCT.md
|
38
|
+
- Cargo.lock
|
39
|
+
- Cargo.toml
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- lib/tzf.rb
|
46
|
+
- lib/tzf/ffi_ext.rb
|
47
|
+
- lib/tzf/libtzf.so
|
48
|
+
- lib/tzf/version.rb
|
49
|
+
- sig/tzf_rs_rb.rbs
|
50
|
+
- src/lib.rs
|
51
|
+
- tzf.gemspec
|
52
|
+
homepage: https://github.com/HarlemSquirrel/tzf-rb
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/HarlemSquirrel/tzf-rb
|
57
|
+
source_code_uri: https://github.com/HarlemSquirrel/tzf-rb
|
58
|
+
changelog_uri: https://github.com/HarlemSquirrel/tzf-rb/blob/main/CHANGELOG.md
|
59
|
+
rubygems_mfa_required: 'true'
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubygems_version: 3.3.26
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: Ruby time zone lookup interface using tzf-rs
|
79
|
+
test_files: []
|