fiveapples 0.0.3 → 0.0.4

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: 05df5643157a04c97182a2a9eac30c3242ef7f8d6d6c885e03623474f5199c3c
4
- data.tar.gz: 5a48a02e003a73be836a4a937596d0f9d11952de9f9e508cb9cbf60c152dd081
3
+ metadata.gz: 8e515423afa398eb0c84bcde4011e6d8e0c1956abe7e560eae16dbf7227ebb74
4
+ data.tar.gz: 7785ce629615f46dd99fd292dcecdcd92a26b0ce256f4edb01eae718e6da32d5
5
5
  SHA512:
6
- metadata.gz: c86fef213d70285c8a9d57353f4139f43cbd11f6deaf1710cf70038e79e37ba22f373cfc7b8a6f08eb31b9b7ee420da90270226161208eac12ab0e713c67f092
7
- data.tar.gz: cfcd6121376e7713487e1d01c106db1e011c635ecafe40ebb95d6417ceec6566d87133cf6022d2e3aaaa8458f3a1c928d25b68d7d8c7e0c8f68a1664b05d6fbd
6
+ metadata.gz: 858a88008a5b520f052cb2083b5bd68ec66b9f2b66f14a937144f96a2f010d4a387503a8f332af9b85d80220f49b0a78b157accb1e9399bdde3e43619f790cd4
7
+ data.tar.gz: e9814e215c62e5d79237195ecaff7517d9781b2a429231225e7e1e0b5b68c337d13c84ca5802d7c33ce77d3b98df9e5f1e98e328da5468bd8916ee5a1bc3c0ff
@@ -6,6 +6,27 @@ require_relative './model.rb'
6
6
 
7
7
  require 'rack/logger'
8
8
 
9
+ # simple redirect middleware for doing / => /ui5/index.html
10
+
11
+ module FiveApples
12
+ class Redirect
13
+ def initialize(app, options={})
14
+ @app = app
15
+ @map = options
16
+ end
17
+ def call(env)
18
+ if @map.has_key?(pi = env['PATH_INFO'])
19
+ destination = "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{@map[pi]}"
20
+ destination << "?#{qs}" unless (qs=env['QUERY_STRING']).empty?
21
+ [301, {'Location' => destination}, ['See Ya!']]
22
+ else
23
+ @app.call(env)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+
9
30
  fiveapples = Rack::OData::Builder.new do
10
31
 
11
32
  use Rack::Cors do
@@ -20,10 +41,20 @@ fiveapples = Rack::OData::Builder.new do
20
41
  use Rack::CommonLogger
21
42
  use Rack::ShowExceptions
22
43
 
23
- # Serve the ui5 app
24
- use Rack::Static, :urls => ["/ui5"]
25
44
 
26
- # Serve the OData
45
+ # Serve the ui5 app
46
+
47
+ # redirect / to /ui5/index.html
48
+ # Note: We need this because serving / with /ui5/index.html content does not work
49
+ # as is produces follow-up javascript resource requests like "/Component.js"
50
+ # outside of ui5 directory and it gives NOT FOUND
51
+ use FiveApples::Redirect, {'/' => '/ui5/index.html',
52
+ '/ui5' => '/ui5/index.html'}
53
+
54
+ use Rack::Static, :urls => ['/ui5']
55
+
56
+
57
+ # Serve the OData (prefixed /odata )
27
58
  run ODataFiveApples.new
28
59
 
29
60
  end
@@ -3,44 +3,47 @@
3
3
  require 'safrano.rb'
4
4
  require 'sequel'
5
5
  require 'fileutils'
