ccu 0.0.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/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +7 -0
- data/bin/ccu +69 -0
- data/ccu.gemspec +28 -0
- data/spec/_spec.rb +10 -0
- data/spec/files/_spec.rb +1 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 430ad16d67956b3ced25df10beafd05811837a06
|
4
|
+
data.tar.gz: e7498ff8d25d71a1280197792ccd9dc24934c904
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1a804a3240c3f2322f7aa10c644655113fc2bdafd3163f56793ce429795f2f556b4a26b1ca489425d7c380980c5610592bfd5c9691bcec1b4bed145763228e2
|
7
|
+
data.tar.gz: 77ad0a37031b6bde88486e7bd04a8875d033055203f50311b413d9fb6858612a999311bd94cc2cc0d77eb5e79cf4394a5ae4c2caf226f523c03c636e9e14d51c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Victor Maslov aka Nakilon
|
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,31 @@
|
|
1
|
+
# Ccu
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ccu'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ccu
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/ccu/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/ccu
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# TODO: to use http://ruby-doc.org/stdlib-2.2.0/libdoc/optparse/rdoc/OptionParser.html
|
4
|
+
|
5
|
+
Signal.trap("INT"){ puts "\n"; exit 0 }
|
6
|
+
|
7
|
+
puts "\tNakitools usage: naki file" || exit if !ARGV.first || ARGV.first[/^-*(v(ersion)?|h(elp)?)$/]
|
8
|
+
|
9
|
+
expect = lambda do |command, expectation|
|
10
|
+
output = `#{command}`
|
11
|
+
return if expectation.is_a?(String) ? output == expectation : output[expectation]
|
12
|
+
puts "WARNING: %p was expected to print %p, not %p" % [command, expectation, output]
|
13
|
+
puts "\tProbably your installed software is incompatible with current version of Nakitools."
|
14
|
+
begin puts "\tProceed? [Y/N]" end until gets[/^\s*Y(es)?|No*\s*$/i] || puts("WUT?")
|
15
|
+
$_[/N/i] && exit
|
16
|
+
end
|
17
|
+
|
18
|
+
# ARGV.first =~ /(?<basename>.*)\.(?<extension>.+)/
|
19
|
+
filename = ARGV.first
|
20
|
+
abort "ERROR: can't run without parameters"
|
21
|
+
extension = File.extname filename
|
22
|
+
ARGV.clear
|
23
|
+
case extension.downcase
|
24
|
+
|
25
|
+
when ".zip"
|
26
|
+
puts "\tAssuming it is a ZIP archive."
|
27
|
+
expect[ "file \"#{filename}\"", "#{filename}: Zip archive data, at least v1.0 to extract\n" ]
|
28
|
+
expect[ "unzip -v", /^UnZip 5\.52 / ]
|
29
|
+
# `which unzip`; p $?.success?
|
30
|
+
puts "\tWhat would you like to do with it?"
|
31
|
+
basename = File.basename filename, extension
|
32
|
+
abort "ERROR: directory %p already exists" % basename if File.exist? basename
|
33
|
+
begin puts "\t[e] - extract to \"./%s\"" % basename end until gets == "e\n" || puts("WUT?")
|
34
|
+
# `[[ -f chat.kongregate.com.zip ]]`; $?.success?
|
35
|
+
cmd = "unzip -q \"#{filename}\" -x \"__MACOSX/*\" -d \"#{basename}\""
|
36
|
+
puts "\tPress Enter to proceed or ^C to cancel this shell command:\n\t\t#{cmd}"
|
37
|
+
gets
|
38
|
+
system cmd
|
39
|
+
system "ls -1 | grep \"^#{basename}\""
|
40
|
+
when ".gif"
|
41
|
+
puts "\tAssuming it is a GIF image."
|
42
|
+
expect[ "file \"#{filename}\"", /^#{filename}: GIF image data, version 89a, \d+ x \d+\n$/ ]
|
43
|
+
expect[ "sips --help", /^sips 10\.4\.4 / ]
|
44
|
+
puts "\tWhat would you like to do with it?"
|
45
|
+
basename = File.basename filename, extension
|
46
|
+
newname = "%s_resized%s" % [basename, extension]
|
47
|
+
# begin puts "\t[r] - resize to \"%s\"" % newname end until gets == "r\n" || puts("WUT?")
|
48
|
+
abort "ERROR: file %p already exists" % newname if File.exist? newname
|
49
|
+
begin puts \
|
50
|
+
"\t[i] - get info about image",
|
51
|
+
"\t[h] - fit to desired height",
|
52
|
+
"\t[w] - fit to desired width"
|
53
|
+
end until answer = {
|
54
|
+
"i" => "",
|
55
|
+
"h" => "Height",
|
56
|
+
"w" => "Width",
|
57
|
+
}[gets.chomp] or puts("WUT?")
|
58
|
+
cmd, safe = case answer
|
59
|
+
when "" ; ["sips -g all \"#{filename}\"", true]
|
60
|
+
when "Height", "Width" ;
|
61
|
+
begin puts "\tspecify desired #{answer} in pixels" end until gets[/^\d{1,5}$/] or puts("WUT?")
|
62
|
+
"sips --resample#{answer} #{$_.chomp} \"#{filename}\" --out \"#{newname}\""
|
63
|
+
end
|
64
|
+
puts "\tPress Enter to proceed or ^C to cancel this shell command:\n\t\t#{cmd}" #or gets unless safe
|
65
|
+
system cmd
|
66
|
+
system "sips -g all \"#{newname}\""
|
67
|
+
else
|
68
|
+
abort "idk"
|
69
|
+
end
|
data/ccu.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# lib = File.expand_path('../lib', __FILE__)
|
4
|
+
# $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
# require 'ccu/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "ccu"
|
9
|
+
spec.version = "0.0.1" # Ccu::VERSION
|
10
|
+
spec.authors = ["Victor Maslov"]
|
11
|
+
spec.email = ["nakilon@gmail.com"]
|
12
|
+
spec.summary = "Context Console Utility"
|
13
|
+
spec.description = "This is currently for Mac OS X only. Published without full tests yet, so do not expect it to work, lol. Please, let me know if it works with Ruby <2.0.0"
|
14
|
+
# spec.homepage = "http://rubygems.org/gems/ccu"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
# spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
25
|
+
|
26
|
+
spec.required_ruby_version = ">= 2.0.0"
|
27
|
+
spec.post_install_message = "Thx for install. Now type `ccu' to see basic usage help."
|
28
|
+
end
|
data/spec/_spec.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# require 'spec_helper'
|
2
|
+
|
3
|
+
describe "A" do
|
4
|
+
it "should fail if no parameters were given" do
|
5
|
+
Dir.chdir __dir__
|
6
|
+
binary = Shellwords.escape File.join(__dir__, "../bin/ccu")
|
7
|
+
`#{binary}`; process_status = $?
|
8
|
+
expect(process_status).not_to be_success
|
9
|
+
end
|
10
|
+
end
|
data/spec/files/_spec.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
abort "ERROR: #{__dir__} has to be excluded from tests!"
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ccu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Victor Maslov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
description: This is currently for Mac OS X only. Published without full tests yet,
|
56
|
+
so do not expect it to work, lol. Please, let me know if it works with Ruby <2.0.0
|
57
|
+
email:
|
58
|
+
- nakilon@gmail.com
|
59
|
+
executables:
|
60
|
+
- ccu
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- .gitignore
|
65
|
+
- .rspec
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/ccu
|
71
|
+
- ccu.gemspec
|
72
|
+
- spec/_spec.rb
|
73
|
+
- spec/files/_spec.rb
|
74
|
+
homepage:
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message: Thx for install. Now type `ccu' to see basic usage help.
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.0.0
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.0.14
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Context Console Utility
|
98
|
+
test_files:
|
99
|
+
- spec/_spec.rb
|
100
|
+
- spec/files/_spec.rb
|