go_import 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/go_import/model/file.rb +30 -7
  2. metadata +2 -2
@@ -7,11 +7,13 @@ require_relative '../serialize_helper'
7
7
  module GoImport
8
8
  class File
9
9
  include SerializeHelper
10
- attr_accessor :id, :integration_id, :path, :description
10
+ attr_accessor :id, :integration_id, :description
11
11
 
12
12
  attr_reader :organization, :created_by, :deal
13
13
 
14
- attr_writer :name
14
+ attr_reader :path
15
+
16
+ attr_reader :name
15
17
 
16
18
  # zip_path is used internally when the file is stored in the
17
19
  # zip file that is sent to LIME Go. You should not modify this
@@ -45,14 +47,31 @@ module GoImport
45
47
  ]
46
48
  end
47
49
 
48
- def name
50
+ def path=(path)
51
+ @path = path
52
+
53
+ # when path is set, we should set the name to the path's
54
+ # filename if name is NOT set already
55
+
56
+ # Hm. this might introduce a bug if we set path twice and
57
+ # never explicity set the name (it will get the name of
58
+ # the first file)
59
+
60
+ if (@name.nil? || @name.empty?) && (!@path.nil? && !@path.empty?)
61
+ @name = Pathname.new(path).basename.to_s
62
+ end
63
+ end
64
+
65
+ def name=(name)
66
+ @name = name
67
+
68
+ # a file must have a name, hence this.
69
+
49
70
  if @name.nil? || @name.empty?
50
- if !@path.nil?
51
- return Pathname.new(path).basename.to_s
71
+ if !@path.nil? && !@path.empty?
72
+ @name = Pathname.new(@path).basename.to_s
52
73
  end
53
74
  end
54
-
55
- return @name
56
75
  end
57
76
 
58
77
  def has_relative_path?()
@@ -94,6 +113,10 @@ module GoImport
94
113
  end
95
114
  end
96
115
 
116
+ if @name.nil? || @name.empty?
117
+ error = "#{error}A file must have a name.\n"
118
+ end
119
+
97
120
  if @created_by.nil?
98
121
  error = "#{error}Created_by is required for file.\n"
99
122
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-09-16 00:00:00.000000000 Z
15
+ date: 2014-09-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes