native 2.0.1 → 2.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: 4538b61237cafb2d12cab88c7b5899e9ec372bd435fc3074173600526f90a144
4
- data.tar.gz: f152537eaa655ae2d3e9f7b8bd45f5cef6732cb1fef1c7d84c6cb5ac7b8feacc
3
+ metadata.gz: adf08cc05c139ad102c40376c26a7aa4ba109d5560264bf11f47074b6acb0dac
4
+ data.tar.gz: 61bc8444e11fdfffc6121e795b76beeaf1599def2f6761e5ff06bb6f039be416
5
5
  SHA512:
6
- metadata.gz: 32b98ff9a526b4e7bd6033743963e88c31fc9f7b3984f071e4e1a0199ab87f5b6e7465c56c2631b9fe573e3eb699dab5931cfd9f4dd1c66653b40b02b3521f7a
7
- data.tar.gz: b3be9a4bebdb9d586a6ea5664ee7a6712269ac9448accd31a686768ccdfe6e47d345400aa3caf579d5c166a524df7296e8736bfdef9a33044ae239863709fe08
6
+ metadata.gz: cbd90a80e5dcb830be66244426b91536f5ba529676181a88c9cc2bf792d8b231ddd74a3fb19386e95d7cc2d90de314d0ec441ee85dd2303988134e6dfa63ad07
7
+ data.tar.gz: 57bc32905f7ad0c1758d3a6039a4f39d4cd153a5c3dd978a8d18e7711c8c2751797daf3076330836c0ea8edd1b7209138cb6d0a866d054794b0f9d8f8df1adea
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@
4
4
 
5
5
  * nothing yet
6
6
 
7
+ ### 2.1.0 - 2017-12-28
8
+
9
+ * features
10
+ * introduced `uses_native_apps` method to ActiveRecord models
11
+ * bugfixes
12
+ * fixed assets precompilation for native platforms
13
+
7
14
  ### 2.0.1 - 2017-12-21
8
15
 
9
16
  * bugfixes
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  git_source :github do |repo_name|
4
4
  "https://github.com/#{repo_name}"
data/INSTALL.md CHANGED
@@ -1,33 +1,10 @@
1
1
  **Thank you for installing Native!**
2
2
 
3
3
 
4
- There are three more steps to take:
4
+ There are two more steps to take:
5
5
 
6
6
  1) Run `rails g native` and `rails db:migrate`
7
- 2) Add to `assets/manifest.js`:
8
-
9
- //= link_directory ../native/android/javascripts .js
10
- //= link_directory ../native/android/stylesheets .css
11
- //= link_directory ../native/ios/javascripts .js
12
- //= link_directory ../native/ios/stylesheets .css
13
- //= link_directory ../native/uwp/javascripts .js
14
- //= link_directory ../native/uwp/stylesheets .css
15
- //= link_directory ../native/chrome/javascripts .js
16
- //= link_directory ../native/chrome/stylesheets .css
17
- //= link_directory ../native/osx/javascripts .js
18
- //= link_directory ../native/osx/stylesheets .css
19
- //= link_directory ../native/win32/javascripts .js
20
- //= link_directory ../native/win32/stylesheets .css
21
- //= link_directory ../native/win64/javascripts .js
22
- //= link_directory ../native/win64/stylesheets .css
23
- //= link_directory ../native/lin32/javascripts .js
24
- //= link_directory ../native/lin32/stylesheets .css
25
- //= link_directory ../native/lin64/javascripts .js
26
- //= link_directory ../native/lin64/stylesheets .css
27
- //= link_directory ../native/web/javascripts .js
28
- //= link_directory ../native/web/stylesheets .css
29
-
30
- 3) Mount engine in `config/routes.rb`:
7
+ 2) Mount engine in `config/routes.rb`:
31
8
 
32
9
  mount Native::Engine, at: '/native'
33
10
 
data/README.md CHANGED
@@ -78,35 +78,10 @@ To wrap things up, migrate the changes into your database:
78
78
 
79
79
  $ rails db:migrate
80
80
 
