kokuban 0.1.0
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/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +101 -0
- data/Rakefile +11 -0
- data/bin/kokuban +5 -0
- data/kokuban.gemspec +27 -0
- data/lib/kokuban/cli.rb +127 -0
- data/lib/kokuban/config.rb +84 -0
- data/lib/kokuban/gem.rb +7 -0
- data/lib/kokuban/gem/version.rb +5 -0
- data/lib/kokuban/utils.rb +46 -0
- data/test/test_cli.rb +56 -0
- data/test/test_config.rb +75 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 340e16a7856d090dcc00a59fc8c7402c548212f5
|
4
|
+
data.tar.gz: e5573e1626d1fb30a78a412e0c5c169b211dcabe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 25da1c5a6d521b4a51fcda3d9eaac6473e0b932501942a5f9c7fe3fd683ba212fa91d34f6de1672754fe0e63b515eec9a2e877da9db59747450cfe941065211e
|
7
|
+
data.tar.gz: e86c0c14aee4afd8512c0b921b66af7d761d3ea5144b806bff1925b5a33c88d42dae578352b7662ddacf9b0734b3e84ec110988cc86b863f72b643796ed09eab
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 ongaeshi
|
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,101 @@
|
|
1
|
+
# rubykokuban-gem
|
2
|
+
|
3
|
+
RubyKokuban installer and executer.
|
4
|
+
|
5
|
+
### RubyKokuban?
|
6
|
+
|
7
|
+
You can write interactive applications be simplified by RubyKokuban.
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
def draw
|
11
|
+
text 'Hello, rubykokuban!', 100, 100
|
12
|
+
circle 300, 100, 50
|
13
|
+
end
|
14
|
+
```
|
15
|
+
|
16
|
+

|
17
|
+
|
18
|
+
To move the circle is very simple.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
def setup
|
22
|
+
@x = 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
@x += 1
|
27
|
+
end
|
28
|
+
|
29
|
+
def draw
|
30
|
+
text 'Hello, rubykokuban!', 100, 100
|
31
|
+
circle @x, 100, 50
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+

|
36
|
+
|
37
|
+
Sample code of [drawing](https://github.com/ongaeshi/rubykokuban-sample/blob/master/drawing.rb) and [shooting](https://github.com/ongaeshi/rubykokuban-sample/blob/master/mouse_shooting.rb).
|
38
|
+
|
39
|
+

|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
$ gem install kokuban
|
44
|
+
|
45
|
+
## Usage
|
46
|
+
|
47
|
+
### Install RubyKokuban.app
|
48
|
+
|
49
|
+
$ kokuban install --latest
|
50
|
+
|
51
|
+
### Installed?
|
52
|
+
|
53
|
+
$ kokuban list
|
54
|
+
osx (0.0.3)
|
55
|
+
|
56
|
+
### Write a code
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
def draw
|
60
|
+
text 'Hello, rubykokuban!', 100, 100
|
61
|
+
circle 300, 100, 50
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
### Execute script
|
66
|
+
|
67
|
+
$ kokuban exec hello.rb
|
68
|
+
|
69
|
+
### Very, Very, Useful Hotkey
|
70
|
+
|
71
|
+
- **Ctrl+R** (Be careful, not ⌘+R) - Reload script
|
72
|
+
|
73
|
+
## Sample Code
|
74
|
+
|
75
|
+
[rubykokuban-sample](https://github.com/ongaeshi/rubykokuban-sample)
|
76
|
+
|
77
|
+
$ git clone https://github.com/ongaeshi/rubykokuban-sample
|
78
|
+
$ cd rubykokuban-sample
|
79
|
+
$ kokuban exec mouse-shooting.rb
|
80
|
+
|
81
|
+
## Platform
|
82
|
+
|
83
|
+
- [osx](https://github.com/ongaeshi/rubykokuban-osx)
|
84
|
+
- win
|
85
|
+
- linux
|
86
|
+
- ios
|
87
|
+
- android
|
88
|
+
|
89
|
+
## Features
|
90
|
+
|
91
|
+
- It's made width mruby + openFrameworks.
|
92
|
+
- Not a library. It's an application that move independently.
|
93
|
+
- Benefits that can be expected.
|
94
|
+
- Run on multiple platforms the same code
|
95
|
+
- Run in the mobile device as well as PC
|
96
|
+
- Hide the code together in the binary file
|
97
|
+
|
98
|
+
## Special Thanks
|
99
|
+
|
100
|
+
- [mruby](https://github.com/mruby/mruby)
|
101
|
+
- [openFrameworks](http://www.openframeworks.cc)
|
data/Rakefile
ADDED
data/bin/kokuban
ADDED
data/kokuban.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kokuban/gem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kokuban"
|
8
|
+
spec.version = Kokuban::Gem::VERSION
|
9
|
+
spec.authors = ["ongaeshi"]
|
10
|
+
spec.email = ["ongaeshi0621@gmail.com"]
|
11
|
+
spec.description = %q{RubyKokuban installer and executer}
|
12
|
+
spec.summary = %q{RubyKokuban installer and executer}
|
13
|
+
spec.homepage = "https://github.com/ongaeshi/rubybasic-gem"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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_dependency 'archive-zip'
|
22
|
+
spec.add_dependency 'fetcher', "~> 0.1.0"
|
23
|
+
spec.add_dependency 'thor'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
end
|
data/lib/kokuban/cli.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'fetcher'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'kokuban/config'
|
6
|
+
require 'kokuban/gem/version'
|
7
|
+
require 'kokuban/utils'
|
8
|
+
require 'thor'
|
9
|
+
|
10
|
+
module Kokuban
|
11
|
+
class CLI < Thor
|
12
|
+
class NotFoundError < RuntimeError ; end
|
13
|
+
|
14
|
+
class_option :help, :type => :boolean, :aliases => '-h', :desc => 'Help message'
|
15
|
+
|
16
|
+
desc "install [options]", "Install RubyKokuban.app"
|
17
|
+
option :latest, :type => :boolean, :desc => 'Install latest version'
|
18
|
+
option :version, :aliases => '-v', :type => :string, :desc => 'Specify version'
|
19
|
+
def install
|
20
|
+
if options.empty?
|
21
|
+
CLI.task_help(shell, "install")
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
conf = Config.new
|
26
|
+
|
27
|
+
case conf.platform
|
28
|
+
when :osx
|
29
|
+
else
|
30
|
+
raise "Not supported platform '#{conf.platform}'"
|
31
|
+
end
|
32
|
+
|
33
|
+
logger = Logger.new(STDOUT)
|
34
|
+
logger.level = Logger::INFO
|
35
|
+
worker = Fetcher::Worker.new(logger)
|
36
|
+
|
37
|
+
platform = conf.platform.to_s
|
38
|
+
version = options[:version] || conf.install_latest_version
|
39
|
+
install_dir = conf.install_dir(version)
|
40
|
+
|
41
|
+
FileUtils.rm_rf(install_dir) if File.exist?(install_dir)
|
42
|
+
FileUtils.mkdir_p(install_dir)
|
43
|
+
|
44
|
+
url = "https://github.com/ongaeshi/rubykokuban-#{platform}/releases/download/v#{version}"
|
45
|
+
filename = "rubykokuban-#{platform}-#{version}.zip"
|
46
|
+
src = File.join(url, filename)
|
47
|
+
dst = File.join(install_dir, filename)
|
48
|
+
|
49
|
+
puts "Download #{src}"
|
50
|
+
worker.copy(src, dst)
|
51
|
+
|
52
|
+
puts "Unzip #{dst}"
|
53
|
+
system("unzip -q #{dst} -d #{File.dirname(dst)}")
|
54
|
+
# Utils.zip_extract(dst, File.dirname(dst), {no_dir: true})
|
55
|
+
FileUtils.rm_f dst
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "uninstall", "Uninstall rubykokuban from the local repository"
|
59
|
+
option :version, :aliases => '-v', :type => :string, :desc => 'Specify version'
|
60
|
+
def uninstall
|
61
|
+
conf = Config.new
|
62
|
+
|
63
|
+
if options[:version]
|
64
|
+
uninstall_dir = File.join(conf.platform_dir, options[:version])
|
65
|
+
|
66
|
+
if File.exist?(uninstall_dir)
|
67
|
+
FileUtils.rm_rf uninstall_dir
|
68
|
+
puts "Successfully uninstalled #{uninstall_dir}"
|
69
|
+
else
|
70
|
+
puts "Not found #{uninstall_dir}"
|
71
|
+
end
|
72
|
+
else
|
73
|
+
puts "Please specify version with '-v'"
|
74
|
+
puts conf.versions.map {|v| " #{v}"}.join("\n")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "exec [input_file]", "Execute rubykokuban file"
|
79
|
+
option :version, :aliases => '-v', :type => :string, :desc => 'Specify version'
|
80
|
+
def exec(*args)
|
81
|
+
if args.empty?
|
82
|
+
CLI.task_help(shell, "exec")
|
83
|
+
return
|
84
|
+
end
|
85
|
+
|
86
|
+
conf = Config.new
|
87
|
+
|
88
|
+
begin
|
89
|
+
case conf.platform
|
90
|
+
when :osx
|
91
|
+
app = File.join(conf.install_dir(options[:version]), "RubyKokuban.app")
|
92
|
+
args = args.map {|v|
|
93
|
+
raise NotFoundError, "Not found '#{v}'" unless File.exist?(v)
|
94
|
+
File.expand_path(v)
|
95
|
+
}
|
96
|
+
system("open #{app} --new --args #{args.join(" ")}")
|
97
|
+
else
|
98
|
+
raise "Not supported platform '#{conf.platform}'"
|
99
|
+
end
|
100
|
+
rescue NotFoundError => e
|
101
|
+
puts e.message
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "list", "Display installed version"
|
106
|
+
def list
|
107
|
+
conf = Config.new
|
108
|
+
puts "#{conf.platform.to_s} (#{conf.versions.join(', ')})"
|
109
|
+
end
|
110
|
+
|
111
|
+
no_tasks do
|
112
|
+
# Override method for support -h
|
113
|
+
# defined in /lib/thor/invocation.rb
|
114
|
+
def invoke_command(task, *args)
|
115
|
+
if task.name == "help" && args == [[]]
|
116
|
+
print "kokuban #{Kokuban::Gem::VERSION}\n\n"
|
117
|
+
end
|
118
|
+
|
119
|
+
if options[:help]
|
120
|
+
CLI.task_help(shell, task.name)
|
121
|
+
else
|
122
|
+
super
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'json'
|
3
|
+
require 'open-uri'
|
4
|
+
|
5
|
+
module Kokuban
|
6
|
+
class Config
|
7
|
+
def initialize(opts = {})
|
8
|
+
@opts = opts
|
9
|
+
end
|
10
|
+
|
11
|
+
def home_dir
|
12
|
+
# First setting.
|
13
|
+
# 1. Set value to @home_dir
|
14
|
+
# 2. Create directory does not exist
|
15
|
+
unless @home_dir
|
16
|
+
@home_dir = @opts[:home_dir] || File.join(home, '.kokuban')
|
17
|
+
FileUtils.mkdir_p(@home_dir) unless File.exist?(@home_dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
@home_dir
|
21
|
+
end
|
22
|
+
|
23
|
+
def app_dir
|
24
|
+
File.join(home_dir, 'app')
|
25
|
+
end
|
26
|
+
|
27
|
+
def platform
|
28
|
+
if RUBY_PLATFORM =~ /mswin(?!ce)|mingw|cygwin|bccwin/
|
29
|
+
:win
|
30
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
31
|
+
:osx
|
32
|
+
else
|
33
|
+
:etc
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def platform_dir(platform_sym = platform)
|
38
|
+
File.join(app_dir, platform_sym.to_s)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.sort_versions(versions)
|
42
|
+
vers = versions.map{|str|
|
43
|
+
{str: str, padding: str.split('.').map{|s| s.rjust(8 - s.length, '0')}.join('.') }
|
44
|
+
}.sort {|a, b|
|
45
|
+
b[:padding] <=> a[:padding]
|
46
|
+
}.map {|a|
|
47
|
+
a[:str]
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def versions
|
52
|
+
versions = Dir.glob(File.join(platform_dir, "*")).map {|path| File.basename(path)}
|
53
|
+
|
54
|
+
versions.map{|str|
|
55
|
+
{str: str, padding: str.split('.').map{|s| s.rjust(8 - s.length, '0')}.join('.') }
|
56
|
+
}.sort {|a, b|
|
57
|
+
b[:padding] <=> a[:padding]
|
58
|
+
}.map {|a|
|
59
|
+
a[:str]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def latest_dir
|
64
|
+
File.join(platform_dir, versions.first)
|
65
|
+
end
|
66
|
+
|
67
|
+
def install_dir(version = nil)
|
68
|
+
File.join(platform_dir, version || versions.first)
|
69
|
+
end
|
70
|
+
|
71
|
+
def install_latest_version
|
72
|
+
src = open("https://api.github.com/repos/ongaeshi/rubykokuban-#{platform.to_s}/tags").read # Couldn't use release API
|
73
|
+
json = JSON.parse(src)
|
74
|
+
# p json
|
75
|
+
json[0]['name'][1..-1] # 'v0.1.0' -> '0.1.0'
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
def home
|
81
|
+
File.expand_path '~'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/lib/kokuban/gem.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'archive/zip'
|
4
|
+
|
5
|
+
module Kokuban
|
6
|
+
module Utils
|
7
|
+
module_function
|
8
|
+
|
9
|
+
class ZipfileNotFound < RuntimeError ; end
|
10
|
+
|
11
|
+
def zip_extract(filename, dst_dir, options)
|
12
|
+
raise ZipfileNotFound unless File.exist?(filename)
|
13
|
+
|
14
|
+
root_list = root_entrylist(filename)
|
15
|
+
|
16
|
+
if (root_list.size == 1)
|
17
|
+
# Extract as it is
|
18
|
+
Archive::Zip.extract filename, dst_dir
|
19
|
+
return root_list[0].gsub("/", "")
|
20
|
+
else
|
21
|
+
# Extract by creating a directory
|
22
|
+
if options[:no_dir]
|
23
|
+
Archive::Zip.extract filename, dst_dir
|
24
|
+
dst_dir
|
25
|
+
else
|
26
|
+
dir = File.basename(filename).sub(/#{File.extname(filename)}$/, "")
|
27
|
+
FileUtils.mkdir_p File.join(dst_dir, dir)
|
28
|
+
Archive::Zip.extract filename, File.join(dst_dir, dir)
|
29
|
+
dir
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def root_entrylist(filename)
|
35
|
+
list = []
|
36
|
+
|
37
|
+
Archive::Zip.open(filename) do |archive|
|
38
|
+
archive.each do |entry|
|
39
|
+
list << entry.zip_path if entry.zip_path.split('/').size == 1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
list
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/test_cli.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'kokuban/cli'
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
module Kokuban
|
7
|
+
class TestCLI < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
$stdout = StringIO.new
|
10
|
+
@orig_stdout = $stdout
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
$stdout = @orig_stdout
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_no_arg
|
18
|
+
assert_match /exec.*help.*install/m, command("")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_help
|
22
|
+
assert_match /exec.*help.*install/m, command("-h")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_install_no_arg
|
26
|
+
assert_match /Usage.*install/m, command("install")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_install_latest
|
30
|
+
# puts command("install --latest")
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_exec_no_arg
|
34
|
+
assert_match /Usage.*exec/m, command("exec")
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_exec_help
|
38
|
+
assert_match /Usage.*exec/m, command("exec -h")
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_list_no_arg
|
42
|
+
command("list")
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_list_help
|
46
|
+
assert_match /Usage.*list/m, command("list -h")
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def command(arg)
|
52
|
+
CLI.start(arg.split)
|
53
|
+
$stdout.string
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/test/test_config.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'kokuban/config'
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
module Kokuban
|
6
|
+
class TestConfig < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@tmp_dir = File.join(File.dirname(__FILE__), "tmp")
|
9
|
+
FileUtils.rm_rf(@tmp_dir)
|
10
|
+
FileUtils.mkdir_p(@tmp_dir)
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
FileUtils.rm_rf(@tmp_dir)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_home_dir
|
18
|
+
conf = Config.new(home_dir: File.join(@tmp_dir, '.kokuban'))
|
19
|
+
|
20
|
+
assert_equal File.join(@tmp_dir, '.kokuban'), conf.home_dir
|
21
|
+
assert_equal File.join(@tmp_dir, '.kokuban/app'), conf.app_dir
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_platform
|
25
|
+
conf = Config.new(home_dir: File.join(@tmp_dir, '.kokuban'))
|
26
|
+
|
27
|
+
if RUBY_PLATFORM =~ /darwin/
|
28
|
+
assert_equal :osx, conf.platform
|
29
|
+
assert_equal File.join(@tmp_dir, '.kokuban/app/osx'), conf.platform_dir
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_sort_versions
|
34
|
+
assert_equal [] , Config.sort_versions([])
|
35
|
+
assert_equal "1.0.0", Config.sort_versions(["1.0.0"]).first
|
36
|
+
assert_equal "2.0.0", Config.sort_versions(["1.0.0", "2.0.0"]).first
|
37
|
+
assert_equal "10.0.0", Config.sort_versions(["1.0.0", "10.0.0"]).first
|
38
|
+
assert_equal "1.2.0", Config.sort_versions(["1.2.0", "1.1.0"]).first
|
39
|
+
assert_equal "1.2.3", Config.sort_versions(["1.2.2", "0.2.3", "1.2.3"]).first
|
40
|
+
assert_equal "1.2.3", Config.sort_versions(["1.2", "1.2.3"]).first
|
41
|
+
assert_equal "1.1.1.1", Config.sort_versions(["1", "1.1.1", "1.1.1.1", "1.1"]).first
|
42
|
+
assert_equal "1.0.101", Config.sort_versions(["1.0.11", "1.0.101"]).first
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_versions
|
46
|
+
conf = Config.new(home_dir: File.join(@tmp_dir, '.kokuban'))
|
47
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "10.1.0")
|
48
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "1.1.0")
|
49
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "1.1.2")
|
50
|
+
|
51
|
+
assert_equal ["10.1.0", "1.1.2", "1.1.0"], conf.versions
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_latest_dir
|
55
|
+
conf = Config.new(home_dir: File.join(@tmp_dir, '.kokuban'))
|
56
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "0.1.0")
|
57
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "1.1.0")
|
58
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "2.0.0")
|
59
|
+
|
60
|
+
assert_equal File.join(@tmp_dir, ".kokuban/app/#{conf.platform.to_s}/2.0.0"), conf.latest_dir
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_install_dir
|
64
|
+
conf = Config.new(home_dir: File.join(@tmp_dir, '.kokuban'))
|
65
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "0.1.0")
|
66
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "1.1.0")
|
67
|
+
FileUtils.mkdir_p File.join(conf.platform_dir, "2.0.0")
|
68
|
+
|
69
|
+
assert_equal conf.latest_dir, conf.install_dir
|
70
|
+
assert_equal conf.latest_dir, conf.install_dir(nil)
|
71
|
+
assert_equal File.join(@tmp_dir, ".kokuban/app/#{conf.platform.to_s}/1.1.0"), conf.install_dir("1.1.0")
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kokuban
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ongaeshi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: archive-zip
|
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
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fetcher
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: RubyKokuban installer and executer
|
84
|
+
email:
|
85
|
+
- ongaeshi0621@gmail.com
|
86
|
+
executables:
|
87
|
+
- kokuban
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- .gitignore
|
92
|
+
- .travis.yml
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/kokuban
|
98
|
+
- kokuban.gemspec
|
99
|
+
- lib/kokuban/cli.rb
|
100
|
+
- lib/kokuban/config.rb
|
101
|
+
- lib/kokuban/gem.rb
|
102
|
+
- lib/kokuban/gem/version.rb
|
103
|
+
- lib/kokuban/utils.rb
|
104
|
+
- test/test_cli.rb
|
105
|
+
- test/test_config.rb
|
106
|
+
homepage: https://github.com/ongaeshi/rubybasic-gem
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.0.0
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: RubyKokuban installer and executer
|
130
|
+
test_files:
|
131
|
+
- test/test_cli.rb
|
132
|
+
- test/test_config.rb
|