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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b323c32a3c1afc5ae8b8cc1f7eab25db1c40f455c1ffa41b6c7fed3e0cb7508f
4
- data.tar.gz: 0d21fd9eb025d27b59274188c6535926c8f6a9e7ac524026db3702232b58e822
3
+ metadata.gz: 286a5030a03e22e1da481e6acd099fee4372e293fa299599872a0045949718f4
4
+ data.tar.gz: 16855e3e132f08248ec3fe1bd8c04a0e0850a51f330462010e896cdac46f5721
5
5
  SHA512:
6
- metadata.gz: 9bd05d4f7f1b953ead3fb74bf1b8aa839ee084e06cf0b9f0febc9745702cdcd2f3a0c1280e336e11c0c55a63750afdc60ece4595fff804bc5e4cf1e5c92ed618
7
- data.tar.gz: 689d91b58317758cc629ae46d617ab36c82714415cf10852317d05b37437b11248b28b44a4fb0a975f9b62758e4ed77376226b43b24b577e7d096a58bf3359dc
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.4
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
@@ -16,3 +16,4 @@ matrix:
16
16
 
17
17
  allow_failures:
18
18
  - rvm: ruby-head
19
+ - rvm: 2.4.5
data/CHANGELOG.md CHANGED
@@ -2,8 +2,15 @@
2
2
 
3
3
  - contributions
4
4
 
5
- ### 1.0.1
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
@@ -11,6 +11,6 @@ group :development, :test do
11
11
  gem 'rack-cors', require: false
12
12
  gem 'rack-test', require: false
13
13
  gem 'rake', '~> 12.0'
14
- gem 'rspec', '~> 3.7'
14
+ gem 'rspec', '~> 3.8'
15
15
  gem 'rspec-command'
16
16
  end
@@ -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: '#{adapter}'
27
- host: localhost
28
- port: 27017
29
- database: "db/development.sqlite3"
30
- username:
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: '#{adapter}'
35
- host: localhost
36
- port: 27017
37
- database: "db/test.sqlite3"
38
- username:
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: '#{adapter}'
43
- host: localhost
44
- port: 27017
45
- database: "db/production.sqlite3"
46
- username:
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', 'migrations', file_name)
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
- @orm == 'sequel' ? 'sqlite' : 'sqlite3'
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
- migrations = File.join(dest, 'migrations')
103
- FileUtils.mkdir_p(migrations)
104
- `touch #{migrations}/.keep`
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
- task :load_config do
64
- config_dir = File.expand_path('../config', __FILE__)
65
- config_content = File.read(File.join(config_dir, 'database.yml'))
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
- # DB stack
70
+ # BE stuff
71
+ gem 'standalone_migrations'
72
+
73
+ # DB stuff
85
74
  gem 'activerecord', '~> 5.2'
86
- gem 'sqlite3', '~> 1.3', '< 1.4'
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.1]
81
+ class Create#{klass_name} < ActiveRecord::Migration[5.2]
93
82
  def change
94
83
  create_table :#{resource} do |t|
95
84
 
@@ -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
- begin
85
- FileUtils.rm file_to_remove
86
- rescue StandardError => error
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Starter
4
- VERSION = '1.0.3'
4
+ VERSION = '1.1.0'
5
5
  end
@@ -7,10 +7,16 @@ AllCops:
7
7
  - Rakefile
8
8
  - Gemfile
9
9
  UseCache: true
10
- TargetRubyVersion: 2.4
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
@@ -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
@@ -2,11 +2,13 @@
2
2
 
3
3
  source 'http://rubygems.org'
4
4
 
5
+ # Server stuff
5
6
  gem 'thin'
6
7
 
7
8
  gem 'rack'
8
9
  gem 'rack-cors'
9
10
 
11
+ # API stuff
10
12
  gem 'grape'
11
13
  gem 'grape-entity'
12
14
  gem 'grape-swagger'
data/template/Rakefile CHANGED
@@ -23,5 +23,6 @@ task default: %i[spec rubocop]
23
23
  require 'grape-swagger/rake/oapi_tasks'
24
24
  GrapeSwagger::Rake::OapiTasks.new(::Api::Base)
25
25
 
26
+ # starter tasks
26
27
  require 'starter/rake/grape_tasks'
27
28
  Starter::Rake::GrapeTasks.new(::Api::Base)
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.3
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-10 00:00:00.000000000 Z
11
+ date: 2019-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli