phonegap-rails 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjJiNzQ1MjBlNGZhZmEwNTIyY2E2MjJjNWJkYTdlODRlNTNkYTdlZA==
4
+ YTI1MzA5MGViMTRjMDY2M2VkZDQ4YmM3ZTUyM2JhNTc1ZjY2OTdjOA==
5
5
  data.tar.gz: !binary |-
6
- M2E1ZjliMjViYTA4NGQ5MmQzNTY5N2RlYjkyMGY5ZGUyYTZiY2EyZg==
6
+ MWUwYWUzNzc3NjAzY2YzMTFkNDQxZTMzNzg1OWQ2NGJmYjc2ZDM2OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmI1NzkzMjdiM2Y2NzRhN2I5NGUwYzk4ODgwM2UyOTQ1ZGVjOGQ4ZWEwNTJh
10
- ODQ4OWJjMDI5MTU1ODJjMTUxMzZjYzY0N2Q3N2RlYTQ3ODg5MDY4NDk1ZTQ3
11
- MjZhMTU3ZGQ4MzUyZTU3OTZlYjlkMmMwODk1OTA5ZTg4YTU0Y2M=
9
+ NjNiNDIxMmIxMjkzYTY1MmNjNTc4YTJmZDcxYjdiYjQ0MWNmNjk0NmY4M2Rl
10
+ YjNhNzgxMDhlNDdjYTEwY2JhMmQ0NmFlOTgzYTRkMjc3OGU1NzhlNGU2ZmJi
11
+ M2Q1YzM5ZmJkNjc1NDY1NmVlN2Q1YTU2YjdhNDc3NTFhZmVhZjU=
12
12
  data.tar.gz: !binary |-
13
- MzJkNTNkMGVmYTNhZWZlMGM5MjI2ODlhNmI4YzhiOWRiOTZhYTVjZGRkYTc3
14
- ZDRhMTEzZTA4YzFmYTk1NzhlNjJiMzYxNTA0MTQ3MGM3Yzk3YzEwYjY3YTA3
15
- Y2M4NGU1ODBkZWY2OWRhYjdhZjE0NWEwMzUwYjRjNWMxZDczNWM=
13
+ YWMwM2E3OTViZjQ4OGFjYmVmMTU0OGQ5MzdlMzU2MzI1NTUzMjc3YjI4YWZm
14
+ YmFhZDU5NWZlOGY5ZjcwZjQ2MGRiNmQwNmYxOTUxYjMwNjU4MThkYTdhYTA2
15
+ OTZjNmNlM2IyZjBmN2Q3ZDIwNTE3YWRmMDIzZGNiMDIyNDBjNWQ=
@@ -1,9 +1,9 @@
1
1
  ##
2
- ## general settings
2
+ ## General settings
3
3
  ##
4
- #phonegap_path: '~/Development/phonegap-2.6.0'
5
- #api_server: 'http://example.com'
6
- #
7
- ## android settings
4
+ #phonegap_path: '~/Development/phonegap-2.6.0'
5
+ #api_server: 'http://example.com'
6
+
7
+ ## Android settings
8
8
  #android:
9
- # package: 'com.example.appname'
9
+ # package: 'com.example.appname'
@@ -37,16 +37,19 @@ namespace :phonegap do
37
37
  desc 'export application assets to android phonegap project'
38
38
  task :export => :environment do
39
39
  puts "Exporting android project"
40
- environment = Rails.application.assets
40
+ environment = Rails.application.assets
41
+ ## Export js assets
41
42
  puts '* javascript assets'
42
43
  file = File.open("#{project_path}/assets/www/js/application.js", "w")
43
44
  file.write environment['application.js']
44
45
  file.close
46
+ ## Export css assets
45
47
  puts '* css assets'
46
48
  file = File.open("#{project_path}/assets/www/css/application.css", "w")
47
49
  file.write environment['application.css']
48
50
  file.close
49
- puts '* other assets (images and fonts)'
51
+ ## Export images and fonts
52
+ puts '* images and fonts'
50
53
  FileUtils.mkdir_p "#{project_path}/assets/www/assets"
51
54
  other_paths = Rails.configuration.assets.paths.select {|x| x =~ /\/fonts$|\/images$/}
52
55
  other_paths.each do |path|
@@ -55,6 +58,7 @@ namespace :phonegap do
55
58
  FileUtils.cp file, "#{project_path}/assets/www/assets"
56
59
  end
57
60
  end
61
+ ## Export public folder
58
62
  puts '* public folder'
59
63
  FileUtils.cp_r 'public/.', "#{project_path}/assets/www/"
60
64
  puts '* index.html'
@@ -63,8 +67,8 @@ namespace :phonegap do
63
67
  file = File.open("#{project_path}/assets/www/index.html", "w")
64
68
  file.write ERB.new(File.read("#{public_source}/android_index.html.erb")).result
65
69
  file.close
66
-
67
- puts '* fix relative paths'
70
+ ## Fix relative paths and configure API server
71
+ puts 'Fix relative paths'
68
72
  css_file_path = "#{project_path}/assets/www/css/application.css"
69
73
  css_file = File.read(css_file_path)
70
74
  new_css_file = css_file.gsub(/\/assets/, '../assets')
@@ -77,7 +81,23 @@ namespace :phonegap do
77
81
  if api_server.blank?
78
82
  puts "Warning: No API server is specified for this app"
79
83
  else
80
- new_js_file = new_js_file.gsub(/href=\\"\//, 'href=\"'+api_server+'/')
84
+ if new_js_file =~ /href=\\"\//
85
+ puts "Relative paths found. Making absolute to reference API: #{api_server}"
86
+ new_js_file.gsub!(/href=\\"\//, 'href=\"'+api_server+'/')
87
+ end
88
+ if new_js_file =~ /ember/
89
+ if new_js_file =~ /DS\.Store\.extend/ and (
90
+ new_js_file =~ /RESTAdapter/ or
91
+ not new_js_file =~ /DS\.Store\.extend.*\(.*\{.*adapter:.*\}.*\)/mx
92
+ )
93
+ puts "ember.js RESTAdapter found. Adding API url #{api_server} to RESTAdapter"
94
+ new_js_file << "\nDS.RESTAdapter.reopen({url: '#{api_server}'});//Added phonegap-rails"
95
+ end
96
+ if new_js_file =~ /(Auth\.Config\.reopen[^\(\{]*\([^\(\{]*\{)/mx
97
+ puts "ember-auth found. Adding API baseUrl: #{api_server}"
98
+ new_js_file.sub!(/(Auth\.Config\.reopen[^\(\{]*\([^\(\{]*\{)/mx,"#{$1}\n\tbaseUrl: '#{api_server}',//Added phonegap-rails")
99
+ end
100
+ end
81
101
  end
82
102
  file = File.open(js_file_path, "w")
83
103
  file.puts new_js_file
@@ -1,5 +1,5 @@
1
1
  module Phonegap
2
2
  module Rails
3
- VERSION = "0.0.7"
3
+ VERSION = "0.0.8"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonegap-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Casals
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-26 00:00:00.000000000 Z
11
+ date: 2013-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Export a rails single page app as a Phonegap project
14
14
  email: