simpex 0.0.1 → 0.0.2

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.
@@ -52,7 +52,7 @@ class TypeEntry
52
52
 
53
53
  def set(key, value)
54
54
  if value.kind_of?(Array)
55
- @values[key] = value.reject{|v| v.nil? || v.empty? }.join(",")
55
+ @values[key] = value.reject{|v| v.nil?}.join(",")
56
56
  else
57
57
  @values[key] = value
58
58
  end
@@ -1,4 +1,4 @@
1
1
  module Simpex
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
4
4
 
data/readme.textile CHANGED
@@ -12,7 +12,6 @@ Simpex will make your life easier because:
12
12
  * generate the right files names with right index numbers so hyris can process them in the right order
13
13
  * simpex is bullet proof and was used and developed for a huge ecommerce project in cooperation with namics.com
14
14
 
15
-
16
15
  Ready? Here it comes:
17
16
 
18
17
  product_type = Type.new("Product", %w{code[unique=true] name[lang=en] name[lang=de] unit(code) $catalogVersion supercategories(code)})
@@ -20,13 +19,10 @@ product_type = Type.new("Product", %w{code[unique=true] name[lang=en] name[lang=
20
19
  product = TypeEntry.new(product_type, %w{555 myproduct555 meinproduct555 pieces SimpexProducts:Online SampleCategory})
21
20
 
22
21
  assert_equal "555", product.code
23
-
24
22
  assert_equal "pieces", product.unit
25
-
26
23
  assert_equal "SampleCategory", product.supercategories
27
24
 
28
25
 
29
-
30
26
  Never worry about the order of rows any more just create a hash specifying the attributes:
31
27
 
32
28
  product2 = TypeEntry.new(product_type, {"code" => "333", "name" => "MyName"})
@@ -34,35 +30,30 @@ product2 = TypeEntry.new(product_type, {"code" => "333", "name" => "MyName"})
34
30
 
35
31
  Just use full string attribute names for ambigious attributes like
36
32
 
37
-
38
33
  assert_equal "myproduct555", product.get("name[lang=en]")
39
-
40
34
  assert_equal "meinproduct555", product.get("name[lang=de]")
41
35
 
42
36
 
43
37
  Now lets build some real references:
44
38
 
45
39
  catalog_type = Type.new("Catalog", %w{id[unique=true] name[lang=de] name[lang=en] defaultCatalog})
40
+ #now create a catalog, by giving the type 'catalog_type' to the constructor, it will be registered for the future generation
46
41
  catalog = TypeEntry.new(catalog_type, %w{simpex_catalog SimpexCatalog SimpexCatalog true})
47
42
 
48
43
  catalog_version_type = Type.new("CatalogVersion", %w{catalog(id)[unique=true] version[unique=true] active defaultCurrency(isocode)})
49
44
  catalog_version = TypeEntry.new(catalog_version_type, [catalog.id, "online", "true", "EUR", "de,en"])
50
45
 
51
-
52
46
  Now add averything to a main object managing the files creation:
53
-
54
47
  result = ImpexResult.new("your/impex/folder")
55
48
 
56
- catalog_type << catalog
57
- product_type << product
58
-
49
+ #Each type, containts all the entries for this type, so entries are listed there for generation, now you just have to add the types to the result
59
50
  result << catalog_type
60
51
  result << product_type
61
52
 
53
+ #now lets generated the result, memory leaks will be avoiaded by not exeeding more than 2000 entries in a type
62
54
  result.impexify # => will write separate files for each type
63
55
  result.impexify("basic_setup.csv") # => will write all tables to one file in the folder your/impex/folder
64
56
 
65
-
66
57
  Thats it!
67
58
 
68
59
  h2. Setup
data/simpex-0.0.1.gem ADDED
Binary file
data/test/test_type.rb CHANGED
@@ -39,14 +39,14 @@ class TestType < Test::Unit::TestCase
39
39
  end
40
40
 
41
41
  def test_shoud_add_an_after_each_statement
42
- bash_script = "#%afterEach: "
43
- after_each = "impex.getLastImportedItem().setApprovalStatus(impex.getLastImportedItem().getBaseProduct().getApprovalStatus());"
44
- product_type = Type.new("Product", %w{code[unique=true] name[lang=en]})
45
- TypeEntry.new(product_type,%w{ 666 denis})
46
- product_type.after_each << after_each
47
- assert_match /impex/, product_type.after_each.first
48
- assert_match /#%afterEach/, product_type.to_imp
49
- puts product_type.to_imp
42
+ bash_script = "#%afterEach: "
43
+ after_each = "impex.getLastImportedItem().setApprovalStatus(impex.getLastImportedItem().getBaseProduct().getApprovalStatus());"
44
+ product_type = Type.new("Product", %w{code[unique=true] name[lang=en]})
45
+ TypeEntry.new(product_type,%w{ 666 denis})
46
+ product_type.after_each << after_each
47
+ assert_match /impex/, product_type.after_each.first
48
+ assert_match /#%afterEach/, product_type.to_imp
49
+ puts product_type.to_imp
50
50
  end
51
51
 
52
52
  def test_type_should_generate_nothing_if_no_entries
@@ -65,6 +65,11 @@ class TestType < Test::Unit::TestCase
65
65
  end
66
66
  end
67
67
 
68
+ def test_entry_should_handle_array_containnig_specific_types
69
+ some_type = Type.new('SomeType', %w{code some_list_attribute})
70
+ entry = TypeEntry.new(some_type, ["66", [1,2,3,4]])
71
+ end
72
+
68
73
  def test_entry_should_reference_other_entries
69
74
  entry = TypeEntry.new(@product_type, {"code" => "333", "name[lang=en]" => "MyName"})
70
75
  @product_type << entry
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
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: 2011-11-17 00:00:00.000000000Z
12
+ date: 2012-07-19 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Read more details at the homepage https://github.com/denislutz/simpex
15
15
  email:
@@ -31,6 +31,7 @@ files:
31
31
  - lib/simpex/type_entry.rb
32
32
  - lib/simpex/version.rb
33
33
  - readme.textile
34
+ - simpex-0.0.1.gem
34
35
  - simpex.gemspec
35
36
  - test/test_result.rb
36
37
  - test/test_rich_types.rb