native 1.0.0 → 2.0.0

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: 6a0f49ca96f43cc606c67f8d36983a1680534ad5099cef846bbf1a2ad9c67b70
4
- data.tar.gz: 3547dcc23cc09bbae8daebbf422298891411502db16893c53235a3814704bc6a
3
+ metadata.gz: 0bfb554ed0a23884a6355580ddee53294e29b6ddfee890d4b81c894b027c9359
4
+ data.tar.gz: dfc98650f1fa96e4f72f6047017d8326fb526a47967657d2713eedcc24d66504
5
5
  SHA512:
6
- metadata.gz: a2af11d5c69359666db6ba567f95119a2fa358a988274fea0b9d4cf13cc874e341e8a59c51c47e45f17f6c6294528f9f0f2ffa1846e57c6600aa9119df705083
7
- data.tar.gz: 1c3cb8e5f8acb4ed23b51d53eb87cf616c2915957e508015e3e46d2182639f9fe5952602a03cf5d54ff0b1a77bb7d73b2fb9a7983b050b84660d9a4d0a0bd665
6
+ metadata.gz: 5375af7ad6450574e0317b12ac34a4cc5e1575558c57512335174c284d65f8eda977a0018434970800b8584e57579ae486bfd99fd342a1ed7583425929df177e
7
+ data.tar.gz: 9f73e0a914cc98362dee8a0bf213cde5ffeb4329dbecac9f4d00e2a7efa38996ea63f67ee5153060e3229196a1f52860ceedefd1fbe06dced38e38b42c5a41db
data/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
- ### 1.0.0 - 2017-12-19
7
+ ### 2.0.0 - 2017-12-21
8
+
9
+ * features
10
+ * made Devise optional
11
+ * added `owner` association to `App` model
12
+
13
+ ### 1.0.0 - 2017-12-20
8
14
 
9
15
  * initial release
data/DEPRECATIONS.md CHANGED
@@ -1 +1,5 @@
1
1
  # Deprecations
