snapshotar 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b7518a6186d705c241f358e230cff6743b69b36
4
- data.tar.gz: 319fcc1e61c96ad015507bb9b2da001c59c1ba51
3
+ metadata.gz: c9dce45f3945faf3abb06e4519cebb35fa7ea70a
4
+ data.tar.gz: d7b40e2306e8e32480ff02bf2071022e2a035531
5
5
  SHA512:
6
- metadata.gz: a312f9567fd4a600df243ac3547d134fbac3a2a4c533f5a302a441bd7c07917dfa1e63cd36703b620b08f5a4411451c1ca41d23595ada61c43cb632996270963
7
- data.tar.gz: e19decc5f4d9c7017d7b641053323d68958b5e4e3ae51652825f5bea8b188016f0d10d3d4a3eae06470ec03de94163c7e93690f15244759c0cdfe55c661222c3
6
+ metadata.gz: dbf284de18e77b28bcf0f63b87ea6e76dd627983c3d29c02bdf1d00d084dc8791137bdbad27a673c7c2dd0aa9e0908778e231e6567e848d0429e1f5ffdd9109d
7
+ data.tar.gz: 0ff2656d88e83b4ed87863f5f063d10823c1ec99438cf13f57e383bcfeb9cd09b6b15baa08e5cf9f728ada348f6e82cba346faaba321c9b1b279ab837d10e1bd
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/elchbenny/snapshotar.svg?branch=master)](https://travis-ci.org/elchbenny/snapshotar)
2
2
  [![Code Climate](https://codeclimate.com/github/elchbenny/snapshotar.png)](https://codeclimate.com/github/elchbenny/snapshotar)
3
-
3
+ [![Gem Version](https://badge.fury.io/rb/snapshotar.svg)](http://badge.fury.io/rb/snapshotar)
4
4
 
5
5
  # Snapshotar
6
6
 
@@ -43,10 +43,13 @@ module Snapshotar
43
43
  m[1..-1].each do |attr|
44
44
 
45
45
  next unless itm.respond_to?(attr.to_sym)
46
+ next if itm[attr].nil?
46
47
 
47
48
  # replace uploads by their url
48
49
  if itm.send(attr.to_sym).respond_to?(:url)
49
50
  json.set! "#{attr}_url".to_sym, itm.send(attr.to_sym).url
51
+ elsif itm.send(attr.to_sym).is_a? ::BSON::ObjectId
52
+ json.set! attr.to_sym, itm[attr].to_s
50
53
  else
51
54
  json.set! attr.to_sym, itm[attr]
52
55
  end
@@ -75,15 +78,22 @@ module Snapshotar
75
78
  value.each do |itm|
76
79
  item_params = {}
77
80
  itm.each do |itm_key,itm_value|
81
+
82
+ next if itm_value.nil?
83
+
78
84
  # handle url paths separatley
79
85
  if itm_key.to_s.end_with?("_url")
80
- orig_key = itm_key.to_s[0..-5].to_sym
81
- item_params[orig_key] = File.open(itm_value)
86
+ if File.exist?(itm_value)
87
+ orig_key = itm_key.to_s[0..-5].to_sym
88
+ item_params[orig_key] = File.open(itm_value)
89
+ else # remote
90
+ item_params["remote_#{itm_key}"] = itm_value
91
+ end
82
92
  else
83
93
  item_params[itm_key] = itm_value
84
94
  end
85
95
  end
86
- clazz.create(item_params)
96
+ clazz.new(item_params).save(validate: false)
87
97
  end
88
98
  end
89
99
  end
@@ -1,3 +1,3 @@
1
1
  module Snapshotar
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snapshotar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Müller