fasta 0.2.7 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fasta/cli.rb +47 -1
- data/lib/fasta/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 797c13c1402ba4efdcdc6c79c5bfac707d7a9953e9c63daf22c44b537209a329
|
4
|
+
data.tar.gz: 307848456085bfdad67aaa16996ddf42013a5d265642c196aa94fed88797316a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62df5dfd595f92b848aee8c6a6dbb5e781d916160f31713d328e23227597406ccfec66be4264814fbb20d1f212f6d2a42685af98df01a0fa15b74a6a6b6b612a
|
7
|
+
data.tar.gz: 5c1b770da4f1b03fcdbaa1eb0dbd23191445b5abd2d77f57268f91cec6a46de128d93058d6726bfa973f0617c88b9ff20d38fae1872f0b5f56f9d56d4c1d49f2
|
data/Gemfile.lock
CHANGED
data/lib/fasta/cli.rb
CHANGED
@@ -2,12 +2,14 @@ require 'thor'
|
|
2
2
|
|
3
3
|
module Fasta
|
4
4
|
class Installer < Thor
|
5
|
+
DEFAULT_ACTIONS = %w[show index create delete patch put].freeze
|
6
|
+
DEFAULT_ACTION = :show
|
7
|
+
|
5
8
|
include Thor::Actions
|
6
9
|
source_root File.expand_path('../../templates', __dir__)
|
7
10
|
|
8
11
|
desc 'plz NAME', 'Unpack Project'
|
9
12
|
def plz(name)
|
10
|
-
@name = name
|
11
13
|
directory 'config', "#{name}/config"
|
12
14
|
create_file "#{name}/app/endpoints/.keep"
|
13
15
|
create_file "#{name}/log/db.log"
|
@@ -26,5 +28,49 @@ module Fasta
|
|
26
28
|
def go
|
27
29
|
exec("puma boot.ru -e #{options[:environment]} -p #{options[:port]}")
|
28
30
|
end
|
31
|
+
|
32
|
+
desc 'endpoint', 'Create new Endpoint'
|
33
|
+
def endpoint(name, *actions)
|
34
|
+
normalized_name = name.downcase
|
35
|
+
create_file "./app/endpoints/#{normalized_name}.rb",
|
36
|
+
"module #{normalized_name.capitalize}
|
37
|
+
extend Fasta::Model
|
38
|
+
end
|
39
|
+
"
|
40
|
+
create_file "./app/endpoints/#{normalized_name}/.keep"
|
41
|
+
actions.each do |action|
|
42
|
+
default_action = DEFAULT_ACTIONS.include?(action)
|
43
|
+
build_action(normalized_name, action, default_action)
|
44
|
+
end
|
45
|
+
|
46
|
+
build_migration(normalized_name)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def build_action(endpoint_name, action_name, default_action)
|
52
|
+
fasta_action = default_action ? action_name : DEFAULT_ACTION
|
53
|
+
|
54
|
+
create_file "./app/endpoints/#{endpoint_name}/#{action_name}.rb",
|
55
|
+
"module #{endpoint_name.capitalize}
|
56
|
+
class #{action_name.capitalize} < Fasta::Model::#{fasta_action.capitalize}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
"
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_migration(endpoint_name)
|
63
|
+
create_file "./db/migrations/#{Time.now.strftime('%Y%m%d%H%M%S')}_create_#{endpoint_name}s_table.rb",
|
64
|
+
"Sequel.migration do
|
65
|
+
change do
|
66
|
+
create_table(:#{endpoint_name}s) do
|
67
|
+
primary_key :id
|
68
|
+
DateTime :created_at, null: false
|
69
|
+
DateTime :updated_at, null: false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
"
|
74
|
+
end
|
29
75
|
end
|
30
76
|
end
|
data/lib/fasta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fasta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaro
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hanami-router
|