2
+
3
+ ### 2.0.0 - 2017-12-21
4
+
5
+ * `devise_class` configuration method removed
data/README.md CHANGED
@@ -35,6 +35,7 @@ Native is being powered by **[NativeGap](https://nativegap.com)**.
35
35
  * [NativeGap](#nativegap)
36
36
  * [Assets](#assets)
37
37
  * [App methods](#app-methods)
38
+ * [Associate objects](#associate-objects)
38
39
  * [View methods](#view-methods)
39
40
  * [Notifications](#notifications)
40
41
  * [Content scaling (Android)](#content-scaling-android)
@@ -42,6 +43,7 @@ Native is being powered by **[NativeGap](https://nativegap.com)**.
42
43
  * [To Do](#to-do)
43
44
  * [Contributing](#contributing)
44
45
  * [Contributors](#contributors)
46
+ * [Semantic versioning](#semantic-versioning)
45
47
  * [License](#license)
46
48
 
47
49
  ---
@@ -117,7 +119,7 @@ mount Native::Engine, at: '/native'
117
119
 
118
120
  ### NativeGap
119
121
 
120
- While this gem assists you in creating a true cross-platform app, [NativeGap](https://nativegap.com) is still needed to create the actual native code. That's not too big of a deal though, NativeApp can be used entirely for free and it has an extensive [documentation](https://nativegap.com/guide).
122
+ While this gem assists you in creating a true cross-platform app, [NativeGap](https://nativegap.com) is still needed to create the actual native code. That's not too big of a deal though, NativeApp can be used entirely for free ([learn more](https://nativegap.com/pricing)) and it has an extensive [documentation](https://nativegap.com/guide).
121
123
 
122
124
  Getting started with NativeGap:
123
125
 
@@ -127,11 +129,11 @@ Getting started with NativeGap:
127
129
 
128
130
  That's it!
129
131
 
130
- Native also supports the coexistence of multiple NativeGap apps with only one Rails app as a source.
132
+ **Note:** Native also supports the coexistence of multiple NativeGap apps with only one Rails app as a source.
131
133
 
132
134
  ### Assets
133
135
 
134
- With Native it is fairly simple to add platform specific stylesheets and scripts. In your assets directory you have a separate folder (in `app/assets/native`) for every platform which behaves similarly to the root assets folder. You are not only able to add custom assets for those platforms added by Native, but you can also add `web` specific assets.
136
+ With Native it is fairly simple to add platform specific stylesheets and scripts. In your assets directory you have a separate folder (`app/assets/native`) for every platform behaving similarly to the root assets folder. You are not only able to add custom assets for those platforms added by Native, but you can also add `web` specific assets.
135
137
 
136
138
  You simple have to include ...
137
139
 
@@ -148,8 +150,8 @@ Native introduces an `App` activerecord model. Every object of your devise class
148
150
  ```ruby
149
151
  a = App.first
150
152
 
151
- # Returns user (or other devise object) that this device belongs to. Can return `nil`.
152
- a.user
153
+ # Returns associated object. Can return `nil`.
154
+ a.owner
153
155
 
154
156
  # Returns lowercase string of platform.
155
157
  d.platform
@@ -175,6 +177,20 @@ d.platforms
175
177
  d.apps
176
178
  ```
177
179
 
180
+ #### Associate objects
181
+
182
+ If you are using Devise and your model is named `User`, the object returned by `current_user` will automatically be associated with the current app. If your Devise model is not named `User` or you are using a different user-management solution that does not implement a `current_user` method, you are able to override this default behavior.
183
+
184
+ Let's say our Devise model is named `Admin`. Just add a `private` method to your `ApplicationController`:
185
+
186
+ ```ruby
187
+ def set_app_owner
188
+ current_admin if current_admin
189
+ end
190
+ ```
191
+
192
+ **Note:** Essentially `set_app_owner` has to return a class object *or* `nil`.
193
+
178
194
  ### View methods
179
195
 
180
196
  **`current_app`** Returns `App` object related to current session. Returns `nil` when the Rails is being used normally.
@@ -211,12 +227,10 @@ You can configure Native by passing a block to `configure`:
211
227
 
212
228
  ```ruby
213
229
  Native.configure do |config|
214
- config.devise_class = 'User'
230
+ config.android = true
215
231
  end
216
232
  ```
217
233
 
218
- **`devise_class`** Specify your devise class. Takes a string. Defaults to `'User'`.
219
-
220
234
  **`#{platform}`** Set to `false` to disable the platform. Takes a boolean. Defaults to `true`.
221
235
 
222
236
  **`#{platform}_url`** Specify the start url of your app on a given platform by passing a stringified route helper. Takes a string. Defaults to `'root_url'`.
@@ -245,6 +259,10 @@ Give the people some :heart: who are working on this project. See them all at:
245
259
 
246
260
  https://github.com/NativeGap/native-rails/graphs/contributors
247
261
 
262
+ ### Semantic Versioning
263
+
264
+ Native follows Semantic Versioning 2.0 as defined at http://semver.org.
265
+
248
266
  ## License
249
267
 
250
268
  MIT License
@@ -1,2 +1,7 @@
1
1
  class Native::ApplicationController < ActionController::Base
2
+
3
+ def set_app_owner
4
+ current_user if current_user
5
+ end
6
+
2
7
  end
@@ -60,7 +60,7 @@ module Native
60
60
  @app.platform = platform
61
61
  @app.url = url
62
62
  end
63
- @app.send( "#{Native.configuration.devise_class.downcase}=", send("current_#{Native.configuration.devise_class.downcase}") ) if send("current_#{Native.configuration.devise_class.downcase}")
63
+ @app.owner = ApplicationController.set_app_owner || set_app_owner
64
64
  @app.last_used = Time.now
65
65
  @app.save!
66
66
 
@@ -4,6 +4,6 @@ class Native::App < ActiveRecord::Base
4
4
 
5
5
  include Native::AppLib
6
6
 
7
- belongs_to Native.configuration.devise_class.downcase.to_sym, optional: true
7
+ belongs_to :owner, polymorphic: true, optional: true
8
8
 
9
9
  end
@@ -2,7 +2,7 @@ class NativeMigration < ActiveRecord::Migration<%= migration_version %>
2
2
  def change
3
3
  create_table :native_apps do |t|
4
4
 
5
- t.references Native.configuration.devise_class.downcase.to_sym, index: true
5
+ t.references :owner, polymorphic: true, index: true
6
6
 
7
7
  t.string :platform, index: true
8
8
  t.string :url, index: true
@@ -1,13 +1,5 @@
1
1
  Native.configure do |config|
2
2
 
3
- ### DEVISE ###
4
-
5
- # Specify your devise class. Defaults to `'User'`.
6
- # config.devise_class = 'User'
7
-
8
-
9
- ### CUSTOMIZATION ###
10
-
11
3
  # Specify platforms your app supports.
12
4
  # config.android = true
13
5
  # config.ios = true
@@ -1,7 +1,6 @@
1
1
  module Native
2
2
  class Configuration
3
3
 
4
- attr_accessor :devise_class
5
4
  attr_accessor :android
6
5
  attr_accessor :ios
7
6
  attr_accessor :uwp
@@ -23,7 +22,6 @@ module Native
23
22
  attr_accessor :scale_size
24
23
 
25
24
  def initialize
26
- @devise_class = 'User'
27
25
  @android = true
28
26
  @ios = true
29
27
  @uwp = true
@@ -1,5 +1,5 @@
1
1
  module Native
2
2
 
3
- VERSION = '1.0.0'
3
+ VERSION = '2.0.0'
4
4
 
5
5
  end
data/native.gemspec CHANGED
@@ -22,5 +22,4 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'bundler', '~> 1.16'
23
23
  gem.add_development_dependency 'rake', '~> 10.0'
24
24
  gem.add_dependency 'rails', '>= 5.0'
25
- gem.add_dependency 'devise', '~> 4.3'
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: native
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Hübotter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-20 00:00:00.000000000 Z
11
+ date: 2017-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
- - !ruby/object:Gem::Dependency
56
- name: devise
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4.3'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.3'
69
55
  description: Build native apps for all major platforms from your Rails applications.
70
56
  email: jonas.huebotter@gmail.com
71
57
  executables: []