roughly-platform 0.1.1
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/.dir-locals.el +1 -0
- data/.standard.yml +3 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +9 -0
- data/README.md +41 -0
- data/Rakefile +23 -0
- data/Steepfile +9 -0
- data/lib/roughly-platform.rb +1 -0
- data/lib/roughly_platform/platform_resolver.rb +30 -0
- data/lib/roughly_platform/user_profile_path.rb +50 -0
- data/lib/roughly_platform/version.rb +5 -0
- data/lib/roughly_platform.rb +26 -0
- data/sig/os.rbs +33 -0
- data/sig/roughly_platform/platform_resolver.rbs +16 -0
- data/sig/roughly_platform/user_profile_path.rbs +32 -0
- data/sig/roughly_platform/version.rbs +3 -0
- data/sig/roughly_platform.rbs +14 -0
- data/sorbet/config +9 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7809066a4c2213a02f17094ec348316709ab25a996bde60efa304d562366b8ac
|
4
|
+
data.tar.gz: 37058c6a6c2aea3a27ba60e41db4e2bc29a715954f65721a8b2bfdb212846047
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9f66e6e47b2a4793eb04f499457a2315bd783004f2f28ef9bf25fa338735a63ecf49b0e7b0feac2c0977fe3cbdd1365929a2f5740994484254b3ef5d482a106
|
7
|
+
data.tar.gz: 5bfd466daaf818689ffc63cc2f6bfd39c50d14c9a62eca1d98bedcac5ce3bcf546d1b4fc90e73089f605e667515a1fc8e88bcf2305fcbd5a0ffda14b61dc635f
|
data/.dir-locals.el
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
;((ruby-mode . ((lsp-enabled-clients . (steep-ls)))))
|
data/.standard.yml
ADDED
data/CHANGELOG.md
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
Copyright 2025 wtnabe
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
4
|
+
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
6
|
+
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
|
9
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# RoughlyPlatform
|
2
|
+
|
3
|
+
roughly platform resolver and more.
|
4
|
+
|
5
|
+
This gem can some how identify linux, windows and macos. And provide something that uses them.
|
6
|
+
|
7
|
+
It provides the path to user's profile now.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle add roughly-platform
|
15
|
+
```
|
16
|
+
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install roughly-platform
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "roughly-platform"
|
27
|
+
|
28
|
+
RoughlyPlatform::PlatformResolver.new.resolve # => :linux
|
29
|
+
RoughlyPlatform.os # => :macos
|
30
|
+
RoughlyPlatform.profile_path # => $HOME/Library/Application Support
|
31
|
+
```
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
36
|
+
|
37
|
+
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).
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wtnabe/roughly-platform.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "minitest/test_task"
|
5
|
+
require "standard/rake"
|
6
|
+
|
7
|
+
Minitest::TestTask.create(:spec) do |t|
|
8
|
+
t.libs << "spec"
|
9
|
+
t.libs << "lib"
|
10
|
+
t.test_globs = ["spec/**/*_spec.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.1")
|
14
|
+
require "logger"
|
15
|
+
require "steep/rake_task"
|
16
|
+
Steep::RakeTask.new do |t|
|
17
|
+
t.check.severity_level = :hint
|
18
|
+
end
|
19
|
+
else
|
20
|
+
task :steep do; end # rubocop: disable Standard/BlockSingleLineBraces
|
21
|
+
end
|
22
|
+
|
23
|
+
task default: %i[standard spec steep]
|
data/Steepfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "roughly_platform"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "os"
|
2
|
+
|
3
|
+
module RoughlyPlatform
|
4
|
+
#
|
5
|
+
# @attr [singleton(OS)] os OS gem itself
|
6
|
+
#
|
7
|
+
class PlatformResolver
|
8
|
+
#
|
9
|
+
# @param [singleton(OS)] os
|
10
|
+
#
|
11
|
+
def initialize(os: OS)
|
12
|
+
@os = os
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# @return [:linux | :windows | :macos | :unknown]
|
17
|
+
#
|
18
|
+
def resolve
|
19
|
+
case @os
|
20
|
+
when :linux?.to_proc then :linux
|
21
|
+
when :freebsd?.to_proc then :linux
|
22
|
+
when :windows?.to_proc then :windows
|
23
|
+
when :cygwin?.to_proc then :windows
|
24
|
+
when :mac?.to_proc then :macos
|
25
|
+
else
|
26
|
+
:unknown
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module RoughlyPlatform
|
2
|
+
class Error < StandardError; end
|
3
|
+
|
4
|
+
#
|
5
|
+
# @attr_reader [String] linux
|
6
|
+
# @attr_reader [String] windows
|
7
|
+
# @attr_reader [String] macos
|
8
|
+
#
|
9
|
+
class Paths
|
10
|
+
#
|
11
|
+
# @param [String] linux
|
12
|
+
# @param [String] windows
|
13
|
+
# @param [String] macos
|
14
|
+
#
|
15
|
+
def initialize(linux:, windows:, macos:)
|
16
|
+
@linux = linux
|
17
|
+
@windows = windows
|
18
|
+
@macos = macos
|
19
|
+
end
|
20
|
+
attr_reader :linux, :windows, :macos
|
21
|
+
end
|
22
|
+
|
23
|
+
class UserProfilePath
|
24
|
+
def initialize(resolver:)
|
25
|
+
@resolver = resolver
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# @param [String] home
|
30
|
+
# @param [String] appdata
|
31
|
+
# @return Paths
|
32
|
+
#
|
33
|
+
def pair(home: ENV["HOME"], appdata: ENV["APPDATA"])
|
34
|
+
Paths.new(
|
35
|
+
linux: File.join(home.to_s, ".config"),
|
36
|
+
windows: appdata.to_s,
|
37
|
+
macos: File.join(home.to_s, "Library/Application Support")
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
#
|
42
|
+
# @param [String] home
|
43
|
+
# @param [String] appdata
|
44
|
+
# @return [String]
|
45
|
+
#
|
46
|
+
def resolve(home: ENV["HOME"], appdata: ENV["APPDATA"])
|
47
|
+
pair(home: home, appdata: appdata).send(@resolver.resolve)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "os"
|
4
|
+
require_relative "roughly_platform/version"
|
5
|
+
require_relative "roughly_platform/platform_resolver"
|
6
|
+
require_relative "roughly_platform/user_profile_path"
|
7
|
+
|
8
|
+
module RoughlyPlatform
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
#
|
12
|
+
# @return [:linux | :windows | :macos]
|
13
|
+
#
|
14
|
+
def os
|
15
|
+
PlatformResolver.new.resolve
|
16
|
+
end
|
17
|
+
module_function :os
|
18
|
+
|
19
|
+
#
|
20
|
+
# @return [String]
|
21
|
+
#
|
22
|
+
def profile_path
|
23
|
+
UserProfilePath.new(resolver: PlatformResolver.new).resolve
|
24
|
+
end
|
25
|
+
module_function :profile_path
|
26
|
+
end
|
data/sig/os.rbs
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# TypeProf 0.30.1
|
2
|
+
|
3
|
+
# vendor/ruby/3.3.0/gems/os-1.1.4/lib/os.rb
|
4
|
+
class OS
|
5
|
+
def config: -> untyped
|
6
|
+
def self.config: -> Hash[String, String]
|
7
|
+
def self.windows?: -> bool?
|
8
|
+
def self.posix?: -> bool?
|
9
|
+
def self.linux?: -> bool
|
10
|
+
def self.freebsd?: -> bool
|
11
|
+
def self.iron_ruby?: -> bool?
|
12
|
+
def self.bits: -> Integer?
|
13
|
+
def self.java?: -> bool?
|
14
|
+
def self.ruby_bin: -> String?
|
15
|
+
def self.mac?: -> bool?
|
16
|
+
def self.osx?: -> bool?
|
17
|
+
def self.x?: -> bool?
|
18
|
+
def self.rss_bytes: -> Integer
|
19
|
+
class Underlying
|
20
|
+
def self.bsd?: -> bool?
|
21
|
+
def self.windows?: -> bool
|
22
|
+
def self.linux?: -> bool
|
23
|
+
def self.docker?: -> bool?
|
24
|
+
end
|
25
|
+
def self.cygwin?: -> bool?
|
26
|
+
def self.dev_null: -> String?
|
27
|
+
def self.report: -> untyped
|
28
|
+
def self.cpu_count: -> Integer
|
29
|
+
def self.open_file_command: -> String
|
30
|
+
def self.app_config_path: (untyped) -> String
|
31
|
+
def self.parse_os_release: -> Hash[Symbol, String]
|
32
|
+
def self.hwprefs_available?: -> bool
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RoughlyPlatform
|
2
|
+
class PlatformResolver
|
3
|
+
@os: singleton(OS)
|
4
|
+
|
5
|
+
#
|
6
|
+
# @param [singleton(OS)] os
|
7
|
+
#
|
8
|
+
def initialize: (?os: singleton(OS)) -> void
|
9
|
+
|
10
|
+
#
|
11
|
+
# @return [:linux | :windows | :macos | :unknown]
|
12
|
+
#
|
13
|
+
def resolve: () -> (:linux | :windows | :macos | :unknown)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RoughlyPlatform
|
2
|
+
class Paths
|
3
|
+
attr_reader linux: String
|
4
|
+
attr_reader windows: String
|
5
|
+
attr_reader macos: String
|
6
|
+
|
7
|
+
def initialize: (linux: String, windows: String, macos: String) -> void
|
8
|
+
end
|
9
|
+
|
10
|
+
class UserProfilePath
|
11
|
+
@resolver: PlatformResolver
|
12
|
+
|
13
|
+
#
|
14
|
+
# @param [PlatformResolver] resolver
|
15
|
+
#
|
16
|
+
def initialize: (resolver: PlatformResolver) -> void
|
17
|
+
|
18
|
+
#
|
19
|
+
# @param [String] home
|
20
|
+
# @param [String] appdata
|
21
|
+
# @return [Paths]
|
22
|
+
#
|
23
|
+
def pair: (?home: String|nil, ?appdata: String|nil) -> Paths
|
24
|
+
|
25
|
+
#
|
26
|
+
# @param [String] home
|
27
|
+
# @param [String] appdata
|
28
|
+
# @return [String]
|
29
|
+
#
|
30
|
+
def resolve: (?home: String|nil, ?appdata: String|nil) -> String
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RoughlyPlatform
|
2
|
+
class Error < StandardError
|
3
|
+
end
|
4
|
+
|
5
|
+
#
|
6
|
+
# @return [:linux | :windows | :macos | :unknown]
|
7
|
+
#
|
8
|
+
def self?.os: () -> (:linux | :windows | :macos | :unknown)
|
9
|
+
|
10
|
+
#
|
11
|
+
# @return [String]
|
12
|
+
#
|
13
|
+
def self?.profile_path: () -> String
|
14
|
+
end
|
data/sorbet/config
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: roughly-platform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- wtnabe
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: os
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: " now available user profile path."
|
28
|
+
email:
|
29
|
+
- 18510+wtnabe@users.noreply.github.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".dir-locals.el"
|
35
|
+
- ".standard.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- Steepfile
|
41
|
+
- lib/roughly-platform.rb
|
42
|
+
- lib/roughly_platform.rb
|
43
|
+
- lib/roughly_platform/platform_resolver.rb
|
44
|
+
- lib/roughly_platform/user_profile_path.rb
|
45
|
+
- lib/roughly_platform/version.rb
|
46
|
+
- sig/os.rbs
|
47
|
+
- sig/roughly_platform.rbs
|
48
|
+
- sig/roughly_platform/platform_resolver.rbs
|
49
|
+
- sig/roughly_platform/user_profile_path.rbs
|
50
|
+
- sig/roughly_platform/version.rbs
|
51
|
+
- sorbet/config
|
52
|
+
homepage: https://github.com/wtnabe/roughly-platform
|
53
|
+
licenses: []
|
54
|
+
metadata:
|
55
|
+
allowed_push_host: https://rubygems.org
|
56
|
+
homepage_uri: https://github.com/wtnabe/roughly-platform
|
57
|
+
source_code_uri: https://github.com/wtnabe/roughly-platform
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '2.7'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubygems_version: 3.5.22
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: roughly platform resolver and more.
|
77
|
+
test_files: []
|