keg 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 +36 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.ja.md +93 -0
- data/README.md +96 -0
- data/Rakefile +17 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/circle.yml +25 -0
- data/exe/keg +4 -0
- data/keg.gemspec +33 -0
- data/lib/keg.rb +7 -0
- data/lib/keg/cli.rb +61 -0
- data/lib/keg/configuration.rb +38 -0
- data/lib/keg/core.rb +52 -0
- data/lib/keg/formatter.rb +14 -0
- data/lib/keg/formatter/json.rb +12 -0
- data/lib/keg/formatter/yaml.rb +12 -0
- data/lib/keg/version.rb +3 -0
- metadata +152 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cc1cd308865efe2ea6deaf708d724c77e4d1e00e
|
4
|
+
data.tar.gz: de83c134e62047822433b3c23969eb46513742c5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ebe78e1d9b88851fad6a7f0b57b276af5892d9b364605cab667e8c4b58ac9a6d4ee6fa76a453ca098e7cf4c55e994ccb8a77c228e4d5a3fd4afc3b89232cc6b1
|
7
|
+
data.tar.gz: 2607fa3a5f15ff0257fa6cf86899871e25b05d2ff2853c86c5d7c27e651cefa14b30760c31a688b867d612c149fd039e4ea099fd479c40e6e413a40c122c47d9
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
Gemfile.lock
|
32
|
+
.ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 yuta-muramoto
|
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.ja.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
Keg [](https://circleci.com/gh/bm-sms/keg)
|
2
|
+
====
|
3
|
+
|
4
|
+
Kegは、データ管理支援を目的としたCLIツールです。
|
5
|
+
|
6
|
+
## Description
|
7
|
+
Kegが扱うデータは、[TOML](https://github.com/toml-lang/toml)と呼ばれる可読性の高い形式で書かれたデータです。
|
8
|
+
Kegは、ローカルに構築されたデータベース内にあるTOML形式のファイルを読み込み、利用しやすい形式にして出力します。
|
9
|
+
事前に、利用したいTOMLファイルがあるリポジトリをローカルのデータベース(`$HOME/.keg/databases`)にクローンする必要があります。
|
10
|
+
|
11
|
+
## VS. [glean](https://github.com/glean/glean)
|
12
|
+
gleanは特定のリモートリポジトリからローカルにキャッシュを構築しているのに対し、Kegはローカルに構築されたデータベースを主として扱います。
|
13
|
+
そのため、リポジトリの更新があった場合は手動でpullする必要があります。しかし、ローカルのデータを扱うため高速に動作します。
|
14
|
+
|
15
|
+
## Requirements
|
16
|
+
Ruby 2.0 以上
|
17
|
+
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Gemfileに追加する場合 :
|
22
|
+
|
23
|
+
```sh
|
24
|
+
gem 'keg'
|
25
|
+
```
|
26
|
+
|
27
|
+
手動でインストールする場合 :
|
28
|
+
|
29
|
+
```sh
|
30
|
+
$ gem install keg
|
31
|
+
```
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
### 準備:
|
35
|
+
TOMLファイルの作成 :
|
36
|
+
|
37
|
+
```toml
|
38
|
+
# example.toml
|
39
|
+
name = 'example'
|
40
|
+
email = 'example@example.com'
|
41
|
+
```
|
42
|
+
|
43
|
+
作成したTOMLファイルをgitにpush :
|
44
|
+
|
45
|
+
```sh
|
46
|
+
$ git add example.toml
|
47
|
+
$ git commit -m 'add keg example'
|
48
|
+
$ git push origin master
|
49
|
+
```
|
50
|
+
|
51
|
+
データベースの構築 :
|
52
|
+
|
53
|
+
```sh
|
54
|
+
$ mkdir -p $HOME/.keg/databases
|
55
|
+
$ cd $HOME/.keg/databases
|
56
|
+
$ git clone <your_repo> example_database
|
57
|
+
```
|
58
|
+
|
59
|
+
### デモ:
|
60
|
+
|
61
|
+
ローカルのパス(`$HOME/.keg/databases`)内のデータベース群からデータベースを選択する :
|
62
|
+
|
63
|
+
```sh
|
64
|
+
$ keg switch example_database #=> switch database `example_database`
|
65
|
+
```
|
66
|
+
|
67
|
+
データベース内にある要求されたTOMLファイルをフォーマットして表示する :
|
68
|
+
|
69
|
+
```sh
|
70
|
+
$ keg show example # show $HOME/.keg/databases/example_database/example.toml
|
71
|
+
$ keg show --format=json example # show in json format
|
72
|
+
$ keg show --format=yaml example # show in yaml format
|
73
|
+
```
|
74
|
+
|
75
|
+
現在選択されているデータベース名を表示する :
|
76
|
+
|
77
|
+
```sh
|
78
|
+
$ keg current #=> example_database
|
79
|
+
```
|
80
|
+
|
81
|
+
選択されているデータベース内の全てのTOMLファイルをフォーマットして表示する :
|
82
|
+
|
83
|
+
```sh
|
84
|
+
$ keg show_all # show all TOML in example_database
|
85
|
+
$ keg show_all --format=json # show all in json format
|
86
|
+
$ keg show_all --format=yaml # show all in yaml format
|
87
|
+
```
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
バグレポートとプルリクエストは https://github.com/bm-sms/keg にてお待ちしております。コントリビューアは [Contributor Covenant](http://contributor-covenant.org) に殉ずる事をお願いします。
|
91
|
+
|
92
|
+
## License
|
93
|
+
このgemは[MIT License](http://opensource.org/licenses/MIT)の元で利用可能です。
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
Keg [](https://circleci.com/gh/bm-sms/keg)
|
2
|
+
====
|
3
|
+
|
4
|
+
Keg is CLI tool that supports a data management.
|
5
|
+
|
6
|
+
## Description
|
7
|
+
Keg use the data formatted by [TOML](https://github.com/toml-lang/toml) which is language that easy to read.
|
8
|
+
Keg read a TOML file from the local database and outputs its useful format.
|
9
|
+
You need to clone the repository has the TOML file in the local database (`$HOME/.keg/databases`) in advance.
|
10
|
+
|
11
|
+
## VS. [glean](https://github.com/glean/glean)
|
12
|
+
glean constructs a cache in local from a specific remote repository. In contrast, Keg mainly works with the database was constructed in local. Therefore, you need to pull manually when the repository has updated. However, it run at high speed by using the data in local.
|
13
|
+
|
14
|
+
## Requirements
|
15
|
+
Ruby 2.0 higher
|
16
|
+
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```sh
|
23
|
+
gem 'keg'
|
24
|
+
```
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
```sh
|
29
|
+
$ gem install keg
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
### Preparations:
|
34
|
+
Makes a TOML file:
|
35
|
+
|
36
|
+
```toml
|
37
|
+
# example.toml
|
38
|
+
name = 'example'
|
39
|
+
email = 'example@example.com'
|
40
|
+
```
|
41
|
+
|
42
|
+
Push this TOML file to git:
|
43
|
+
|
44
|
+
```sh
|
45
|
+
$ git add example.toml
|
46
|
+
$ git commit -m 'add example'
|
47
|
+
$ git push origin master
|
48
|
+
```
|
49
|
+
|
50
|
+
Constructs databases:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
$ mkdir -p $HOME/.keg/databases
|
54
|
+
$ cd $HOME/.keg/databases
|
55
|
+
$ git clone <your_repo> example_database
|
56
|
+
```
|
57
|
+
|
58
|
+
### Demo:
|
59
|
+
|
60
|
+
Select a database from databases in local (`$HOME/.keg/databases`):
|
61
|
+
|
62
|
+
```sh
|
63
|
+
$ keg switch example_database #=> switch database `example_database`
|
64
|
+
```
|
65
|
+
|
66
|
+
Format and show the TOML file which is requested in the database:
|
67
|
+
|
68
|
+
```sh
|
69
|
+
$ keg show example # show $HOME/.keg/databases/example_database/example.toml
|
70
|
+
$ keg show --format=json example # show in json format
|
71
|
+
$ keg show --format=yaml example # show in yaml format
|
72
|
+
```
|
73
|
+
|
74
|
+
Show the current database:
|
75
|
+
|
76
|
+
```sh
|
77
|
+
$ keg current #=> example_database
|
78
|
+
```
|
79
|
+
|
80
|
+
Format and show all TOML files in the database:
|
81
|
+
|
82
|
+
```sh
|
83
|
+
$ keg show_all # show all TOML file in example_database
|
84
|
+
$ keg show_all --format=json # show all in json format
|
85
|
+
$ keg show_all --format=yaml # show all in yaml format
|
86
|
+
```
|
87
|
+
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/bm-sms/keg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
92
|
+
|
93
|
+
|
94
|
+
## License
|
95
|
+
|
96
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
|
+
end
|
9
|
+
|
10
|
+
task :test_init do
|
11
|
+
sh "mkdir -p $HOME/.keg/databases/glean-daimon-lunch"
|
12
|
+
sh "git clone git@github.com:bm-sms/glean-daimon-lunch.git $HOME/.keg/databases/glean-daimon-lunch"
|
13
|
+
sh "mkdir -p $HOME/.keg/databases/example"
|
14
|
+
sh "git clone git@github.com:yuta-muramoto/TomlTest.git $HOME/.keg/databases/example"
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "keg"
|
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
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
machine:
|
2
|
+
timezone: Asia/Tokyo
|
3
|
+
ruby:
|
4
|
+
version: '2.2.3'
|
5
|
+
post:
|
6
|
+
- sudo service mysql stop
|
7
|
+
- sudo service postgresql stop
|
8
|
+
|
9
|
+
dependencies:
|
10
|
+
override:
|
11
|
+
- rake test_init
|
12
|
+
test:
|
13
|
+
override:
|
14
|
+
- rvm use 2.2.3
|
15
|
+
- gem install bundler -v 1.11.2
|
16
|
+
- bundle _1.11.2_ install
|
17
|
+
- rake test
|
18
|
+
- rvm use 2.1.7
|
19
|
+
- gem install bundler -v 1.11.2
|
20
|
+
- bundle _1.11.2_ install
|
21
|
+
- rake test
|
22
|
+
- rvm use 2.0.0
|
23
|
+
- gem install bundler -v 1.11.2
|
24
|
+
- bundle _1.11.2_ install
|
25
|
+
- rake test
|
data/exe/keg
ADDED
data/keg.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'keg/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "keg"
|
8
|
+
spec.version = Keg::VERSION
|
9
|
+
spec.authors = ["yuta-muramoto"]
|
10
|
+
spec.email = ["s1513114@u.tsukuba.ac.jp"]
|
11
|
+
|
12
|
+
spec.summary = %q{This is CLI tool that supports a data management.}
|
13
|
+
spec.description = <<-EOF
|
14
|
+
Keg use the data formatted by TOML which is language that easy to read.
|
15
|
+
Keg read a TOML file from the local database and outputs its useful format.
|
16
|
+
You need to clone the repository has the TOML file in the local database (`$HOME/.keg/databases`) in advance.
|
17
|
+
EOF
|
18
|
+
spec.homepage = "https://github.com/bm-sms/keg"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "thor"
|
27
|
+
spec.add_dependency "toml-rb"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "minitest"
|
32
|
+
spec.add_development_dependency "minitest-reporters"
|
33
|
+
end
|
data/lib/keg.rb
ADDED
data/lib/keg/cli.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'keg'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Keg
|
5
|
+
class CLI < Thor
|
6
|
+
DEFAULT_FORMAT = 'json'
|
7
|
+
def self.exit_on_failure?; true end
|
8
|
+
|
9
|
+
def initialize(*args)
|
10
|
+
super
|
11
|
+
@database = Core.new(ENV["HOME"])
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "switch <database>", "Database switch to <database>."
|
15
|
+
def switch(name)
|
16
|
+
begin
|
17
|
+
@database.switch name
|
18
|
+
rescue => e
|
19
|
+
raise Thor::InvocationError.new(e)
|
20
|
+
end
|
21
|
+
puts "Switch dataBase `#{name}`."
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "show <file>", "output contents from <file> formatted by json or yaml."
|
25
|
+
method_option "format", desc: "json, yaml", default: DEFAULT_FORMAT
|
26
|
+
def show(filename)
|
27
|
+
begin
|
28
|
+
content = @database.select(filename)
|
29
|
+
formatter = Formatter.create(options[:format])
|
30
|
+
rescue => e
|
31
|
+
raise Thor::InvocationError.new(e)
|
32
|
+
end
|
33
|
+
|
34
|
+
puts formatter.format(content)
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "current", "show a current database."
|
38
|
+
def current
|
39
|
+
begin
|
40
|
+
puts @database.current
|
41
|
+
rescue => e
|
42
|
+
raise Thor::InvocationError.new(e.message)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "show_all", "output all contents from current database."
|
47
|
+
method_option "format", desc: "json, yaml", default: DEFAULT_FORMAT
|
48
|
+
def show_all
|
49
|
+
begin
|
50
|
+
contents = @database.select_all
|
51
|
+
formatter = Formatter.create(options[:format])
|
52
|
+
rescue => e
|
53
|
+
raise Thor::InvocationError.new(e)
|
54
|
+
end
|
55
|
+
|
56
|
+
contents.each do |content|
|
57
|
+
puts formatter.format(content)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'keg'
|
2
|
+
|
3
|
+
module Keg
|
4
|
+
class Configuration
|
5
|
+
def initialize(root)
|
6
|
+
@root = root
|
7
|
+
end
|
8
|
+
|
9
|
+
def save(name)
|
10
|
+
config = { 'database' => name }
|
11
|
+
File.write(config_path, config.to_yaml)
|
12
|
+
end
|
13
|
+
|
14
|
+
def load
|
15
|
+
begin
|
16
|
+
@config = YAML.load_file(config_path)
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
save ''
|
19
|
+
end
|
20
|
+
unless database_does_set?
|
21
|
+
raise 'Error: Database does not set. You should set a database.'
|
22
|
+
end
|
23
|
+
|
24
|
+
@config['database']
|
25
|
+
end
|
26
|
+
|
27
|
+
def config_path
|
28
|
+
File.join(@root, '.keg', 'config.yml')
|
29
|
+
end
|
30
|
+
|
31
|
+
def database_does_set?
|
32
|
+
return false unless @config
|
33
|
+
return false if @config['database'].nil?
|
34
|
+
return false if @config['database'].empty?
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/keg/core.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'keg'
|
2
|
+
require 'toml'
|
3
|
+
|
4
|
+
module Keg
|
5
|
+
class Core
|
6
|
+
def initialize(root)
|
7
|
+
@root = root
|
8
|
+
@configuration = Configuration.new(root)
|
9
|
+
end
|
10
|
+
|
11
|
+
def switch(name)
|
12
|
+
path = File.join(databases_path, name)
|
13
|
+
if !Dir.exists?(path) || name.empty?
|
14
|
+
raise "Error: No such directory `#{name}`. Please enter a exist database."
|
15
|
+
end
|
16
|
+
|
17
|
+
@configuration.save name
|
18
|
+
end
|
19
|
+
|
20
|
+
def select(filename)
|
21
|
+
unless Dir.exists?(current_path)
|
22
|
+
raise "Current database is unknown directory `#{current}`. Please set a exist database."
|
23
|
+
end
|
24
|
+
|
25
|
+
path = File.join(current_path, filename+'.toml')
|
26
|
+
TOML.load_file(path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def current
|
30
|
+
@current = @configuration.load if @current.nil?
|
31
|
+
@current
|
32
|
+
end
|
33
|
+
|
34
|
+
def select_all
|
35
|
+
unless Dir.exists?(current_path)
|
36
|
+
raise "Current database is unknown directory `#{current}`. Please set a exist database."
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir.glob("#{current_path}/**/*.toml").map do |path|
|
40
|
+
TOML.load_file(path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def current_path
|
45
|
+
File.join(databases_path, current)
|
46
|
+
end
|
47
|
+
|
48
|
+
def databases_path
|
49
|
+
File.join(@root, '.keg', 'databases')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'keg'
|
2
|
+
|
3
|
+
module Keg
|
4
|
+
class Formatter
|
5
|
+
def self.create(format)
|
6
|
+
begin
|
7
|
+
formatter = const_get(format.capitalize)
|
8
|
+
rescue
|
9
|
+
raise "Error: Unavailable format `#{format}`. Please enter a available format `JSON` or `YAML`."
|
10
|
+
end
|
11
|
+
formatter.new
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/keg/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: keg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yuta-muramoto
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-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'
|
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: toml-rb
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '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'
|
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.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
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
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest-reporters
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: |2
|
98
|
+
Keg use the data formatted by TOML which is language that easy to read.
|
99
|
+
Keg read a TOML file from the local database and outputs its useful format.
|
100
|
+
You need to clone the repository has the TOML file in the local database (`$HOME/.keg/databases`) in advance.
|
101
|
+
email:
|
102
|
+
- s1513114@u.tsukuba.ac.jp
|
103
|
+
executables:
|
104
|
+
- keg
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".gitignore"
|
109
|
+
- CODE_OF_CONDUCT.md
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.ja.md
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- circle.yml
|
118
|
+
- exe/keg
|
119
|
+
- keg.gemspec
|
120
|
+
- lib/keg.rb
|
121
|
+
- lib/keg/cli.rb
|
122
|
+
- lib/keg/configuration.rb
|
123
|
+
- lib/keg/core.rb
|
124
|
+
- lib/keg/formatter.rb
|
125
|
+
- lib/keg/formatter/json.rb
|
126
|
+
- lib/keg/formatter/yaml.rb
|
127
|
+
- lib/keg/version.rb
|
128
|
+
homepage: https://github.com/bm-sms/keg
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.4.5.1
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: This is CLI tool that supports a data management.
|
152
|
+
test_files: []
|