grape-starter 1.0.3 → 1.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 +4 -4
- data/.rubocop.yml +7 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +8 -31
- data/Gemfile +1 -1
- data/lib/starter/builder/orms.rb +32 -23
- data/lib/starter/builder/templates/activerecord.rb +9 -20
- data/lib/starter/builder.rb +3 -5
- data/lib/starter/version.rb +1 -1
- data/template/.rubocop.yml +10 -4
- data/template/.rubocop_todo.yml +0 -13
- data/template/Gemfile +2 -0
- data/template/Rakefile +1 -0
- 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: 286a5030a03e22e1da481e6acd099fee4372e293fa299599872a0045949718f4
|
4
|
+
data.tar.gz: 16855e3e132f08248ec3fe1bd8c04a0e0850a51f330462010e896cdac46f5721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4362af960d305232d718184faf5406740f0e6331a91e17e256171609871c21c9a7a25176c164d4998a56dca3aa745eadf44016c3e4d4ed270de5c5d816b98bc0
|
7
|
+
data.tar.gz: 1576e5b5b7f6b0db966a208ebe6b1c4e676d8d625cd365c68ed92d911a240a65459a59bd17c5bfab686e309800b95e65237ec4c2ffebcbb866b8b50b9f171eef
|
data/.rubocop.yml
CHANGED
@@ -9,7 +9,7 @@ AllCops:
|
|
9
9
|
- '**/template/api/**'
|
10
10
|
- grape-starter.gemspec
|
11
11
|
UseCache: true
|
12
|
-
TargetRubyVersion: 2.
|
12
|
+
TargetRubyVersion: 2.6
|
13
13
|
|
14
14
|
Layout/IndentationWidth:
|
15
15
|
Exclude:
|
@@ -23,6 +23,12 @@ Metrics/BlockLength:
|
|
23
23
|
Metrics/LineLength:
|
24
24
|
Max: 120
|
25
25
|
|
26
|
+
Metrics/AbcSize:
|
27
|
+
Max: 20
|
28
|
+
|
29
|
+
Metrics/MethodLength:
|
30
|
+
Max: 20
|
31
|
+
|
26
32
|
Naming/AccessorMethodName:
|
27
33
|
Exclude:
|
28
34
|
- 'lib/starter/builder/templates/files.rb'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,8 +2,15 @@
|
|
2
2
|
|
3
3
|
- contributions
|
4
4
|
|
5
|
-
### 1.0
|
5
|
+
### v1.1.0 / 2019-02-22
|
6
|
+
- Replaces own migration tasks through [standalone-migrations](https://github.com/thuss/standalone-migrations)
|
7
|
+
|
8
|
+
### v1.0.3 / 2019-02-10
|
9
|
+
- Loosens reuby version to 2.4
|
10
|
+
- prepare release 1.0.2
|
11
|
+
- Cleans up travis ci.
|
6
12
|
|
13
|
+
### 1.0.1
|
7
14
|
- [00993](https://github.com/LeFnord/grape-starter/commit/6fef3812fd587ea61c29b9eacde1fb856ad00993) - adds a rudimentary Dockerfile as starting point
|
8
15
|
|
9
16
|
### 1.0.0
|
@@ -69,33 +76,3 @@
|
|
69
76
|
**breaking changes** renames all api stuff under lib to models (includes, of course, the namespace):
|
70
77
|
- `lib/api.rb` -> `lib/models.rb`
|
71
78
|
- `lib/api/` -> `lib/models/`
|
72
|
-
|
73
|
-
### < 0.5.4
|
74
|
-
|
75
|
-
- simplyfies request specs, **breaking change**: takes route from spec description
|
76
|
-
- adds option to set prefix, defaults to api
|
77
|
-
- sets prefix after project name
|
78
|
-
- refactores rack api mounting
|
79
|
-
- adds ruby 2.4.0 support
|
80
|
-
- server command supports port, thin tag would be named after project
|
81
|
-
- adds redoc oapi documentation viewer
|
82
|
-
- default rake task now only spec, rubocop would be done via hound
|
83
|
-
- adds hound ci service
|
84
|
-
- fix: add mount point to api base
|
85
|
-
- adds inch.yml
|
86
|
-
- improves specs
|
87
|
-
- fix: removes mount point from api base
|
88
|
-
- renames `remove` to `rm`
|
89
|
-
- adds params to POST, PUT and PATCH specs
|
90
|
-
- removes duplication and warning
|
91
|
-
- allows entity removing
|
92
|
-
- adds `remove` command
|
93
|
-
- adds request specs shared examples
|
94
|
-
- corrects path param for specific endpoints
|
95
|
-
- corrects adding of endpoints, if no http verb was given
|
96
|
-
- adds flag for entity creating
|
97
|
-
- moves back dependencies to gemspec
|
98
|
-
- adds rubygems badge
|
99
|
-
- cleans up dependencies
|
100
|
-
- adds `force` option to add
|
101
|
-
- adds specifying http verbs
|
data/Gemfile
CHANGED
data/lib/starter/builder/orms.rb
CHANGED
@@ -10,6 +10,7 @@ module Starter
|
|
10
10
|
if @orm == 'ar' || @orm == 'activerecord'
|
11
11
|
# Fixes pooling
|
12
12
|
add_middleware(dest, 'ActiveRecord::Rack::ConnectionManagement')
|
13
|
+
build_standalone_migrations(File.join(dest, '.standalone_migrations'))
|
13
14
|
end
|
14
15
|
|
15
16
|
build_initializer(File.join(dest, 'config', 'initializers'))
|
@@ -19,32 +20,36 @@ module Starter
|
|
19
20
|
prepare_for_migrations(File.join(dest, 'db'))
|
20
21
|
end
|
21
22
|
|
23
|
+
def standalone_migrations
|
24
|
+
<<-FILE.strip_heredoc
|
25
|
+
config:
|
26
|
+
database: config/database.yml
|
27
|
+
FILE
|
28
|
+
end
|
29
|
+
|
22
30
|
def config
|
23
31
|
<<-FILE.strip_heredoc
|
24
32
|
# ActiveRecord Database Configuration
|
25
33
|
development:
|
26
|
-
adapter:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
password:
|
34
|
+
adapter: #{adapter}
|
35
|
+
encoding: unicode
|
36
|
+
timeout: 5000
|
37
|
+
user: postgres
|
38
|
+
database: name_development
|
32
39
|
|
33
40
|
test:
|
34
|
-
adapter:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
password:
|
41
|
+
adapter: #{adapter}
|
42
|
+
encoding: unicode
|
43
|
+
timeout: 5000
|
44
|
+
user: postgres
|
45
|
+
database: name_test
|
40
46
|
|
41
47
|
production:
|
42
|
-
adapter:
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
password:
|
48
|
+
adapter: #{adapter}
|
49
|
+
encoding: unicode
|
50
|
+
timeout: 5000
|
51
|
+
user: postgres
|
52
|
+
database: name_production
|
48
53
|
FILE
|
49
54
|
end
|
50
55
|
|
@@ -53,7 +58,7 @@ module Starter
|
|
53
58
|
return if @orm.nil?
|
54
59
|
|
55
60
|
file_name = "#{Time.now.strftime('%Y%m%d%H%m%S')}_Create#{klass_name}.rb"
|
56
|
-
migration_dest = File.join(Dir.pwd, 'db', '
|
61
|
+
migration_dest = File.join(Dir.pwd, 'db', 'migrate', file_name)
|
57
62
|
FileFoo.write_file(migration_dest, migration(klass_name, resource))
|
58
63
|
end
|
59
64
|
|
@@ -75,7 +80,7 @@ module Starter
|
|
75
80
|
private
|
76
81
|
|
77
82
|
def adapter
|
78
|
-
|
83
|
+
'postgresql'
|
79
84
|
end
|
80
85
|
|
81
86
|
def build_initializer(dest)
|
@@ -87,6 +92,10 @@ module Starter
|
|
87
92
|
FileFoo.write_file(File.join(dest, 'database.yml'), config)
|
88
93
|
end
|
89
94
|
|
95
|
+
def build_standalone_migrations(dest)
|
96
|
+
FileFoo.write_file(dest, standalone_migrations)
|
97
|
+
end
|
98
|
+
|
90
99
|
# adds a middleware to config.ru
|
91
100
|
def add_middleware(dest, middleware)
|
92
101
|
replacement = "use #{middleware}\n\n\\1"
|
@@ -99,9 +108,9 @@ module Starter
|
|
99
108
|
end
|
100
109
|
|
101
110
|
def prepare_for_migrations(dest)
|
102
|
-
|
103
|
-
FileUtils.mkdir_p(
|
104
|
-
`touch #{
|
111
|
+
migrate = File.join(dest, 'migrate')
|
112
|
+
FileUtils.mkdir_p(migrate)
|
113
|
+
`touch #{migrate}/.keep`
|
105
114
|
end
|
106
115
|
end
|
107
116
|
end
|
@@ -58,38 +58,27 @@ module Starter
|
|
58
58
|
|
59
59
|
def rakefile
|
60
60
|
<<-FILE.strip_heredoc
|
61
|
-
# ActiveRecord DB tasks
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
DatabaseTasks.env = ENV['RACK_ENV'] || 'development'
|
68
|
-
DatabaseTasks.db_dir = db_dir
|
69
|
-
config = YAML.safe_load(ERB.new(config_content).result)
|
70
|
-
DatabaseTasks.database_configuration = config
|
71
|
-
DatabaseTasks.migrations_paths = File.join(db_dir, 'migrate')
|
72
|
-
|
73
|
-
ActiveRecord::Base.configurations = DatabaseTasks.database_configuration
|
74
|
-
ActiveRecord::Base.establish_connection DatabaseTasks.env.to_sym
|
75
|
-
end
|
76
|
-
|
77
|
-
# Loads AR tasks like db:create, db:drop etc..
|
78
|
-
load 'active_record/railties/databases.rake'
|
62
|
+
# ActiveRecord migration tasks
|
63
|
+
require 'standalone_migrations'
|
64
|
+
StandaloneMigrations::Tasks.load_tasks
|
79
65
|
FILE
|
80
66
|
end
|
81
67
|
|
82
68
|
def gemfile
|
83
69
|
<<-FILE.strip_heredoc
|
84
|
-
#
|
70
|
+
# BE stuff
|
71
|
+
gem 'standalone_migrations'
|
72
|
+
|
73
|
+
# DB stuff
|
85
74
|
gem 'activerecord', '~> 5.2'
|
86
|
-
gem '
|
75
|
+
gem 'pg'
|
87
76
|
FILE
|
88
77
|
end
|
89
78
|
|
90
79
|
def migration(klass_name, resource)
|
91
80
|
<<-FILE.strip_heredoc
|
92
|
-
class Create#{klass_name} < ActiveRecord::Migration[5.
|
81
|
+
class Create#{klass_name} < ActiveRecord::Migration[5.2]
|
93
82
|
def change
|
94
83
|
create_table :#{resource} do |t|
|
95
84
|
|
data/lib/starter/builder.rb
CHANGED
@@ -81,11 +81,9 @@ module Starter
|
|
81
81
|
@entity = options[:entity]
|
82
82
|
|
83
83
|
file_list.map { |x| send("#{x}_name") }.each do |file_to_remove|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
$stdout.puts error.to_s
|
88
|
-
end
|
84
|
+
FileUtils.rm file_to_remove
|
85
|
+
rescue StandardError => error
|
86
|
+
$stdout.puts error.to_s
|
89
87
|
end
|
90
88
|
|
91
89
|
remove_mount_point
|
data/lib/starter/version.rb
CHANGED
data/template/.rubocop.yml
CHANGED
@@ -7,10 +7,16 @@ AllCops:
|
|
7
7
|
- Rakefile
|
8
8
|
- Gemfile
|
9
9
|
UseCache: true
|
10
|
-
TargetRubyVersion: 2.
|
11
|
-
|
12
|
-
Metrics/BlockLength:
|
13
|
-
Enabled: false
|
10
|
+
TargetRubyVersion: 2.6
|
14
11
|
|
15
12
|
Metrics/LineLength:
|
16
13
|
Max: 120
|
14
|
+
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Max: 20
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Max: 20
|
20
|
+
|
21
|
+
Style/AsciiComments:
|
22
|
+
Enabled: false
|
data/template/.rubocop_todo.yml
CHANGED
@@ -9,19 +9,6 @@
|
|
9
9
|
# Offense count: 1
|
10
10
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
11
11
|
# URISchemes: http, https
|
12
|
-
Metrics/LineLength:
|
13
|
-
Max: 120
|
14
|
-
|
15
|
-
Metrics/AbcSize:
|
16
|
-
Max: 20
|
17
|
-
|
18
|
-
# Offense count: 1
|
19
|
-
# Configuration parameters: CountComments.
|
20
|
-
Metrics/MethodLength:
|
21
|
-
Max: 20
|
22
|
-
|
23
|
-
Style/AsciiComments:
|
24
|
-
Enabled: false
|
25
12
|
|
26
13
|
# Offense count: 6
|
27
14
|
Style/Documentation:
|
data/template/Gemfile
CHANGED
data/template/Rakefile
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-starter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LeFnord
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|