81
- Go to `app/assets/config/manifest.js` and add the following lines:
82
-
83
- ```js
84
- //= link_directory ../native/android/javascripts .js
85
- //= link_directory ../native/android/stylesheets .css
86
- //= link_directory ../native/ios/javascripts .js
87
- //= link_directory ../native/ios/stylesheets .css
88
- //= link_directory ../native/uwp/javascripts .js
89
- //= link_directory ../native/uwp/stylesheets .css
90
- //= link_directory ../native/chrome/javascripts .js
91
- //= link_directory ../native/chrome/stylesheets .css
92
- //= link_directory ../native/osx/javascripts .js
93
- //= link_directory ../native/osx/stylesheets .css
94
- //= link_directory ../native/win32/javascripts .js
95
- //= link_directory ../native/win32/stylesheets .css
96
- //= link_directory ../native/win64/javascripts .js
97
- //= link_directory ../native/win64/stylesheets .css
98
- //= link_directory ../native/lin32/javascripts .js
99
- //= link_directory ../native/lin32/stylesheets .css
100
- //= link_directory ../native/lin64/javascripts .js
101
- //= link_directory ../native/lin64/stylesheets .css
102
- //= link_directory ../native/web/javascripts .js
103
- //= link_directory ../native/web/stylesheets .css
104
- ```
105
-
106
81
  Let's move on to your devise class. For instance `User` located in `app/models/user.rb`. Associate belonging `App` objects:
107
82
 
108
83
  ```ruby
109
- has_many :apps, class_name: 'Native::App'
84
+ uses_native_apps
110
85
  ```
111
86
 
112
87
  Lastly, got to your routes file (`config/routes.rb`) and mount the `Native::Engine` class:
@@ -133,7 +108,7 @@ That's it!
133
108
 
134
109
  ### Assets
135
110
 
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.
111
+ With Native it is fairly simple to add platform specific stylesheets and scripts. In your assets directory you have a new folder for your `javascripts` and `stylesheets` (`app/assets/.../native`). In these two folders you are able to add custom assets for specific platforms including `web` specific assets.
137
112
 
138
113
  You simple have to include ...
139
114
 
@@ -141,11 +116,11 @@ You simple have to include ...
141
116
  = native_assets
142
117
  ```
143
118
 
144
- ... in the `head` tag of your layout.
119
+ ... in the `head` tag of your layout after your other asset include tags.
145
120
 
146
121
  ### App methods
147
122
 
148
- Native introduces an `App` activerecord model. Every object of your devise class can have multiple apps.
123
+ Native introduces an `App` ActiveRecord model. Every object of your devise class can have multiple apps.
149
124
 
150
125
  ```ruby
151
126
  a = App.first
@@ -203,7 +178,7 @@ If you want to use them in your controllers, just add `include NativeHelper` at
203
178
 
204
179
  ### Notifications
205
180
 
