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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9fe0cbd4a6427e750696cc732783ef4f0fa8f2f6cc296368afe657ec074d511
4
- data.tar.gz: 2e727263ffd422f2f81e68dd5c05c8f2e6e30785f6df07f8cbf1c680137b86e7
3
+ metadata.gz: 797c13c1402ba4efdcdc6c79c5bfac707d7a9953e9c63daf22c44b537209a329
4
+ data.tar.gz: 307848456085bfdad67aaa16996ddf42013a5d265642c196aa94fed88797316a
5
5
  SHA512:
6
- metadata.gz: 0dc6b39f9183a838b70b6ac52ace2caf5304b935c417441e710a5fdf08ead5e76f0a9a145c03cdc5f1907333a367278d7cdfc652e01057d5c8d78876339e2ffd
7
- data.tar.gz: 8ccd204e2df74b2e8cbfa8097b521c736cdb2e9b1ff91f3ff239578f0a2bbc0f993d6c08ea3b5ed8c08f15701523f12f3bad4d49a0852893ef681f8e6bfbf9b9
6
+ metadata.gz: 62df5dfd595f92b848aee8c6a6dbb5e781d916160f31713d328e23227597406ccfec66be4264814fbb20d1f212f6d2a42685af98df01a0fa15b74a6a6b6b612a
7
+ data.tar.gz: 5c1b770da4f1b03fcdbaa1eb0dbd23191445b5abd2d77f57268f91cec6a46de128d93058d6726bfa973f0617c88b9ff20d38fae1872f0b5f56f9d56d4c1d49f2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fasta (0.2.4)
4
+ fasta (0.3.0)
5
5
  hanami-router (~> 1.3)
6
6
  logger (~> 1.0)
7
7
  oj (~> 3.6)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Fasta
2
- VERSION = '0.2.7'.freeze
2
+ VERSION = '0.3.1'.freeze
3
3
  end
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.2.7
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-07 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-router