ichigeki 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 +18 -0
- data/.travis.yml +8 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +7 -0
- data/ichigeki.gemspec +23 -0
- data/lib/ichigeki/hissatsu.rb +129 -0
- data/lib/ichigeki/version.rb +3 -0
- data/lib/ichigeki.rb +21 -0
- data/sample.rb +11 -0
- data/spec/ichigek_spec.rb +36 -0
- data/spec/sample.rb +8 -0
- data/spec/sample_require_hissatsu.rb +6 -0
- data/spec/spec_helper.rb +7 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e46a757da3954c239c997b36cb60a9b711555d87
|
4
|
+
data.tar.gz: 15346471ef7eb62ac2178c9629b30035120b03ba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22ae7ae8574a1bc64ad14e02cc94b34360c5f892e4f0093684f2dee4fd6753c71c4e477b08589137c143d5dbfe15c9ed287eb05d6f24f9a8ac8443efe62607b2
|
7
|
+
data.tar.gz: 591725fa18e8819279b15846d04106b381ac35b67150a4bd03ee214756813bcd5782d3a8486112f9ce416c4f8794bef2b0c1125a78b371a7cd5efa6762a16b32
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Konboi
|
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,72 @@
|
|
1
|
+
# Ichigeki
|
2
|
+
[](https://travis-ci.org/Konboi/ichigeki)
|
3
|
+
|
4
|
+
This is [Script::Ichigeki](https://github.com/Songmu/p5-Script-Ichigeki) ruby version.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'ichigeki'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install ichigeki
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# sample.rb
|
24
|
+
require 'ichigeki'
|
25
|
+
|
26
|
+
Ichigeki.hissatsu(
|
27
|
+
dialog_message: "殺っちゃう??",
|
28
|
+
log_file_postfix: '.ichigeki',
|
29
|
+
exec_date: "2014-03-08"
|
30
|
+
)
|
31
|
+
|
32
|
+
puts 'ichigeki: グハッ'
|
33
|
+
|
34
|
+
```
|
35
|
+
|
36
|
+
```
|
37
|
+
bundle exec ruby sample.rb
|
38
|
+
```
|
39
|
+
|
40
|
+
```
|
41
|
+
less .sample.rb.ichigeki
|
42
|
+
```
|
43
|
+
|
44
|
+
```
|
45
|
+
# This log file is generated by ichigeki.start: 2014-03-08 12:00:00 +0900
|
46
|
+
---
|
47
|
+
ichigeki: グハッ
|
48
|
+
|
49
|
+
---
|
50
|
+
end: 2014-03-08 12:00:01 +0900
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
We can set optons when require this gem like this
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require("ichigeki").hissatsu(
|
58
|
+
log_file_postfix: '.hoge'
|
59
|
+
exec_date: "2014-03-10"
|
60
|
+
)
|
61
|
+
|
62
|
+
```
|
63
|
+
|
64
|
+
thanks [p-r](https://github.com/Konboi/ichigeki/pull/1)
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it ( http://github.com/<my-github-username>/ichigeki/fork )
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/ichigeki.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ichigeki/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ichigeki"
|
8
|
+
spec.version = Ichigeki::VERSION
|
9
|
+
spec.authors = ["Konboi"]
|
10
|
+
spec.email = ["ryosuke.yabuki@gmail.com"]
|
11
|
+
spec.summary = %q{ichigeki}
|
12
|
+
spec.description = %q{ichigeki}
|
13
|
+
spec.homepage = ""
|
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_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
module Ichigeki
|
5
|
+
class Hissatsu
|
6
|
+
attr_reader :exec_date, :confirm_dialog, :log_file_postfix,
|
7
|
+
:script, :in_compilation, :dialog_message
|
8
|
+
|
9
|
+
attr_accessor :is_running
|
10
|
+
|
11
|
+
def initialize(init_properties = {})
|
12
|
+
init_properties = {
|
13
|
+
exec_date: Time.now.strftime("%Y-%m-%d"),
|
14
|
+
confirm_dialog: true,
|
15
|
+
log_file_postfix: '.log',
|
16
|
+
dialog_message: "Do you really execute %s",
|
17
|
+
in_compilation: 1,
|
18
|
+
script: $0,
|
19
|
+
is_running: nil,
|
20
|
+
}.merge(init_properties)
|
21
|
+
|
22
|
+
@exec_date = init_properties[:exec_date]
|
23
|
+
@confirm_dialog = init_properties[:confirm_dialog]
|
24
|
+
@in_compilation = init_properties[:in_compilation]
|
25
|
+
@log_file_postfix = init_properties[:log_file_postfix]
|
26
|
+
@script = init_properties[:script]
|
27
|
+
@dialog_message = init_properties[:dialog_message]
|
28
|
+
@is_running = init_properties[:is_running]
|
29
|
+
end
|
30
|
+
|
31
|
+
def execute
|
32
|
+
now = Time.now;
|
33
|
+
today = now.strftime("%Y-%m-%d")
|
34
|
+
|
35
|
+
exiting("exec_date: #{exec_date} is not today") unless exec_date == today
|
36
|
+
|
37
|
+
exiting(sprintf("Can't execue! Execution log file [%s] already exists!", log_file)) if File.exists?(log_file)
|
38
|
+
|
39
|
+
if confirm_dialog
|
40
|
+
printf(dialog_message + ' [y/n] [n] ', script.to_s)
|
41
|
+
answer = gets.chomp
|
42
|
+
exiting 'canceled.' unless answer == 'y'
|
43
|
+
end
|
44
|
+
|
45
|
+
STDOUT.flush
|
46
|
+
STDERR.flush
|
47
|
+
|
48
|
+
log(["\n",
|
49
|
+
'# This log file is generated by ichigeki.',
|
50
|
+
"start: #{now.to_s} \n",
|
51
|
+
'---',''].join
|
52
|
+
)
|
53
|
+
|
54
|
+
self.is_running = 1
|
55
|
+
|
56
|
+
$stdout = std_out
|
57
|
+
$stderr = std_err
|
58
|
+
|
59
|
+
done
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def twin_out(f)
|
65
|
+
out = Object.new
|
66
|
+
out.instance_eval{@ofile=f}
|
67
|
+
class <<out
|
68
|
+
def write(str)
|
69
|
+
STDOUT.write(str)
|
70
|
+
@ofile.write(str)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
return out
|
75
|
+
end
|
76
|
+
|
77
|
+
def twin_err(f)
|
78
|
+
err = Object.new
|
79
|
+
err.instance_eval{@ofile=f}
|
80
|
+
class <<err
|
81
|
+
def write(str)
|
82
|
+
STDERR.write(str)
|
83
|
+
@ofile.write(str)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
return err
|
88
|
+
end
|
89
|
+
|
90
|
+
def std_out
|
91
|
+
twin_out(log_fh)
|
92
|
+
end
|
93
|
+
|
94
|
+
def std_err
|
95
|
+
twin_err(log_fh)
|
96
|
+
end
|
97
|
+
|
98
|
+
def log_fh
|
99
|
+
open(log_file, "a")
|
100
|
+
end
|
101
|
+
|
102
|
+
def exiting(msg = '')
|
103
|
+
msg = msg + "\n"
|
104
|
+
if (self.in_compilation)
|
105
|
+
puts msg
|
106
|
+
exit 1
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def log_file
|
111
|
+
"#{File.dirname(script)}/.#{script.to_s}#{log_file_postfix}"
|
112
|
+
end
|
113
|
+
|
114
|
+
def log(msg)
|
115
|
+
log_fh.puts msg
|
116
|
+
end
|
117
|
+
|
118
|
+
def done
|
119
|
+
if is_running
|
120
|
+
now = Time.now.to_s
|
121
|
+
log(["\n",
|
122
|
+
'','---',"\n",
|
123
|
+
"end: #{now}\n", ''].join)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
data/lib/ichigeki.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "ichigeki/version"
|
2
|
+
require "ichigeki/hissatsu"
|
3
|
+
|
4
|
+
module Ichigeki
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def hissatsu(args={})
|
8
|
+
ichigeki = Ichigeki::Hissatsu.new(args)
|
9
|
+
ichigeki.execute
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
#Kernel#.require returns bool value
|
14
|
+
#so, bool value override and we can `require('ichigeki').hissatsu`
|
15
|
+
[true, false].each do |bool|
|
16
|
+
class << bool
|
17
|
+
def hissatsu(args={})
|
18
|
+
Ichigeki.hissatsu args
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/sample.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rspec'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'pathname'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
describe Ichigeki, "hissatsu" do
|
8
|
+
sample_rbs = %w(sample.rb sample_require_hissatsu.rb)
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
sample_rbs.each do |rb|
|
12
|
+
File.delete("./spec/#{rb}.log") if File.exist?("./spec/#{rb}.log")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "can execute test script" do
|
17
|
+
it "First time can doing" do
|
18
|
+
sample_rbs.each do |rb|
|
19
|
+
stdout = `ruby ./spec/#{rb}`
|
20
|
+
expect(stdout).to eq("ichigekiiiii\n")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "can't execute twice this script" do
|
26
|
+
it "First time can doing" do
|
27
|
+
sample_rbs.each do |rb|
|
28
|
+
`ruby ./spec/#{rb}`
|
29
|
+
stdout = `ruby ./spec/#{rb}`
|
30
|
+
expect(stdout).to eq("Can\'t execue! Execution log file [./spec/../spec/#{rb}.log] already exists!\n")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
data/spec/sample.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ichigeki
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Konboi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ichigeki
|
42
|
+
email:
|
43
|
+
- ryosuke.yabuki@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- ichigeki.gemspec
|
55
|
+
- lib/ichigeki.rb
|
56
|
+
- lib/ichigeki/hissatsu.rb
|
57
|
+
- lib/ichigeki/version.rb
|
58
|
+
- sample.rb
|
59
|
+
- spec/ichigek_spec.rb
|
60
|
+
- spec/sample.rb
|
61
|
+
- spec/sample_require_hissatsu.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
homepage: ''
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.2.0
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: ichigeki
|
87
|
+
test_files:
|
88
|
+
- spec/ichigek_spec.rb
|
89
|
+
- spec/sample.rb
|
90
|
+
- spec/sample_require_hissatsu.rb
|
91
|
+
- spec/spec_helper.rb
|