forced 0.1.0 → 0.2.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/README.md +32 -20
- data/lib/forced/engine.rb +0 -9
- data/lib/forced/version.rb +1 -1
- data/lib/generators/forced/install_generator.rb +65 -0
- data/lib/generators/forced/templates/create_forced_app_versions.rb.erb +15 -0
- metadata +3 -9
- data/app/assets/config/forced_manifest.js +0 -2
- data/app/assets/javascripts/forced/application.js +0 -15
- data/app/assets/stylesheets/forced/application.css +0 -15
- data/app/helpers/forced/application_helper.rb +0 -4
- data/app/jobs/forced/application_job.rb +0 -4
- data/app/mailers/forced/application_mailer.rb +0 -6
- data/app/views/layouts/forced/application.html.erb +0 -16
- data/db/migrate/20180713160038_create_forced_app_versions.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24410ac9c0767e607034525d8168837dc87231bf
|
4
|
+
data.tar.gz: 1706c0b98edca3bc8b4e09779c829fdc74c07180
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16f9039bfcd3f53f2a91148d28f3c52f8363e2c735eca9e3d76ff9d2c4ca7ae5d2495313e6280d5e7eeb91ba39eb7f03525ba516158daecba4a9e2d723e25a49
|
7
|
+
data.tar.gz: 49b535a85af7581037e7db44d8dceaba655db7454e17a38f70c1f074cd0c7d61161d5a422f7540d78648dad963ba260f35411b68bc74cc125c84e4b75024fa10
|
data/README.md
CHANGED
@@ -6,16 +6,45 @@ Read the link below to get some insight.
|
|
6
6
|
|
7
7
|
* [Handling Force Update on Mobile Apps / Rusty Neuron](https://rustyneuron.net/2018/07/12/handling-force-update-on-mobile-apps/)
|
8
8
|
|
9
|
-
##
|
9
|
+
## Installation
|
10
|
+
Add this line to your application's Gemfile:
|
10
11
|
|
11
|
-
|
12
|
+
```ruby
|
13
|
+
gem 'forced'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
```bash
|
18
|
+
$ bundle
|
19
|
+
```
|
12
20
|
|
13
|
-
|
21
|
+
Or install it yourself as:
|
22
|
+
```bash
|
23
|
+
$ gem install forced
|
24
|
+
```
|
25
|
+
|
26
|
+
And then, run:
|
27
|
+
```bash
|
28
|
+
# this will create a migration file.
|
29
|
+
$ bundle exec rails g forced:install
|
30
|
+
|
31
|
+
# this will migrate it.
|
32
|
+
$ bundle exec rails db:migrate
|
33
|
+
```
|
34
|
+
|
35
|
+
After all these are done, add the line below to your routes file.
|
14
36
|
|
15
37
|
```ruby
|
16
38
|
mount Forced::Engine => "/forced"
|
17
39
|
```
|
18
40
|
|
41
|
+
You are all set!
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
Module needs to get the coming request to prepare the response. As long as request headers contains `X-Platform` and `X-Client-Version`, you are good to go.
|
46
|
+
|
47
|
+
|
19
48
|
Then send a `GET` request to `{{url}}/forced/status`. This will return the below JSON.
|
20
49
|
|
21
50
|
```json
|
@@ -52,22 +81,5 @@ Forced::AppVersion.new
|
|
52
81
|
|
53
82
|
All available under `Forced::MESSAGES` hash table. You can override the values as you wish. Also checkout the `check_update_status` private method in `base.rb` to understand the cases.
|
54
83
|
|
55
|
-
## Installation
|
56
|
-
Add this line to your application's Gemfile:
|
57
|
-
|
58
|
-
```ruby
|
59
|
-
gem 'forced'
|
60
|
-
```
|
61
|
-
|
62
|
-
And then execute:
|
63
|
-
```bash
|
64
|
-
$ bundle
|
65
|
-
```
|
66
|
-
|
67
|
-
Or install it yourself as:
|
68
|
-
```bash
|
69
|
-
$ gem install forced
|
70
|
-
```
|
71
|
-
|
72
84
|
## License
|
73
85
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/forced/engine.rb
CHANGED
@@ -1,14 +1,5 @@
|
|
1
1
|
module Forced
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace Forced
|
4
|
-
|
5
|
-
# import engine's migratons into main app
|
6
|
-
initializer :append_migrations do |app|
|
7
|
-
unless app.root.to_s.match root.to_s
|
8
|
-
config.paths["db/migrate"].expanded.each do |expanded_path|
|
9
|
-
app.config.paths["db/migrate"] << expanded_path
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
4
|
end
|
14
5
|
end
|
data/lib/forced/version.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/active_record'
|
5
|
+
|
6
|
+
module Forced
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
include ::Rails::Generators::Migration
|
9
|
+
|
10
|
+
MYSQL_ADAPTERS = [
|
11
|
+
"ActiveRecord::ConnectionAdapters::MysqlAdapter",
|
12
|
+
"ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
source_root File.expand_path('templates', __dir__)
|
16
|
+
|
17
|
+
desc "Generates (but does not run) a migration to add a forced_app_versions table."
|
18
|
+
|
19
|
+
def create_migration_file
|
20
|
+
add_paper_trail_migration('create_forced_app_versions')
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.next_migration_number(dirname)
|
24
|
+
::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def add_paper_trail_migration(template)
|
30
|
+
migration_dir = File.expand_path('db/migrate')
|
31
|
+
|
32
|
+
if self.class.migration_exists?(migration_dir, template)
|
33
|
+
::Kernel.warn "Migration already exists: #{template}"
|
34
|
+
else
|
35
|
+
migration_template(
|
36
|
+
"#{template}.rb.erb",
|
37
|
+
"db/migrate/#{template}.rb",
|
38
|
+
migration_version: migration_version,
|
39
|
+
forced_app_versions_table_options: forced_app_versions_table_options
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def migration_version
|
47
|
+
major = ActiveRecord::VERSION::MAJOR
|
48
|
+
if major >= 5
|
49
|
+
"[#{major}.#{ActiveRecord::VERSION::MINOR}]"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def mysql?
|
54
|
+
MYSQL_ADAPTERS.include?(ActiveRecord::Base.connection.class.name)
|
55
|
+
end
|
56
|
+
|
57
|
+
def forced_app_versions_table_options
|
58
|
+
if mysql?
|
59
|
+
', { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }'
|
60
|
+
else
|
61
|
+
""
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This migration creates the `app_versions` table, the only schema PT requires.
|
2
|
+
# All other migrations PT provides are optional.
|
3
|
+
class CreateForcedAppVersions < ActiveRecord::Migration<%= migration_version %>
|
4
|
+
|
5
|
+
def change
|
6
|
+
create_table :forced_app_versions<%= forced_app_versions_table_options %> do |t|
|
7
|
+
t.integer :client
|
8
|
+
t.string :version, limit: 255
|
9
|
+
t.boolean :force_update, nil: false, default: false
|
10
|
+
t.text :changelog
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forced
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aoozdemir
|
@@ -62,19 +62,11 @@ files:
|
|
62
62
|
- MIT-LICENSE
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
|
-
- app/assets/config/forced_manifest.js
|
66
|
-
- app/assets/javascripts/forced/application.js
|
67
|
-
- app/assets/stylesheets/forced/application.css
|
68
65
|
- app/controllers/forced/application_controller.rb
|
69
66
|
- app/controllers/forced/status_controller.rb
|
70
|
-
- app/helpers/forced/application_helper.rb
|
71
|
-
- app/jobs/forced/application_job.rb
|
72
|
-
- app/mailers/forced/application_mailer.rb
|
73
67
|
- app/models/forced/app_version.rb
|
74
68
|
- app/models/forced/application_record.rb
|
75
|
-
- app/views/layouts/forced/application.html.erb
|
76
69
|
- config/routes.rb
|
77
|
-
- db/migrate/20180713160038_create_forced_app_versions.rb
|
78
70
|
- lib/forced.rb
|
79
71
|
- lib/forced/base.rb
|
80
72
|
- lib/forced/client_enum.rb
|
@@ -82,6 +74,8 @@ files:
|
|
82
74
|
- lib/forced/messages.rb
|
83
75
|
- lib/forced/response.rb
|
84
76
|
- lib/forced/version.rb
|
77
|
+
- lib/generators/forced/install_generator.rb
|
78
|
+
- lib/generators/forced/templates/create_forced_app_versions.rb.erb
|
85
79
|
- lib/tasks/forced_tasks.rake
|
86
80
|
homepage: https://github.com/aoozdemir/forced
|
87
81
|
licenses:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require rails-ujs
|
14
|
-
//= require activestorage
|
15
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
-
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
-
* It is generally better to create a new file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Forced</title>
|
5
|
-
<%= csrf_meta_tags %>
|
6
|
-
<%= csp_meta_tag %>
|
7
|
-
|
8
|
-
<%= stylesheet_link_tag "forced/application", media: "all" %>
|
9
|
-
<%= javascript_include_tag "forced/application" %>
|
10
|
-
</head>
|
11
|
-
<body>
|
12
|
-
|
13
|
-
<%= yield %>
|
14
|
-
|
15
|
-
</body>
|
16
|
-
</html>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class CreateForcedAppVersions < ActiveRecord::Migration[5.2]
|
2
|
-
def change
|
3
|
-
create_table :forced_app_versions do |t|
|
4
|
-
t.integer :client
|
5
|
-
t.string :version, limit: 255
|
6
|
-
t.boolean :force_update, nil: false, default: false
|
7
|
-
t.text :changelog
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|