agile_utils 0.0.2
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 +21 -0
- data/.travis.yml +5 -0
- data/.yardopts +2 -0
- data/Gemfile +4 -0
- data/Guardfile +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +21 -0
- data/agile_utils.gemspec +35 -0
- data/bin/agile_utils +6 -0
- data/lib/agile_utils/cli.rb +42 -0
- data/lib/agile_utils/constant.rb +3 -0
- data/lib/agile_utils/core_ext/hash/hash.rb +56 -0
- data/lib/agile_utils/core_ext/kernel/reporting.rb +36 -0
- data/lib/agile_utils/file_util.rb +88 -0
- data/lib/agile_utils/helper.rb +67 -0
- data/lib/agile_utils/logger.rb +10 -0
- data/lib/agile_utils/version.rb +3 -0
- data/lib/agile_utils.rb +8 -0
- data/test/fixtures/inputs/demo1.xxx.rb +1 -0
- data/test/fixtures/inputs/demo2.xxx.rb +1 -0
- data/test/fixtures/outputs/demo1.xhtml +0 -0
- data/test/fixtures/outputs/demo2.xhtml +0 -0
- data/test/lib/agile_utils/test_file_util.rb +31 -0
- data/test/lib/agile_utils/test_helper.rb +8 -0
- data/test/test_helper.rb +7 -0
- metadata +248 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5de88d08a9fd5dd56b5f5d298f31dabde3d1b3e5
|
4
|
+
data.tar.gz: ca2dd47e768dd91e83d764c9184472c0595bcd7b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6579bd5fb55b4bdb34ab47ed1ed3314869c127c9e0841c6b9f3f580cc1838c06145ca3fe044e0d8963dd7c7b8ff32977410646bb0f9ef3251bcc63fd1be4f74c
|
7
|
+
data.tar.gz: 27ee5bc58fb421785aae755b382f6508a9457f10bc306dbf2a90b18d07124e32df761c530889d8d1230b7bf9fa6ce52a0161cd94dfaa5efbdb2d23f88e0d4804
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
|
19
|
+
# Custom ignore files
|
20
|
+
TODOs.md
|
21
|
+
output.tar.gz
|
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
guard 'minitest' do
|
4
|
+
|
5
|
+
# with Minitest::Unit
|
6
|
+
watch(%r|^test/(.*)\/?test_(.*)\.rb|)
|
7
|
+
watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
8
|
+
watch(%r|^test/test_helper\.rb|) { "test" }
|
9
|
+
|
10
|
+
# with Minitest::Spec
|
11
|
+
# watch(%r|^spec/(.*)_spec\.rb|)
|
12
|
+
# watch(%r|^lib/(.*)([^/]+)\.rb|) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
13
|
+
# watch(%r|^spec/spec_helper\.rb|) { "spec" }
|
14
|
+
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Burin Choomnuan
|
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,67 @@
|
|
1
|
+
## agile_utils
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/agile_utils)
|
4
|
+
|
5
|
+
My collection of ruby library that I have implemented and plan to use them in more
|
6
|
+
than one project. To promote the code re-use I move them all to this gem
|
7
|
+
DRY (Don't repeat yourself). I hope you will find some of them useful for you
|
8
|
+
interesting project.
|
9
|
+
|
10
|
+
### Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'agile_utils'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install agile_utils
|
23
|
+
|
24
|
+
### Usage
|
25
|
+
|
26
|
+
#### Use as CLI
|
27
|
+
|
28
|
+
As this gem is intended to be used as a library in other application.
|
29
|
+
I plan to show the available command/api when the command is executed.
|
30
|
+
|
31
|
+
```sh
|
32
|
+
# to show list of all available api
|
33
|
+
agile_utils
|
34
|
+
```
|
35
|
+
|
36
|
+
#### Use as standard ruby library
|
37
|
+
|
38
|
+
This is how the gem supposed to be used.
|
39
|
+
|
40
|
+
```rb
|
41
|
+
# Require and include the library in your code
|
42
|
+
require 'agile_utils'
|
43
|
+
include AgileUtils
|
44
|
+
|
45
|
+
# call appropriate methods you like to use
|
46
|
+
AgileUtils::FileUtil.find()
|
47
|
+
AgileUtils::FileUtils.tar_gzip_files()
|
48
|
+
AgileUtils::FileUtils.delete()
|
49
|
+
```
|
50
|
+
|
51
|
+
### Limitation/Known Issues
|
52
|
+
|
53
|
+
- Will be listed here if any
|
54
|
+
|
55
|
+
### Changelogs
|
56
|
+
|
57
|
+
#### 0.0.2
|
58
|
+
|
59
|
+
- First initial release
|
60
|
+
|
61
|
+
### Contributing
|
62
|
+
|
63
|
+
1. Fork it ( http://github.com/agilecreativity/agile_utils/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
project_name = 'agile_utils'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
t.libs << "lib/#{project_name}"
|
8
|
+
t.test_files = FileList["test/lib/#{project_name}/test_*.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :test
|
13
|
+
|
14
|
+
task :pry do
|
15
|
+
require 'pry'
|
16
|
+
require 'awesome_print'
|
17
|
+
require_relative 'lib/agile_utils'
|
18
|
+
include AgileUtils
|
19
|
+
ARGV.clear
|
20
|
+
Pry.start
|
21
|
+
end
|
data/agile_utils.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'agile_utils/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "agile_utils"
|
8
|
+
spec.version = AgileUtils::VERSION
|
9
|
+
spec.authors = ["Burin Choomnuan"]
|
10
|
+
spec.email = ["agilecreativity@gmail.com"]
|
11
|
+
spec.summary = %q{Collection of my library that can be re-used across project}
|
12
|
+
spec.description = %q{My collection of library that I have used that can be shared across multiple project.}
|
13
|
+
spec.homepage = "https://github.com/agilecreativity/agile_utils"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_runtime_dependency "thor", "~> 0.18"
|
22
|
+
spec.add_runtime_dependency "minitar", "~> 0.5.4"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "awesome_print", "~> 1.2"
|
27
|
+
spec.add_development_dependency "minitest-spec-context", "~> 0.0.3"
|
28
|
+
spec.add_development_dependency "guard-minitest", "~> 2.2"
|
29
|
+
spec.add_development_dependency "minitest", "~> 4.2"
|
30
|
+
spec.add_development_dependency "guard", "~> 2.6"
|
31
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
32
|
+
spec.add_development_dependency "gem-ctags", "~> 1.0"
|
33
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
34
|
+
|
35
|
+
end
|
data/bin/agile_utils
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require_relative '../agile_utils'
|
3
|
+
module AgileUtils
|
4
|
+
class CLI < Thor
|
5
|
+
desc 'main', 'Main entry point'
|
6
|
+
# method_option :commit,
|
7
|
+
# aliases: "-c",
|
8
|
+
# desc: "commit your changes",
|
9
|
+
# default: false
|
10
|
+
def main
|
11
|
+
opts = options.symbolize_keys
|
12
|
+
|
13
|
+
if opts[:version]
|
14
|
+
puts "You are using #{AgileUtils::PROJECT_NAME} version #{AgileUtils::VERSION}"
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "FYI: your options #{opts}"
|
19
|
+
execute(opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "usage", "Display help screen"
|
23
|
+
def usage
|
24
|
+
# Add your usage here (How to automate this task from Vim?)
|
25
|
+
# try running :r !./bin/agile_utils help run
|
26
|
+
puts <<-EOS
|
27
|
+
Add your usage here.
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
|
31
|
+
default_task :usage
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# @param [Hash<Symbol, Object>] options the options argument
|
36
|
+
def execute(options = {})
|
37
|
+
# TODO: just a place holder for now!
|
38
|
+
puts "FYI: execute with options: #{options}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
# File activesupport/lib/active_support/core_ext/hash/keys.rb
|
4
|
+
#
|
5
|
+
# hash = { name: 'Rob', age: '28' }
|
6
|
+
# hash.transform_keys{ |key| key.to_s.upcase }
|
7
|
+
# => { "NAME" => "Rob", "AGE" => "28" }
|
8
|
+
def transform_keys
|
9
|
+
result = {}
|
10
|
+
each_key do |key|
|
11
|
+
result[yield(key)] = self[key]
|
12
|
+
end
|
13
|
+
result
|
14
|
+
end
|
15
|
+
|
16
|
+
def transform_keys!(&block)
|
17
|
+
keys.each do |key|
|
18
|
+
value = delete(key)
|
19
|
+
self[yield(key)] = value.is_a?(Hash) ? value.transform_keys!(&block) : value
|
20
|
+
end
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
# hash = { 'name' => 'Rob', 'age' => '28' }
|
25
|
+
# hash.symbolize_keys
|
26
|
+
# => { name: "Rob", age: "28" }
|
27
|
+
def symbolize_keys
|
28
|
+
transform_keys{ |key| key.to_sym rescue key }
|
29
|
+
end
|
30
|
+
|
31
|
+
# File activesupport/lib/active_support/core_ext/hash/keys.rb, line 135
|
32
|
+
def symbolize_keys!
|
33
|
+
transform_keys!{ |key| key.to_sym rescue key }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Merges the caller into +other_hash+. For example,
|
37
|
+
#
|
38
|
+
# options = options.reverse_merge(size: 25, velocity: 10)
|
39
|
+
#
|
40
|
+
# is equivalent to
|
41
|
+
#
|
42
|
+
# options = { size: 25, velocity: 10 }.merge(options)
|
43
|
+
#
|
44
|
+
# This is particularly useful for initializing an options hash
|
45
|
+
# with default values.
|
46
|
+
def reverse_merge(other_hash)
|
47
|
+
other_hash.merge(self)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Destructive +reverse_merge+.
|
51
|
+
def reverse_merge!(other_hash)
|
52
|
+
# right wins if there is no left
|
53
|
+
merge!(other_hash) { |key,left,right| left }
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
module Kernel
|
3
|
+
# From: 'activesupport-4.1.0/lib/active_support/core_ext/kernel/reporting.rb
|
4
|
+
#
|
5
|
+
# Captures the given stream and returns it:
|
6
|
+
#
|
7
|
+
# stream = capture(:stdout) { puts 'notice' }
|
8
|
+
# stream # => "notice\n"
|
9
|
+
#
|
10
|
+
# stream = capture(:stderr) { warn 'error' }
|
11
|
+
# stream # => "error\n"
|
12
|
+
#
|
13
|
+
# even for subprocesses:
|
14
|
+
#
|
15
|
+
# stream = capture(:stdout) { system('echo notice') }
|
16
|
+
# stream # => "notice\n"
|
17
|
+
#
|
18
|
+
# stream = capture(:stderr) { system('echo error 1>&2') }
|
19
|
+
# stream # => "error\n"
|
20
|
+
def capture(stream)
|
21
|
+
stream = stream.to_s
|
22
|
+
captured_stream = Tempfile.new(stream)
|
23
|
+
stream_io = eval("$#{stream}")
|
24
|
+
origin_stream = stream_io.dup
|
25
|
+
stream_io.reopen(captured_stream)
|
26
|
+
|
27
|
+
yield
|
28
|
+
|
29
|
+
stream_io.rewind
|
30
|
+
return captured_stream.read
|
31
|
+
ensure
|
32
|
+
captured_stream.close
|
33
|
+
captured_stream.unlink
|
34
|
+
stream_io.reopen(origin_stream)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'zlib'
|
2
|
+
require 'stringio'
|
3
|
+
require 'find'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'archive/tar/minitar'
|
6
|
+
|
7
|
+
module AgileUtils
|
8
|
+
include Archive::Tar
|
9
|
+
include Archive::Tar::Minitar
|
10
|
+
|
11
|
+
module FileUtil
|
12
|
+
|
13
|
+
class << self
|
14
|
+
# @todo use me when you have to!
|
15
|
+
CustomError = Class.new(StandardError)
|
16
|
+
|
17
|
+
# Find list of files based on certain extension
|
18
|
+
#
|
19
|
+
# @param [String] base_dir the starting directory
|
20
|
+
# @param [String] extension the file extension to search for
|
21
|
+
#
|
22
|
+
# @return [Array<String>] list of matching files or empty list
|
23
|
+
def find(base_dir, extension = 'xhtml')
|
24
|
+
file_paths = []
|
25
|
+
Find.find(base_dir) do |path|
|
26
|
+
file_paths << path if path =~ /.*\.#{extension}$/
|
27
|
+
end
|
28
|
+
file_paths || []
|
29
|
+
end
|
30
|
+
|
31
|
+
# Tar and gzip list of files
|
32
|
+
#
|
33
|
+
# @param [Array<String>] files list of input files
|
34
|
+
# @param [String] output the output file in .tar.gz format
|
35
|
+
def tar_gzip_files(files, output = 'output.tar.gz')
|
36
|
+
begin
|
37
|
+
sgz = Zlib::GzipWriter.new(File.open(output, 'wb'))
|
38
|
+
tar = Minitar::Output.new(sgz)
|
39
|
+
files.each do |file|
|
40
|
+
Minitar.pack_file(file, tar)
|
41
|
+
end
|
42
|
+
ensure
|
43
|
+
# Closes both tar and sgz.
|
44
|
+
tar.close unless tar.nil?
|
45
|
+
tar = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Delete the files from the given list
|
50
|
+
def delete(files)
|
51
|
+
# Note: should we remove the files and be done with it?
|
52
|
+
files.each do |file|
|
53
|
+
#puts "FYI: about to delete file #{file}"
|
54
|
+
# Note: name clash!!!
|
55
|
+
FileUtils.rm_rf(file)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Add suffix to each extensions
|
60
|
+
#
|
61
|
+
# @param [Array<String>] extensions list of extension
|
62
|
+
# @param [String] suffix the suffix string
|
63
|
+
#
|
64
|
+
# @return [Array<String>] new list with the suffix added to each element
|
65
|
+
def add_suffix(extensions = %w(rb pdf), suffix)
|
66
|
+
extensions.map {|e| "#{e}.#{suffix}" }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Time the operation before and after the operation for tuning purpose
|
70
|
+
def time
|
71
|
+
beg_time = Time.now
|
72
|
+
yield
|
73
|
+
end_time = Time.now
|
74
|
+
end_time - beg_time
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
if __FILE__ == $0
|
81
|
+
include AgileUtils
|
82
|
+
files = AgileUtils::FileUtil.find('test/fixtures/inputs', 'rb')
|
83
|
+
puts files
|
84
|
+
AgileUtils::FileUtil.tar_gzip_files files, 'test/fixtures/output.tar.gz'
|
85
|
+
puts "Your output is at #{File.absolute_path('test/fixtures/output.tar.gz')}"
|
86
|
+
puts "About to delete your file.."
|
87
|
+
#AgileUtils::FileUtil.delete ['test/fixtures/output.tar.gz']
|
88
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'open3'
|
2
|
+
module AgileUtils
|
3
|
+
module Helper
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# Wrapper function to call the 'popen3' and return the result
|
7
|
+
#
|
8
|
+
# @param [Array<String>] commands list of command
|
9
|
+
# @return [String] result of the command as the string
|
10
|
+
def shell(commands = [])
|
11
|
+
stdin, stderr, status = Open3.capture3(commands.join(" "))
|
12
|
+
raise "Problem processing #{input_file}" unless status.success?
|
13
|
+
stdin
|
14
|
+
end
|
15
|
+
|
16
|
+
def is_osx?
|
17
|
+
uname && uname.strip.downcase == "darwin"
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_linux?
|
21
|
+
uname && uname.strip.downcase == "linux"
|
22
|
+
end
|
23
|
+
|
24
|
+
def uname
|
25
|
+
shell(%w(uname))
|
26
|
+
end
|
27
|
+
|
28
|
+
# Extract "key1: value1\nkey2: value 2" to
|
29
|
+
# hash of { "key1" => "value1", "key2" => "value 2" }
|
30
|
+
#
|
31
|
+
# @param [String] input the input string from the unix command
|
32
|
+
# @return [Hash<Symbol,String>] result hash extracted from the command
|
33
|
+
# @todo re-implement the code and look for specific list of keys and quit
|
34
|
+
# as fast as we get the specific list of keys
|
35
|
+
def string_to_hash(input)
|
36
|
+
hash = {}
|
37
|
+
input.split("\n").each do |i|
|
38
|
+
#TODO: code smell?
|
39
|
+
item = i.split(":") if is_linux?
|
40
|
+
item = i.split("=") if is_osx?
|
41
|
+
next if item.empty? || item.size != 2
|
42
|
+
hash[item[0].strip] = item[1].strip
|
43
|
+
end
|
44
|
+
hash
|
45
|
+
end
|
46
|
+
|
47
|
+
# Add suffix to each item in the list
|
48
|
+
#
|
49
|
+
# @param [Array<String>] list the input list
|
50
|
+
# @param [String] suffix the suffix string
|
51
|
+
# @return [Array<String.] list of input where each element is append with
|
52
|
+
# suffix string
|
53
|
+
def add_suffix(list = [], suffix)
|
54
|
+
list.map { |e| "#{e}.#{suffix}" }
|
55
|
+
end
|
56
|
+
|
57
|
+
# For tuning the operation
|
58
|
+
def time
|
59
|
+
beg_time = Time.now
|
60
|
+
yield
|
61
|
+
end_time = Time.now
|
62
|
+
end_time - beg_time
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/agile_utils.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require_relative './agile_utils/core_ext/hash/hash'
|
2
|
+
require_relative './agile_utils/core_ext/kernel/reporting'
|
3
|
+
require_relative './agile_utils/constant'
|
4
|
+
require_relative './agile_utils/version'
|
5
|
+
require_relative './agile_utils/logger'
|
6
|
+
require_relative './agile_utils/cli'
|
7
|
+
require_relative './agile_utils/helper'
|
8
|
+
require_relative './agile_utils/file_util'
|
@@ -0,0 +1 @@
|
|
1
|
+
# file: demo1.xxx.rb
|
@@ -0,0 +1 @@
|
|
1
|
+
# file: demo2.xxx.rb
|
File without changes
|
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe AgileUtils do
|
5
|
+
|
6
|
+
context '#tar_gzip_files' do
|
7
|
+
before do
|
8
|
+
FileUtils.rm_rf("test/fixtures/output.tar.gz")
|
9
|
+
@files = AgileUtils::FileUtil.find("test/fixtures/outputs", 'xhtml')
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
FileUtils.rm_rf("test/fixtures/output.tar.gz")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'compresses list of files' do
|
17
|
+
refute File.exists?("test/fixtures/output.tar.gz"), "Output file must not exist"
|
18
|
+
AgileUtils::FileUtil.tar_gzip_files(@files, "test/fixtures/output.tar.gz")
|
19
|
+
assert File.exists?("test/fixtures/output.tar.gz"), "Output file must be generated"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# context '#delete' do
|
24
|
+
# it 'removes the files' do
|
25
|
+
# @files.wont_be_empty
|
26
|
+
# AgileUtils::FileUtil.delete(@files)
|
27
|
+
#
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: agile_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Burin Choomnuan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-18 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.18'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.18'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitar
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: awesome_print
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-spec-context
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.3
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.0.3
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-minitest
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.2'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.2'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: minitest
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.2'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.6'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.6'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: gem-ctags
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.8'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.8'
|
181
|
+
description: My collection of library that I have used that can be shared across multiple
|
182
|
+
project.
|
183
|
+
email:
|
184
|
+
- agilecreativity@gmail.com
|
185
|
+
executables:
|
186
|
+
- agile_utils
|
187
|
+
extensions: []
|
188
|
+
extra_rdoc_files: []
|
189
|
+
files:
|
190
|
+
- ".gitignore"
|
191
|
+
- ".travis.yml"
|
192
|
+
- ".yardopts"
|
193
|
+
- Gemfile
|
194
|
+
- Guardfile
|
195
|
+
- LICENSE.txt
|
196
|
+
- README.md
|
197
|
+
- Rakefile
|
198
|
+
- agile_utils.gemspec
|
199
|
+
- bin/agile_utils
|
200
|
+
- lib/agile_utils.rb
|
201
|
+
- lib/agile_utils/cli.rb
|
202
|
+
- lib/agile_utils/constant.rb
|
203
|
+
- lib/agile_utils/core_ext/hash/hash.rb
|
204
|
+
- lib/agile_utils/core_ext/kernel/reporting.rb
|
205
|
+
- lib/agile_utils/file_util.rb
|
206
|
+
- lib/agile_utils/helper.rb
|
207
|
+
- lib/agile_utils/logger.rb
|
208
|
+
- lib/agile_utils/version.rb
|
209
|
+
- test/fixtures/inputs/demo1.xxx.rb
|
210
|
+
- test/fixtures/inputs/demo2.xxx.rb
|
211
|
+
- test/fixtures/outputs/demo1.xhtml
|
212
|
+
- test/fixtures/outputs/demo2.xhtml
|
213
|
+
- test/lib/agile_utils/test_file_util.rb
|
214
|
+
- test/lib/agile_utils/test_helper.rb
|
215
|
+
- test/test_helper.rb
|
216
|
+
homepage: https://github.com/agilecreativity/agile_utils
|
217
|
+
licenses:
|
218
|
+
- MIT
|
219
|
+
metadata: {}
|
220
|
+
post_install_message:
|
221
|
+
rdoc_options: []
|
222
|
+
require_paths:
|
223
|
+
- lib
|
224
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
+
requirements:
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: '0'
|
229
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
+
requirements:
|
231
|
+
- - ">="
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0'
|
234
|
+
requirements: []
|
235
|
+
rubyforge_project:
|
236
|
+
rubygems_version: 2.2.2
|
237
|
+
signing_key:
|
238
|
+
specification_version: 4
|
239
|
+
summary: Collection of my library that can be re-used across project
|
240
|
+
test_files:
|
241
|
+
- test/fixtures/inputs/demo1.xxx.rb
|
242
|
+
- test/fixtures/inputs/demo2.xxx.rb
|
243
|
+
- test/fixtures/outputs/demo1.xhtml
|
244
|
+
- test/fixtures/outputs/demo2.xhtml
|
245
|
+
- test/lib/agile_utils/test_file_util.rb
|
246
|
+
- test/lib/agile_utils/test_helper.rb
|
247
|
+
- test/test_helper.rb
|
248
|
+
has_rdoc:
|