ruby_lepton 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +99 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +10 -0
- data/exe/ruby_lepton +51 -0
- data/lib/ruby_lepton.rb +41 -0
- data/lib/ruby_lepton/version.rb +3 -0
- data/ruby_lepton.gemspec +30 -0
- metadata +75 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 16c22a4d1df2269e16eae00cfa51c400dd174c4970bb73400ef1f253ea6dace2
|
4
|
+
data.tar.gz: 7bd5fa5aefbf44736cea4ee339aafc1d0641bd95f284e86a7edad1d973822f5a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc7ac1096353cb2fd0b7b9682ea405d7c23c18101509fe1e3a8752eb6038ad907a6cdc09468f68a286b85e839bf60b5bb4f1c2f099618cb59f8ea8cb6e2c4fbd
|
7
|
+
data.tar.gz: fe09b05438f1c0a049bd555a1db7604f7d0bbe17b00bda84635c16de4430cffb595e4cd0ee6f60d99372a27ba5f12dae1c2eb19d2ef6f03918390f6d20f0f4e3
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kirubakarann7@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby_lepton (0.1.0)
|
5
|
+
thor
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
rake (12.3.3)
|
11
|
+
thor (1.0.1)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
rake (~> 12.0)
|
18
|
+
ruby_lepton!
|
19
|
+
|
20
|
+
BUNDLED WITH
|
21
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Karan
|
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,99 @@
|
|
1
|
+
|
2
|
+
# Ruby Lepton
|
3
|
+
|
4
|
+
A Ruby wrapper library for Dropbox JPEG Lepton compression tool.
|
5
|
+
|
6
|
+
## Getting started
|
7
|
+
Install Dropbox Lepton
|
8
|
+
|
9
|
+
On macOS with Homebrew:
|
10
|
+
```
|
11
|
+
brew install lepton
|
12
|
+
```
|
13
|
+
On linux:
|
14
|
+
```
|
15
|
+
sudo apt update
|
16
|
+
sudo apt install lepton
|
17
|
+
```
|
18
|
+
**This guide assumes you have Dropbox Lepton installed.**
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Clone the repo:
|
23
|
+
|
24
|
+
```
|
25
|
+
gem install ruby_lepton
|
26
|
+
```
|
27
|
+
or include inside Gemfile
|
28
|
+
```
|
29
|
+
gem "ruby_lepton"
|
30
|
+
```
|
31
|
+
Generate binstubs:
|
32
|
+
|
33
|
+
`bundle binstubs ruby_lepton`
|
34
|
+
|
35
|
+
`ruby_lepton` executable will be generated under `bin/` folder
|
36
|
+
|
37
|
+
Install ruby lepton:
|
38
|
+
|
39
|
+
bundle exec ruby_lepton install
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
To compress a file:
|
46
|
+
```
|
47
|
+
bundle exec ruby_lepton compress [PATH] [OPTIONS]
|
48
|
+
```
|
49
|
+
To decompress a file:
|
50
|
+
```
|
51
|
+
bundle exec ruby_lepton decompress [PATH] [OPTIONS]
|
52
|
+
```
|
53
|
+
|
54
|
+
#### Options
|
55
|
+
```
|
56
|
+
bundle exec ruby_lepton compress path_to_file --verbose --binary
|
57
|
+
bundle exec ruby_lepton decompress path_to_file --no-verbose --no-binary
|
58
|
+
```
|
59
|
+
or you can pass alias for binary
|
60
|
+
```
|
61
|
+
bundle exec ruby_lepton compress path_to_file -b
|
62
|
+
bundle exec ruby_lepton decompress path_to_file -b
|
63
|
+
```
|
64
|
+
## Output
|
65
|
+
|
66
|
+
#### File generation
|
67
|
+
By default, file is generated for compression and decompression under `output/` folder
|
68
|
+
|
69
|
+
#### Binary data
|
70
|
+
Binary data will be returned instead of file by passing `--binary` option
|
71
|
+
```
|
72
|
+
bundle exec ruby_lepton compress path_to_file --binary
|
73
|
+
```
|
74
|
+
|
75
|
+
File is not generated when `--binary` option is passed
|
76
|
+
|
77
|
+
|
78
|
+
## Development
|
79
|
+
|
80
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
81
|
+
|
82
|
+
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).
|
83
|
+
|
84
|
+
## Contributing
|
85
|
+
|
86
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/binarylHq/ruby_lepton. 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/binarylHq/ruby_lepton/blob/master/CODE_OF_CONDUCT.md).
|
87
|
+
|
88
|
+
|
89
|
+
## License
|
90
|
+
|
91
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
92
|
+
|
93
|
+
## Code of Conduct
|
94
|
+
|
95
|
+
Everyone interacting in the Lepton project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/binarylHq/ruby_lepton/blob/master/CODE_OF_CONDUCT.md).
|
96
|
+
|
97
|
+
## Authors and acknowledgment
|
98
|
+
|
99
|
+
[![](https://github.com/karandocs.png?size=100)](https://github.com/karandocs)
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ruby_lepton"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/exe/ruby_lepton
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "ruby_lepton"
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
module RubyLepton
|
7
|
+
class CLI < Thor
|
8
|
+
check_unknown_options!
|
9
|
+
class_option 'verbose', :type => :boolean, :default => false
|
10
|
+
|
11
|
+
def self.exit_on_failure?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'version', 'Display Lepton version'
|
16
|
+
map %w[-v --version] => :version
|
17
|
+
def version
|
18
|
+
say "RubyLepton #{VERSION}"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "compress [path]", "compress method"
|
22
|
+
method_options %w( binary -b ) => :boolean
|
23
|
+
def compress(path)
|
24
|
+
say "Setting the options" if options.verbose?
|
25
|
+
opts = {
|
26
|
+
binary: options.binary?
|
27
|
+
}
|
28
|
+
say "Compression begins" if options.verbose?
|
29
|
+
RubyLepton::Base.compress(path, opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "decompress [path]", "decompress method"
|
33
|
+
method_options %w( binary -b ) => :boolean
|
34
|
+
def decompress(path)
|
35
|
+
say "Setting the options" if options.verbose?
|
36
|
+
opts = {
|
37
|
+
binary: options.binary?
|
38
|
+
}
|
39
|
+
say "Decompression begins" if options.verbose?
|
40
|
+
RubyLepton::Base.decompress(path, opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Install", "Install lepton"
|
44
|
+
def install
|
45
|
+
puts "Installing lepton" if options.verbose?
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
RubyLepton::CLI.start(ARGV)
|
data/lib/ruby_lepton.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "ruby_lepton/version"
|
2
|
+
require 'securerandom'
|
3
|
+
|
4
|
+
module RubyLepton
|
5
|
+
class Error < StandardError; end
|
6
|
+
class Base
|
7
|
+
class << self
|
8
|
+
def compress(source_file, options)
|
9
|
+
generated_file = "output/"+SecureRandom.hex(4)+".lep"
|
10
|
+
`lepton -memory=1024M -threadmemory=128M #{source_file} #{generated_file}`
|
11
|
+
if File.exist? generated_file
|
12
|
+
output = File.open(generated_file, 'rb')
|
13
|
+
if options[:binary].to_s == "true"
|
14
|
+
File.delete(generated_file)
|
15
|
+
puts output.read
|
16
|
+
else
|
17
|
+
puts "Compressed file saved to: " + generated_file
|
18
|
+
end
|
19
|
+
else
|
20
|
+
puts "Error in compression"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def decompress(source_file, options)
|
25
|
+
generated_file = "output/"+SecureRandom.hex(4)+".jpeg"
|
26
|
+
`lepton -memory=1024M -threadmemory=128M #{source_file} #{generated_file}`
|
27
|
+
if File.exist? generated_file
|
28
|
+
output = File.open(generated_file, 'rb')
|
29
|
+
if options[:binary].to_s == "true"
|
30
|
+
File.delete(generated_file)
|
31
|
+
puts output.read
|
32
|
+
else
|
33
|
+
puts "Decompressed file saved to: " + generated_file
|
34
|
+
end
|
35
|
+
else
|
36
|
+
puts "Error in decompression"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/ruby_lepton.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'lib/ruby_lepton/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "ruby_lepton"
|
5
|
+
spec.version = RubyLepton::VERSION
|
6
|
+
spec.authors = ["Karan"]
|
7
|
+
spec.email = ["kirubakarann7@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = 'Ruby wrapper for dropbox lepton'
|
10
|
+
spec.description = 'Ruby wrapper for dropbox lepton'
|
11
|
+
spec.homepage = "https://github.com/binarylHq/ruby_lepton"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/binarylHq/ruby_lepton"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/binarylHq/ruby_lepton"
|
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(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
spec.add_dependency "thor"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_lepton
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karan
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
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: Ruby wrapper for dropbox lepton
|
28
|
+
email:
|
29
|
+
- kirubakarann7@gmail.com
|
30
|
+
executables:
|
31
|
+
- ruby_lepton
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- CODE_OF_CONDUCT.md
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- exe/ruby_lepton
|
45
|
+
- lib/ruby_lepton.rb
|
46
|
+
- lib/ruby_lepton/version.rb
|
47
|
+
- ruby_lepton.gemspec
|
48
|
+
homepage: https://github.com/binarylHq/ruby_lepton
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata:
|
52
|
+
allowed_push_host: https://rubygems.org
|
53
|
+
homepage_uri: https://github.com/binarylHq/ruby_lepton
|
54
|
+
source_code_uri: https://github.com/binarylHq/ruby_lepton
|
55
|
+
changelog_uri: https://github.com/binarylHq/ruby_lepton
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.3.0
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
requirements: []
|
71
|
+
rubygems_version: 3.1.2
|
72
|
+
signing_key:
|
73
|
+
specification_version: 4
|
74
|
+
summary: Ruby wrapper for dropbox lepton
|
75
|
+
test_files: []
|