206
- You can enable native notifications on most platforms. To handle notifications Native integrates with thew [notifications-rails](https://github.com/jonhue/notifications-rails) gem.
181
+ You can enable native notifications on most platforms. To handle notifications Native integrates with the [notifications-rails](https://github.com/jonhue/notifications-rails) gem. Implement the [notification-pusher-onesignal](https://github.com/jonhue/notifications-rails/tree/master/notification-pusher/notification-pusher-onesignal) component to push notifications to your native applications.
207
182
 
208
183
  ### Content scaling (Android)
209
184
 
@@ -223,7 +198,7 @@ This will adjust the `font-size` of `:root`. The pixel value can be [configured]
223
198
 
224
199
  ## Configuration
225
200
 
226
- You can configure Native by passing a block to `configure`:
201
+ You can configure Native by passing a block to `configure`. This can be done in `config/initializers/native.rb`:
227
202
 
228
203
  ```ruby
229
204
  Native.configure do |config|
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ system 'bundle'
5
+ system 'gem build native.gemspec'
6
+
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task default: :spec
@@ -9,8 +9,8 @@ module NativeHelper
9
9
  end
10
10
 
11
11
  def native_assets
12
- stylesheet = stylesheet_link_tag "native/#{current_platform}/stylesheets/application", media: 'all', 'data-turbolinks-track': 'reload'
13
- javascript = javascript_include_tag "native/#{current_platform}/javascripts/application", 'data-turbolinks-track': 'reload'
12
+ stylesheet = stylesheet_link_tag "native/#{current_platform}", media: 'all', 'data-turbolinks-track': 'reload'
13
+ javascript = javascript_include_tag "native/#{current_platform}", 'data-turbolinks-track': 'reload'
14
14
  stylesheet.concat javascript
15
15
  end
16
16
 
@@ -26,26 +26,16 @@ class NativeGenerator < Rails::Generators::Base
26
26
  end
27
27
 
28
28
  def create_assets
29
- template 'application.css', 'app/assets/native/android/stylesheets/application.css'
30
- template 'application.js', 'app/assets/native/android/javascripts/application.js'
31
- template 'application.css', 'app/assets/native/ios/stylesheets/application.css'
32
- template 'application.js', 'app/assets/native/ios/javascripts/application.js'
33
- template 'application.css', 'app/assets/native/uwp/stylesheets/application.css'
34
- template 'application.js', 'app/assets/native/uwp/javascripts/application.js'
35
- template 'application.css', 'app/assets/native/chrome/stylesheets/application.css'
36
- template 'application.js', 'app/assets/native/chrome/javascripts/application.js'
37
- template 'application.css', 'app/assets/native/osx/stylesheets/application.css'
38
- template 'application.js', 'app/assets/native/osx/javascripts/application.js'
39
- template 'application.css', 'app/assets/native/win32/stylesheets/application.css'
40
- template 'application.js', 'app/assets/native/win32/javascripts/application.js'
41
- template 'application.css', 'app/assets/native/win64/stylesheets/application.css'
42
- template 'application.js', 'app/assets/native/win64/javascripts/application.js'
43
- template 'application.css', 'app/assets/native/lin32/stylesheets/application.css'
44
- template 'application.js', 'app/assets/native/lin32/javascripts/application.js'
45
- template 'application.css', 'app/assets/native/lin64/stylesheets/application.css'
46
- template 'application.js', 'app/assets/native/lin64/javascripts/application.js'
47
- template 'application.css', 'app/assets/native/web/stylesheets/application.css'
48
- template 'application.js', 'app/assets/native/web/javascripts/application.js'
29
+ create_assets_for 'android'
30
+ create_assets_for 'ios'
31
+ create_assets_for 'uwp'
32
+ create_assets_for 'chrome'
33
+ create_assets_for 'osx'
34
+ create_assets_for 'win32'
35
+ create_assets_for 'win64'
36
+ create_assets_for 'lin32'
37
+ create_assets_for 'lin64'
38
+ create_assets_for 'web'
49
39
  end
50
40
 
51
41
  def show_readme
@@ -60,4 +50,12 @@ class NativeGenerator < Rails::Generators::Base
60
50
  end
61
51
  end
62
52
 
53
+ def create_assets_for platform
54
+ @platform = platform
55
+ template 'application.css.erb', "app/assets/stylesheets/native/#{platform}.css"
56
+ template '.keep', "app/assets/stylesheets/native/#{platform}/.keep"
57
+ template 'application.js.erb', "app/assets/javascripts/native/#{platform}.js"
58
+ template '.keep', "app/assets/javascripts/native/#{platform}/.keep"
59
+ end
60
+
63
61
  end
File without changes
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Use this file to import your platform specific stylesheets.
3
3
  *
4
- *= require_tree .
4
+ *= require_tree ./<%= @platform %>
5
5
  *= require_self
6
6
  */
@@ -1,3 +1,3 @@
1
1
  // Use this file to require your platform specific javascript.
2
2
  //
3
- //= require_tree .
3
+ //= require_tree ./<%= @platform %>
@@ -1,4 +1,14 @@
1
1
  module Native
2
+
3
+ class << self
4
+ attr_accessor :configuration
5
+ end
6
+
7
+ def self.configure
8
+ self.configuration ||= Configuration.new
9
+ yield configuration
10
+ end
11
+
2
12
  class Configuration
3
13
 
4
14
  attr_accessor :android
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+
3
+ module Native
4
+ class Engine < ::Rails::Engine
5
+ # isolate_namespace Native
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Native
2
+ module Owner
3
+
4
+ def self.included base
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def uses_native_apps
10
+ has_many :apps, class_name: 'Native::App', as: :owner, dependent: :destroy
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'rails'
2
+
3
+ module Native
4
+ class Railtie < Rails::Railtie
5
+
6
+ initializer 'native.initialize' do
7
+ Rails.application.config.assets.precompile += %w( native/android.js native/ios.js native/uwp.js native/chrome.js native/osx.js native/win32.js native/win64.js native/lin32.js native/lin64.js native/web.js native/android.css native/ios.css native/uwp.css native/chrome.css native/osx.css native/win32.css native/win64.css native/lin32.css native/lin64.css native/web.css )
8
+
9
+ ActiveSupport.on_load :active_record do
10
+ include Native::Owner
11
+ end
12
+ end
13
+
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  module Native
2
2
 
3
- VERSION = '2.0.1'
3
+ VERSION = '2.1.0'
4
4
 
5
5
  end
data/lib/native.rb CHANGED
@@ -2,19 +2,11 @@ require 'native/version'
2
2
 
3
3
  module Native
4
4
 
5
- autoload :Configuration, 'native/configuration'
5
+ require 'native/configuration'
6
6
 
7
- class << self
8
- attr_accessor :configuration
9
- end
7
+ autoload :Owner, 'native/owner'
10
8
 
11
- def self.configure
12
- self.configuration ||= Configuration.new
13
- yield configuration
14
- end
15
-
16
- class Engine < ::Rails::Engine
17
- # isolate_namespace Native
18
- end
9
+ require 'native/engine'
10
+ require 'native/railtie'
19
11
 
20
12
  end
data/native.gemspec CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.required_ruby_version = '>= 2.3'
21
21
 
22
- gem.add_development_dependency 'bundler', '~> 1.16'
23
- gem.add_development_dependency 'rake', '~> 10.0'
24
22
  gem.add_dependency 'rails', '>= 5.0'
23
+
24
+ gem.add_development_dependency 'rspec', '~> 3.7'
25
+ gem.add_development_dependency 'rubocop', '~> 0.52'
25
26
  end
metadata CHANGED
@@ -1,57 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: native
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.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-21 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
19
+ version: '5.0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '3.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '3.7'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rails
42
+ name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
48
- type: :runtime
47
+ version: '0.52'
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '0.52'
55
55
  description: Build native apps for all major platforms from your Rails applications.
56
56
  email: jonas.huebotter@gmail.com
57
57
  executables: []
@@ -76,16 +76,19 @@ files:
76
76
  - app/helpers/native_helper.rb
77
77
  - app/models/concerns/native/app_lib.rb
78
78
  - config/routes.rb
79
- - init.rb
80
79
  - lib/generators/native_generator.rb
80
+ - lib/generators/templates/.keep
81
81
  - lib/generators/templates/README.md
82
82
  - lib/generators/templates/app_model.rb
83
- - lib/generators/templates/application.css
84
- - lib/generators/templates/application.js
83
+ - lib/generators/templates/application.css.erb
84
+ - lib/generators/templates/application.js.erb
85
85
  - lib/generators/templates/apps_migration.rb.erb
86
86
  - lib/generators/templates/initializer.rb
87
87
  - lib/native.rb
88
88
  - lib/native/configuration.rb
89
+ - lib/native/engine.rb
90
+ - lib/native/owner.rb
91
+ - lib/native/railtie.rb
89
92
  - lib/native/version.rb
90
93
  - native.gemspec
91
94
  - vendor/assets/javascripts/nativeScale.js.erb
@@ -97,33 +100,10 @@ post_install_message: |
97
100
  **Thank you for installing Native!**
98
101
 
99
102
 
100
- There are three more steps to take:
103
+ There are two more steps to take:
101
104
 
102
105
  1) Run `rails g native` and `rails db:migrate`
103
- 2) Add to `assets/manifest.js`:
104
-
105
- //= link_directory ../native/android/javascripts .js
106
- //= link_directory ../native/android/stylesheets .css
107
- //= link_directory ../native/ios/javascripts .js
108
- //= link_directory ../native/ios/stylesheets .css
109
- //= link_directory ../native/uwp/javascripts .js
110
- //= link_directory ../native/uwp/stylesheets .css
111
- //= link_directory ../native/chrome/javascripts .js
112
- //= link_directory ../native/chrome/stylesheets .css
113
- //= link_directory ../native/osx/javascripts .js
114
- //= link_directory ../native/osx/stylesheets .css
115
- //= link_directory ../native/win32/javascripts .js
116
- //= link_directory ../native/win32/stylesheets .css
117
- //= link_directory ../native/win64/javascripts .js
118
- //= link_directory ../native/win64/stylesheets .css
119
- //= link_directory ../native/lin32/javascripts .js
120
- //= link_directory ../native/lin32/stylesheets .css
121
- //= link_directory ../native/lin64/javascripts .js
122
- //= link_directory ../native/lin64/stylesheets .css
123
- //= link_directory ../native/web/javascripts .js
124
- //= link_directory ../native/web/stylesheets .css
125
-
126
- 3) Mount engine in `config/routes.rb`:
106
+ 2) Mount engine in `config/routes.rb`:
127
107
 
128
108
  mount Native::Engine, at: '/native'
129
109
 
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'native'