fruit_to_lime 2.5.5 → 2.5.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/lib/fruit_to_lime.rb +17 -17
  2. data/lib/fruit_to_lime/csv_helper.rb +47 -47
  3. data/lib/fruit_to_lime/email_helper.rb +10 -10
  4. data/lib/fruit_to_lime/errors.rb +16 -16
  5. data/lib/fruit_to_lime/excel_helper.rb +10 -10
  6. data/lib/fruit_to_lime/global_phone.json +6571 -6571
  7. data/lib/fruit_to_lime/model/address.rb +60 -60
  8. data/lib/fruit_to_lime/model/class_settings.rb +50 -50
  9. data/lib/fruit_to_lime/model/coworker.rb +76 -76
  10. data/lib/fruit_to_lime/model/coworker_reference.rb +33 -33
  11. data/lib/fruit_to_lime/model/customfield.rb +87 -87
  12. data/lib/fruit_to_lime/model/deal.rb +141 -141
  13. data/lib/fruit_to_lime/model/deal_status.rb +12 -12
  14. data/lib/fruit_to_lime/model/note.rb +80 -79
  15. data/lib/fruit_to_lime/model/organization.rb +203 -203
  16. data/lib/fruit_to_lime/model/person.rb +151 -151
  17. data/lib/fruit_to_lime/model/referencetosource.rb +45 -45
  18. data/lib/fruit_to_lime/model/relation.rb +23 -23
  19. data/lib/fruit_to_lime/model/rootmodel.rb +342 -338
  20. data/lib/fruit_to_lime/model/settings.rb +60 -60
  21. data/lib/fruit_to_lime/model/tag.rb +35 -35
  22. data/lib/fruit_to_lime/model_helpers.rb +54 -54
  23. data/lib/fruit_to_lime/phone_helper.rb +74 -74
  24. data/lib/fruit_to_lime/roo_helper.rb +72 -72
  25. data/lib/fruit_to_lime/serialize_helper.rb +186 -186
  26. data/lib/fruit_to_lime/templating.rb +52 -52
  27. data/spec/address_spec.rb +48 -48
  28. data/spec/class_settings_spec.rb +37 -37
  29. data/spec/coworker_spec.rb +94 -94
  30. data/spec/custom_field_spec.rb +22 -22
  31. data/spec/deal_spec.rb +101 -101
  32. data/spec/helpers/csv_helper_spec.rb +29 -29
  33. data/spec/helpers/email_helper_spec.rb +32 -32
  34. data/spec/helpers/phone_helper_spec.rb +97 -97
  35. data/spec/helpers/serialize_helper_spec.rb +249 -249
  36. data/spec/helpers/xsd_validate_spec.rb +58 -58
  37. data/spec/note_spec.rb +98 -98
  38. data/spec/organization_spec.rb +103 -103
  39. data/spec/person_spec.rb +134 -134
  40. data/spec/rootmodel_spec.rb +306 -277
  41. data/spec/templating_spec.rb +11 -11
  42. data/templates/csv/lib/tomodel.rb +230 -230
  43. data/templates/csv/spec/exporter_spec.rb +17 -17
  44. data/templates/csv/spec/sample_data/coworkers.csv +2 -2
  45. data/templates/csv/spec/sample_data/deals.csv +2 -2
  46. data/templates/csv/spec/sample_data/organizations.csv +2 -2
  47. data/templates/csv/spec/sample_data/persons.csv +2 -2
  48. data/templates/easy/Gemfile +5 -5
  49. data/templates/easy/Rakefile.rb +7 -7
  50. data/templates/easy/convert.rb +2 -2
  51. data/templates/easy/spec/exporter_spec.rb +10 -10
  52. data/templates/easy/spec/spec_helper.rb +24 -24
  53. data/templates/excel/lib/tomodel.rb +207 -207
  54. data/templates/sqlserver/lib/tomodel.rb +79 -79
  55. metadata +3 -3