6
-
7
- class FiveApples
8
- CONFIGDIRNAME = 'fiveapples'.freeze
9
- DBFILENAME = 'fiveapples.db3'.freeze
10
- CONFIGRU = 'config5.ru'
11
-
12
- attr_reader :db
13
-
14
- def initialize
15
- gconfigdir = File.expand_path('.config', Dir.home)
16
- @apphome = File.expand_path(CONFIGDIRNAME, gconfigdir)
17
- @libdir = __dir__.dup
18
- @systemdbname = File.join(@libdir, DBFILENAME)
19
- @homedbname = File.expand_path(DBFILENAME, @apphome)
20
- @configru = File.expand_path(CONFIGRU, @libdir)
21
- end
22
-
23
- def setup_db_in_homedir
24
- FileUtils.mkdir_p(@apphome) unless Dir.exist?(@apphome)
25
- FileUtils.cp(@systemdbname, @homedbname) unless File.exist?(@homedbname)
26
- end
27
-
28
- def startdb
29
- setup_db_in_homedir
30
-
31
- @db = Sequel::Model.db = Sequel.sqlite(@homedbname)
32
-
33
- Kernel.at_exit { Sequel::Model.db.disconnect if Sequel::Model.db }
34
-
35
- end
36
-
37
- def serve
38
-
39
- Dir.chdir @libdir
40
- exec "rackup -I#{@libdir} #{@configru}"
41
-
6
+ require_relative 'version'
7
+
8
+ module FiveApples
9
+ class Server
10
+ CONFIGDIRNAME = 'fiveapples'.freeze
11
+ DBFILENAME = 'fiveapples.db3'.freeze
12
+ CONFIGRU = 'config5.ru'
13
+
14
+ attr_reader :db
15
+
16
+ def initialize
17
+ gconfigdir = File.expand_path('.config', Dir.home)
18
+ @apphome = File.expand_path(CONFIGDIRNAME, gconfigdir)
19
+ @libdir = __dir__.dup
20
+ @systemdbname = File.join(@libdir, DBFILENAME)
21
+ @homedbname = File.expand_path(DBFILENAME, @apphome)
22
+ @configru = File.expand_path(CONFIGRU, @libdir)
23
+ end
24
+
25
+ def setup_db_in_homedir
26
+ FileUtils.mkdir_p(@apphome) unless Dir.exist?(@apphome)
27
+ FileUtils.cp(@systemdbname, @homedbname) unless File.exist?(@homedbname)
28
+ end
29
+
30
+ def startdb
31
+ setup_db_in_homedir
32
+
33
+ @db = Sequel::Model.db = Sequel.sqlite(@homedbname)
34
+
35
+ Kernel.at_exit { Sequel::Model.db.disconnect if Sequel::Model.db }
36
+
37
+ end
38
+
39
+ def serve
40
+
41
+ Dir.chdir @libdir
42
+ puts "Fiveapples version #{FiveApples::VERSION}"
43
+ exec "rackup -I#{@libdir} #{@configru}"
44
+
45
+ end
46
+
42
47
  end
43
-
44
48
  end
45
-
46
- FiveA = FiveApples.new
49
+ FiveA = FiveApples::Server.new
@@ -31,7 +31,8 @@ sap.ui.define([
31
31
  _that.byId('year').setValue("");
32
32
  _that.byId('breeder_id').setValue("");
33
33
  MessageToast.show("Create success");
34
- _that._oRouter.navTo( "cultivar_detail", {id: data.id} );
34
+ // TODO: isnt this data access OData version dependant?
35
+ _that._oRouter.navTo( "cultivar_detail", {id: data["results"]["0"].id} );
35
36
  }
36
37
  function onErrorHandler(){
37
38
  MessageToast.show("Create failed"); }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FiveApples
4
+ VERSION = '0.0.4'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fiveapples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - D.M.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-16 00:00:00.000000000 Z
11
+ date: 2020-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safrano
@@ -118,6 +118,7 @@ files:
118
118
  - lib/ui5/view/ParentageList.view.xml
119
119
  - lib/ui5/view/Parentage_Create.view.xml
120
120
  - lib/ui5/view/Parentage_Detail.view.xml
121
+ - lib/version.rb
121
122
  homepage: https://gitlab.com/dm0da/fiveapples
122
123
  licenses:
123
124
  - MIT