rubypitaya 2.8.0 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rubypitaya +26 -3
- data/lib/rubypitaya.rb +21 -0
- data/lib/rubypitaya/app-template/Gemfile +1 -1
- data/lib/rubypitaya/app-template/Gemfile.lock +2 -2
- data/lib/rubypitaya/app-template/Makefile +4 -0
- data/lib/rubypitaya/app-template/app/models/user.rb +2 -0
- data/lib/rubypitaya/app-template/bin/console +6 -0
- data/lib/rubypitaya/core/path.rb +2 -0
- data/lib/rubypitaya/core/templates/template_migration.rb.erb +13 -0
- data/lib/rubypitaya/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a6575a4e72c2225e88a02e48a02265797958d1ba5aba36d017bd576fd071c09
|
4
|
+
data.tar.gz: b502c84808a5372a6f354f860d5fd673a790851bcff700964b4da24a96c0f50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89b94ffafd69e7216559fcbbd6f55f81a431d4f357771d5ca595ad25a32fcb4e5f0427d5ec21db982ca97f65a19bd3a08b5293ec933e52bd5ac3bcd4c8f26a7e
|
7
|
+
data.tar.gz: 6701e279dc7173a1dde84870d2b3728554649a748f36eb2583d0f45b6d5d25432f19de88dc742351f85f8cd81c415fdea414170acbfabd245bcf3a6bbb26c727
|
data/bin/rubypitaya
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'rubypitaya'
|
4
4
|
|
5
|
-
COMMANDS = ['run', 'create']
|
5
|
+
COMMANDS = ['run', 'create', 'create-migration']
|
6
6
|
|
7
7
|
def main
|
8
8
|
if ARGV.size == 0 || !COMMANDS.include?(ARGV[0])
|
@@ -19,6 +19,10 @@ def main
|
|
19
19
|
if command == 'create'
|
20
20
|
command_create(ARGV)
|
21
21
|
end
|
22
|
+
|
23
|
+
if command == 'create-migration'
|
24
|
+
command_create_migration(ARGV)
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
def command_run(argv)
|
@@ -40,11 +44,25 @@ def command_create(argv)
|
|
40
44
|
puts "Project #{project_name} created!"
|
41
45
|
end
|
42
46
|
|
47
|
+
def command_create_migration(argv)
|
48
|
+
if argv.size <= 1
|
49
|
+
show_help_create_migration()
|
50
|
+
exit(-1)
|
51
|
+
end
|
52
|
+
|
53
|
+
migration_name = argv[1]
|
54
|
+
|
55
|
+
migration_file_name = RubyPitaya::RubyPitaya.create_migration(migration_name)
|
56
|
+
|
57
|
+
puts "Migration #{migration_file_name} created!"
|
58
|
+
end
|
59
|
+
|
43
60
|
def show_help
|
44
61
|
puts 'Usage: $ rubypitaya [COMMAND]'
|
45
62
|
puts 'COMMAND:'
|
46
|
-
puts ' run:
|
47
|
-
puts ' create:
|
63
|
+
puts ' run: - Run server'
|
64
|
+
puts ' create: - Create project'
|
65
|
+
puts ' create-migration: - Create migration'
|
48
66
|
puts ''
|
49
67
|
end
|
50
68
|
|
@@ -53,4 +71,9 @@ def show_help_create
|
|
53
71
|
puts ''
|
54
72
|
end
|
55
73
|
|
74
|
+
def show_help_create_migration
|
75
|
+
puts 'Usage: $ rubypitaya create-migration [migration_name]'
|
76
|
+
puts ''
|
77
|
+
end
|
78
|
+
|
56
79
|
main
|
data/lib/rubypitaya.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'ostruct'
|
1
3
|
require 'fileutils'
|
2
4
|
|
3
5
|
require 'rubypitaya/core/main'
|
@@ -16,5 +18,24 @@ module RubyPitaya
|
|
16
18
|
|
17
19
|
FileUtils.cp_r app_template_path, project_path
|
18
20
|
end
|
21
|
+
|
22
|
+
def self.create_migration(migration_name)
|
23
|
+
migration_name = "#{migration_name}_migration" unless migration_name.underscore.end_with?('migration')
|
24
|
+
migration_timestamp = Time.now.utc.to_i
|
25
|
+
migration_file_name = "#{migration_timestamp}_#{migration_name.underscore}.rb"
|
26
|
+
migration_class_name = migration_name.camelcase
|
27
|
+
|
28
|
+
template_struct = OpenStruct.new(
|
29
|
+
class_name: migration_class_name,
|
30
|
+
)
|
31
|
+
|
32
|
+
template = File.open(Path::MIGRATION_TEMPLATE_PATH, &:read)
|
33
|
+
template_result = ERB.new(template).result(template_struct.instance_eval { binding })
|
34
|
+
|
35
|
+
migration_file_path = File.join(Path::MIGRATIONS_FOLDER_PATH, migration_file_name)
|
36
|
+
File.open(migration_file_path, 'w') { |f| f.write(template_result) }
|
37
|
+
|
38
|
+
migration_file_name
|
39
|
+
end
|
19
40
|
end
|
20
41
|
end
|
@@ -69,7 +69,7 @@ GEM
|
|
69
69
|
rspec-support (~> 3.8.0)
|
70
70
|
rspec-support (3.8.3)
|
71
71
|
ruby2_keywords (0.0.2)
|
72
|
-
rubypitaya (2.
|
72
|
+
rubypitaya (2.9.0)
|
73
73
|
activerecord (= 6.0.2)
|
74
74
|
etcdv3 (= 0.10.2)
|
75
75
|
eventmachine (= 1.2.7)
|
@@ -106,7 +106,7 @@ DEPENDENCIES
|
|
106
106
|
listen (= 3.2.1)
|
107
107
|
pry (= 0.12.2)
|
108
108
|
rspec (= 3.8.0)
|
109
|
-
rubypitaya (= 2.
|
109
|
+
rubypitaya (= 2.9.0)
|
110
110
|
|
111
111
|
BUNDLED WITH
|
112
112
|
1.17.2
|
@@ -28,6 +28,10 @@ console:
|
|
28
28
|
bash:
|
29
29
|
@docker-compose run --service-ports --rm rubypitaya bash
|
30
30
|
|
31
|
+
## Create new migrgation. NAME=[migration-name]
|
32
|
+
create-migration:
|
33
|
+
@docker-compose run --service-ports --rm rubypitaya-console bundle exec rubypitaya create-migration $(NAME)
|
34
|
+
|
31
35
|
## Create database
|
32
36
|
db-create:
|
33
37
|
@docker-compose run --service-ports --rm rubypitaya bundle exec rake db:create
|
@@ -6,18 +6,22 @@ require 'active_record'
|
|
6
6
|
require 'rubypitaya'
|
7
7
|
require 'rubypitaya/core/database_config'
|
8
8
|
|
9
|
+
# Database connection
|
9
10
|
environment_name = ENV.fetch("RUBYPITAYA_ENV") { 'development' }
|
10
11
|
database_config = RubyPitaya::DatabaseConfig.new(environment_name, RubyPitaya::Path::DATABASE_CONFIG_PATH)
|
11
12
|
ActiveRecord::Base.establish_connection(database_config.connection_data)
|
12
13
|
ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT)
|
13
14
|
ActiveSupport::LogSubscriber.colorize_logging = true
|
14
15
|
|
16
|
+
# Loading core files
|
15
17
|
Gem.find_files('rubypitaya/**/*.rb').each do |path|
|
16
18
|
require path unless path.end_with?('spec.rb') ||
|
17
19
|
path.include?('db/migration') ||
|
20
|
+
path.include?('core/templates') ||
|
18
21
|
path.include?('app-template')
|
19
22
|
end
|
20
23
|
|
24
|
+
# Loading application files
|
21
25
|
app_folder_paths = RubyPitaya::Path::Plugins::APP_FOLDER_PATHS + [RubyPitaya::Path::APP_FOLDER_PATH]
|
22
26
|
app_folder_paths.each do |app_folder_path|
|
23
27
|
app_files_path = File.join(app_folder_path, '**/*.rb')
|
@@ -28,7 +32,9 @@ app_folder_paths.each do |app_folder_path|
|
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
35
|
+
# Starting irb
|
31
36
|
require 'irb'
|
32
37
|
IRB.start(__FILE__)
|
33
38
|
|
39
|
+
# Closing database connection
|
34
40
|
ActiveRecord::Base.connection.close
|
data/lib/rubypitaya/core/path.rb
CHANGED
@@ -2,6 +2,7 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class Path
|
4
4
|
APP_TEMPLATE_FOLDER_PATH = File.join(__dir__, '../app-template/')
|
5
|
+
MIGRATION_TEMPLATE_PATH = File.join(__dir__, 'templates/template_migration.rb.erb')
|
5
6
|
|
6
7
|
DATABASE_CONFIG_PATH = File.join(Dir.pwd, 'config/database.yml')
|
7
8
|
|
@@ -15,6 +16,7 @@ module RubyPitaya
|
|
15
16
|
|
16
17
|
HTTP_VIEWS_PATH = File.join(Dir.pwd, 'app/http/views')
|
17
18
|
|
19
|
+
|
18
20
|
class Core
|
19
21
|
APP_FOLDER_PATH = File.join(__dir__, 'app/')
|
20
22
|
MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'db/migration/')
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
|
3
|
+
class <%= class_name %> < ActiveRecord::Migration[5.1]
|
4
|
+
|
5
|
+
enable_extension 'pgcrypto'
|
6
|
+
|
7
|
+
def change
|
8
|
+
create_table :[table-name-here-in-plural], id: :uuid do |t|
|
9
|
+
# t.belongs_to :user, type: :uuid
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/rubypitaya/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypitaya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Prestes Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ostruct
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.1.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: sinatra-contrib
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,6 +299,7 @@ files:
|
|
285
299
|
- "./lib/rubypitaya/core/session.rb"
|
286
300
|
- "./lib/rubypitaya/core/setup.rb"
|
287
301
|
- "./lib/rubypitaya/core/status_codes.rb"
|
302
|
+
- "./lib/rubypitaya/core/templates/template_migration.rb.erb"
|
288
303
|
- "./lib/rubypitaya/version.rb"
|
289
304
|
- bin/rubypitaya
|
290
305
|
homepage: https://gitlab.com/LucianoPC/ruby-pitaya
|