mobilize-base 1.1.04 → 1.1.05

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.
@@ -153,7 +153,7 @@ module GoogleDrive
153
153
  else
154
154
  rem_v = rem_table[row_i][col_i]
155
155
  if loc_v != rem_v
156
- if ['true','false'].include?(loc_v.downcase)
156
+ if ['true','false'].include?(loc_v.to_s.downcase)
157
157
  #google sheet upcases true and false. ignore
158
158
  elsif loc_v.to_s.downcase.gsub("-","").gsub(" ","")==rem_v.to_s.downcase.gsub("-","").gsub(" ","")
159
159
  #supported currency, silently converted whether it's an actual currency or not
@@ -3,14 +3,13 @@ module Mobilize
3
3
  def Gbook.find_all_by_path(path,gdrive_slot)
4
4
  Gdrive.books(gdrive_slot,{"title"=>path,"title-exact"=>"true"})
5
5
  end
6
- def Gbook.find_or_create_by_path(path,gdrive_slot)
7
- books = Gdrive.books(gdrive_slot,{"title"=>path,"title-exact"=>"true"})
6
+ def Gbook.find_by_path(path,gdrive_slot)
7
+ books = Gbook.find_all_by_path(path,gdrive_slot)
8
8
  dst = Dataset.find_or_create_by_handler_and_path('gbook',path)
9
- #there should only be one book with each path, otherwise we have fail
10
9
  book = nil
11
10
  if books.length>1 and dst.http_url.to_s.length>0
12
- #some idiot process created a duplicate book.
13
- #Fix by renaming all but one with dst entry's key
11
+ #some idiot process or malicious user created a duplicate book.
12
+ #Fix by deleting all but the one with dst entry's key
14
13
  dkey = dst.http_url.split("key=").last
15
14
  books.each do |b|
16
15
  bkey = b.resource_id.split(":").last
@@ -23,8 +22,15 @@ module Mobilize
23
22
  end
24
23
  end
25
24
  else
25
+ #If it's a new dst or if there are multiple books
26
+ #take the first
26
27
  book = books.first
27
28
  end
29
+ return book
30
+ end
31
+ def Gbook.find_or_create_by_path(path,gdrive_slot)
32
+ book = Gbook.find_by_path(path,gdrive_slot)
33
+ dst = Dataset.find_or_create_by_handler_and_path('gbook',path)
28
34
  if book.nil?
29
35
  #always use owner email to make sure all books are owned by owner account
30
36
  book = Gdrive.root(Gdrive.owner_email).create_spreadsheet(path)
@@ -16,7 +16,7 @@ module Mobilize
16
16
 
17
17
  def Gsheet.find_by_path(path,gdrive_slot)
18
18
  book_path,sheet_name = path.split("/")
19
- book = Gdrive.books(gdrive_slot,{"title"=>book_path,"title-exact"=>"true"}).first
19
+ book = Gbook.find_by_path(book_path,gdrive_slot)
20
20
  return book.worksheet_by_title(sheet_name) if book
21
21
  end
22
22
 
@@ -119,8 +119,15 @@ module Mobilize
119
119
  :trigger => rj['trigger'])
120
120
  (1..5).to_a.each do |s_idx|
121
121
  stage_string = rj["stage#{s_idx.to_s}"]
122
- break if stage_string.to_s.length==0
123
- s = Stage.find_or_create_by_path("#{j.path}/stage#{s_idx.to_s}")
122
+ s = Stage.find_by_path("#{j.path}/stage#{s_idx.to_s}")
123
+ if stage_string.to_s.length==0
124
+ #delete this stage; user has blanked it
125
+ s.delete if s
126
+ break
127
+ elsif s.nil?
128
+ #create this stage
129
+ s = Stage.find_or_create_by_path("#{j.path}/stage#{s_idx.to_s}")
130
+ end
124
131
  #parse command string, update stage with it
125
132
  s_handler, call, param_string = [""*3]
126
133
  stage_string.split(" ").ie do |spls|
@@ -47,6 +47,11 @@ module Mobilize
47
47
  return s
48
48
  end
49
49
 
50
+ def Stage.find_by_path(path)
51
+ s = Stage.where(:path=>path).first
52
+ return s
53
+ end
54
+
50
55
  def prior
51
56
  s = self
52
57
  j = s.job
@@ -1,5 +1,5 @@
1
1
  module Mobilize
2
2
  module Base
3
- VERSION = "1.1.04"
3
+ VERSION = "1.1.05"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobilize-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.04
4
+ version: 1.1.05
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  segments:
241
241
  - 0
242
- hash: -2157829484572255156
242
+ hash: -938171999002513852
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements:
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  version: '0'
249
249
  segments:
250
250
  - 0
251
- hash: -2157829484572255156
251
+ hash: -938171999002513852
252
252
  requirements: []
253
253
  rubyforge_project: mobilize-base
254
254
  rubygems_version: 1.8.24