frecon 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd60a8e39df9d65354023f15a71e7ff1941465cc
4
- data.tar.gz: 322aad2f9008ee3bac2f566a1afcc7ccc60938f8
3
+ metadata.gz: 57bd9b7c1164b8eb8fd9e832ac615281a0ae0921
4
+ data.tar.gz: 3c24af5efdef6fc97d60148a7daceb0d8f61c4f8
5
5
  SHA512:
6
- metadata.gz: d40ef54381e9b613289a0c1b82f486a965975866e1f7e3cbe16ec15285708e05156b2bfc4c6a27a567b3ecd72fa128f379fbcbfad6b008f5ccd19f81970b559b
7
- data.tar.gz: e6c5a2c2bbddf8de4b04441c59cc45575f76019fb2f81e3d110860b736c8ce8a6ff57203f36d6e6f92066261b52c8b5ad18d9e8052543500d158b74f352c4df2
6
+ metadata.gz: 632ff7d628bfafa97051643b7553939598a84d3aacd84927d5393b5ec18e8b980ee00379204b0a6dd45ef7c1ef9628019d2f698511e1656b13c5c2ef5ec17c2c
7
+ data.tar.gz: a39cf27d21e8747472bbfcfe98fd153e67473977f248baf65ab1723c587c52135a69ed1bf4070cce990978d50e4e6a0de6b7b6934d2398cfc4701a015da3f262
@@ -8,7 +8,7 @@
8
8
  # <http://opensource.org/licenses/MIT>.
9
9
 
10
10
  module FReCon
11
- VERSION = "0.3.0"
11
+ VERSION = "0.3.1"
12
12
 
13
13
  @environment_variable = :development
14
14
 
@@ -23,6 +23,12 @@ module FReCon
23
23
  # `data` will be a string, so we need to convert it from JSON.
24
24
  data = JSON.parse(data)
25
25
 
26
+ if context[:type] == :single && data.empty?
27
+ return [404, "Could not find a model with that query."]
28
+ elsif
29
+ puts "Just a heads up: you are importing an empty array of data."
30
+ end
31
+
26
32
  # Here we want `context` to tell us what model we are making.
27
33
  if context[:model]
28
34
  result = context[:model].controller.create(nil, nil, data)
@@ -57,14 +63,17 @@ module FReCon
57
63
  route_name = model.name.gsub(/FReCon::/, "").downcase.pluralize if model
58
64
 
59
65
  if !model && query.empty?
60
- data = HTTParty.get("http://#{@base_uri}:4567/dump")
66
+ type = :dump
67
+ data = HTTParty.get("http://#{@base_uri}/dump")
61
68
  elsif model && query.empty?
62
- data = HTTParty.get("http://#{@base_uri}:4567/#{route_name}")
69
+ type = :index
70
+ data = HTTParty.get("http://#{@base_uri}/#{route_name}")
63
71
  else
64
- data = HTTParty.get("http://#{@base_uri}:4567/#{route_name}", { query: query })
72
+ type = :single
73
+ data = HTTParty.get("http://#{@base_uri}/#{route_name}", { query: query })
65
74
  end
66
75
 
67
- read data.body, model: model
76
+ read data.body, model: model, type: type
68
77
  end
69
78
  end
70
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Craig