datashift 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/Rakefile +6 -1
  2. data/VERSION +1 -1
  3. data/datashift.gemspec +13 -6
  4. data/lib/datashift.rb +2 -20
  5. data/lib/datashift/exceptions.rb +2 -0
  6. data/lib/datashift/method_detail.rb +15 -29
  7. data/lib/datashift/method_dictionary.rb +36 -21
  8. data/lib/datashift/method_mapper.rb +56 -16
  9. data/lib/datashift/populator.rb +23 -0
  10. data/lib/datashift/querying.rb +86 -0
  11. data/lib/generators/csv_generator.rb +1 -4
  12. data/lib/generators/excel_generator.rb +28 -11
  13. data/lib/generators/generator_base.rb +12 -0
  14. data/lib/loaders/csv_loader.rb +9 -3
  15. data/lib/loaders/excel_loader.rb +14 -6
  16. data/lib/loaders/loader_base.rb +38 -125
  17. data/lib/loaders/paperclip/attachment_loader.rb +130 -62
  18. data/lib/loaders/paperclip/datashift_paperclip.rb +46 -12
  19. data/lib/loaders/paperclip/image_loading.rb +25 -41
  20. data/lib/thor/generate.thor +16 -6
  21. data/lib/thor/paperclip.thor +25 -5
  22. data/spec/Gemfile +3 -2
  23. data/spec/MissingAttachmentRecords/DEMO_001_ror_bag.jpeg +0 -0
  24. data/spec/{fixtures/images/DEMO_002_Powerstation.jpg → MissingAttachmentRecords/DEMO_002_Powerstation.jpeg} +0 -0
  25. data/spec/MissingAttachmentRecords/DEMO_002_Powerstation.jpg +0 -0
  26. data/spec/MissingAttachmentRecords/DEMO_003_ror_mug.jpeg +0 -0
  27. data/spec/MissingAttachmentRecords/DEMO_004_ror_ringer.jpeg +0 -0
  28. data/spec/excel_generator_spec.rb +28 -0
  29. data/spec/excel_loader_spec.rb +12 -17
  30. data/spec/fixtures/config/database.yml +1 -1
  31. data/spec/fixtures/db/datashift_test_models_db.sqlite +0 -0
  32. data/spec/fixtures/db/migrate/20121009161700_add_digitals.rb +24 -0
  33. data/spec/fixtures/images/DEMO_002_Powerstation.jpeg +0 -0
  34. data/spec/fixtures/models/digital.rb +14 -0
  35. data/spec/fixtures/models/owner.rb +5 -3
  36. data/spec/fixtures/test_model_defs.rb +4 -62
  37. data/spec/loader_spec.rb +42 -50
  38. data/spec/method_dictionary_spec.rb +3 -10
  39. data/spec/method_mapper_spec.rb +79 -20
  40. data/spec/paperclip_loader_spec.rb +95 -0
  41. data/spec/spec_helper.rb +44 -8
  42. metadata +236 -224
  43. data/lib/helpers/rake_utils.rb +0 -42
  44. data/spec/fixtures/models/test_model_defs.rb +0 -67
@@ -1,42 +0,0 @@
1
- # Copyright:: (c) Autotelik Media Ltd 2011
2
- # Author :: Tom Statter
3
- # Date :: Aug 2011
4
- # License:: MIT
5
- #
6
- #
7
- module RakeUtils
8
-
9
- # Method to check arguments from a rake task and display help if required
10
- #
11
- # Expects a block which prints out the usage information
12
- #
13
- # task_args is expected to be of type Rake::TaskArguments
14
- #
15
- # NOTES: TaskArgs - bit of a weird class, has internal hash but also looks up on ENV
16
- # So if ENV[:filter] defined, args[:filter] would return the value,
17
- # but it would not show up in args.inspect or args.to_s or args.to_hash
18
- #
19
- def self.check_args( task_args, required = [] )
20
-
21
- # Tasks that call other tasks may wish to switch off displaying help for those sub tasks
22
-
23
- if( block_given? )
24
- yield unless task_args && required
25
-
26
- # Does task_args contain keys for ALL required items
27
- if(task_args[:help] || ENV['help'])
28
- yield
29
- exit(-1)
30
- end
31
-
32
- required.each do |r|
33
- unless(task_args.send(r))# || task_args[r.to_sym])
34
- puts "ERROR: Missing mandatory Param [#{r}]"
35
- yield
36
- exit(-1)
37
- end
38
- end
39
- end
40
- end
41
-
42
- end
@@ -1,67 +0,0 @@
1
- # A set of models and associations we can use in our specs to test
2
- # basic database columns and also relationships
3
-
4
- # See Companion migration spec/db/migrate
5
-
6
- class Project < ActiveRecord::Base
7
-
8
- has_one :owner
9
-
10
- has_many :milestones
11
-
12
- has_many :loader_releases
13
- has_many :versions, :through => :loader_releases
14
-
15
-
16
- #has_many :release_versions, :through => :loader_releases, :source => :versions
17
-
18
- has_and_belongs_to_many :categories
19
-
20
- attr_accessible :value_as_string, :value_as_boolean, :value_as_double
21
-
22
- def multiply
23
- 10 * value_as_double
24
- end
25
-
26
- end
27
-
28
- class Owner < ActiveRecord::Base
29
- belongs_to :project
30
- end
31
-
32
- class Milestone < ActiveRecord::Base
33
- belongs_to :project
34
- #validate the name, cost
35
-
36
- delegate :title, :title=, :to => :project
37
- end
38
-
39
- # had_and_belongs to join table
40
- class Category < ActiveRecord::Base
41
- has_and_belongs_to_many :projects
42
- end
43
-
44
-
45
- class Version < ActiveRecord::Base
46
- has_many :releases
47
-
48
- has_one :long_and_complex_table_linked_to_version
49
- end
50
-
51
- # Join Table with additional columns
52
- class LoaderRelease < ActiveRecord::Base
53
-
54
- belongs_to :project
55
- belongs_to :version
56
-
57
- #validate the name
58
- end
59
-
60
- class Empty < ActiveRecord::Base
61
- end
62
-
63
- # Join Table with additional columns
64
- class LongAndComplexTableLinkedToVersion < ActiveRecord::Base
65
-
66
- belongs_to :version
67
- end