@@ -1,79 +1,79 @@
1
- require 'fruit_to_lime'
2
- require 'roo'
3
- require 'date'
4
-
5
- class ToModel
6
- def to_organization(row)
7
- organization = FruitToLime::Organization.new()
8
- organization.integration_id = row['id']
9
- organization.name = row['name']
10
- return organization
11
- end
12
-
13
- def configure(model)
14
- # add custom field to your model here. Custom fields can be
15
- # added to organization, deal and person. Valid types are
16
- # :String and :Link. If no type is specified :String is used
17
- # as default.
18
-
19
- model.settings.with_deal do |deal|
20
- deal.set_custom_field( { :integrationid => 'discount_url', :title => 'Rabatt url', :type => :Link } )
21
- end
22
- end
23
-
24
- def to_model(organization_rows)
25
- model = FruitToLime::RootModel.new
26
- configure model
27
-
28
- organization_rows.each do |row|
29
- model.organizations.push(to_organization(row))
30
- end
31
-
32
- return model
33
- end
34
- end
35
-
36
- require "thor"
37
- require "fileutils"
38
- require 'pathname'
39
- require 'tiny_tds'
40
-
41
- class Cli < Thor
42
- desc "to_go", "Connects to sql server and queries for organizations to Go xml format. HOST, DATABASE, USERNAME and PASSWORD for Sql server connection. FILE is output file where Go xml will go."
43
- def to_go(host, database, username, password, file = nil)
44
- puts "Connecting to database #{database} on server #{host} as user #{username}"
45
- client = TinyTds::Client.new(
46
- :username => username,
47
- :password => password,
48
- :host => host,
49
- :database => database)
50
-
51
- organizationSql =
52
- "SELECT
53
- c.id,
54
- c.name,
55
- FROM
56
- company c"
57
-
58
- organization_rows = client.execute(organizationSql)
59
-
60
- file = 'export.xml' if file == nil
61
- tomodel = ToModel.new()
62
- model = tomodel.to_model(organization_rows)
63
- error = model.sanity_check
64
- if error.empty?
65
- validation_errors = model.validate
66
-
67
- if validation_errors.empty?
68
- model.serialize_to_file(file)
69
- puts "'#{organizations}' has been converted into '#{file}'."
70
- else
71
- puts "'#{organizations}' could not be converted due to"
72
- puts validation_errors
73
- end
74
- else
75
- puts "'#{organizations}' could not be converted due to"
76
- puts error
77
- end
78
- end
79
- end
1
+ require 'fruit_to_lime'
2
+ require 'roo'
3
+ require 'date'
4
+
5
+ class ToModel
6
+ def to_organization(row)
7
+ organization = FruitToLime::Organization.new()
8
+ organization.integration_id = row['id']
9
+ organization.name = row['name']
10
+ return organization
11
+ end
12
+
13
+ def configure(model)
14
+ # add custom field to your model here. Custom fields can be
15
+ # added to organization, deal and person. Valid types are
16
+ # :String and :Link. If no type is specified :String is used
17
+ # as default.
18
+
19
+ model.settings.with_deal do |deal|
20
+ deal.set_custom_field( { :integrationid => 'discount_url', :title => 'Rabatt url', :type => :Link } )
21
+ end
22
+ end
23
+
24
+ def to_model(organization_rows)
25
+ model = FruitToLime::RootModel.new
26
+ configure model
27
+
28
+ organization_rows.each do |row|
29
+ model.organizations.push(to_organization(row))
30
+ end
31
+
32
+ return model
33
+ end
34
+ end
35
+
36
+ require "thor"
37
+ require "fileutils"
38
+ require 'pathname'
39
+ require 'tiny_tds'
40
+
41
+ class Cli < Thor
42
+ desc "to_go", "Connects to sql server and queries for organizations to Go xml format. HOST, DATABASE, USERNAME and PASSWORD for Sql server connection. FILE is output file where Go xml will go."
43
+ def to_go(host, database, username, password, file = nil)
44
+ puts "Connecting to database #{database} on server #{host} as user #{username}"
45
+ client = TinyTds::Client.new(
46
+ :username => username,
47
+ :password => password,
48
+ :host => host,
49
+ :database => database)
50
+
51
+ organizationSql =
52
+ "SELECT
53
+ c.id,
54
+ c.name,
55
+ FROM
56
+ company c"
57
+
58
+ organization_rows = client.execute(organizationSql)
59
+
60
+ file = 'export.xml' if file == nil
61
+ tomodel = ToModel.new()
62
+ model = tomodel.to_model(organization_rows)
63
+ error = model.sanity_check
64
+ if error.empty?
65
+ validation_errors = model.validate
66
+
67
+ if validation_errors.empty?
68
+ model.serialize_to_file(file)
69
+ puts "'#{organizations}' has been converted into '#{file}'."
70
+ else
71
+ puts "'#{organizations}' could not be converted due to"
72
+ puts validation_errors
73
+ end
74
+ else
75
+ puts "'#{organizations}' could not be converted due to"
76
+ puts error
77
+ end
78
+ end
79
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fruit_to_lime
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.5
4
+ version: 2.5.6
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-06-25 00:00:00.000000000 Z
15
+ date: 2014-06-26 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: iso_country_codes
@@ -263,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
263
  version: '0'
264
264
  requirements: []
265
265
  rubyforge_project:
266
- rubygems_version: 1.8.28
266
+ rubygems_version: 1.8.24
267
267
  signing_key:
268
268
  specification_version: 3
269
269
  summary: Library to generate Lime Go xml import format