spout 0.14.1 → 1.0.0.beta1

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
  SHA256:
3
- metadata.gz: dbba380addbe8afe96326c9e8c171aadd8a272a24a693e1073ce3622819bead3
4
- data.tar.gz: '06180a92089af4f0355e1e2f0887f98d04d5a21dc3e0501e4e219f08a713cb5c'
3
+ metadata.gz: 62adbf205bca2bcc8145f98ec3db81e0e4f727cefc8a6cd4feba20f89cad05c3
4
+ data.tar.gz: 27865c6bc004b782554f351f9f06e7ba1dfb30c2c3b770fcb30d81017924fa97
5
5
  SHA512:
6
- metadata.gz: a1ee3a5d7f55a7a0363d3bc2c8950d349a183030f3a0592bb04d28e9b8818ed3e8556d172ac7ea28a99fe26e6cdeba04c323ff35ba94a475ef142600e6abcb21
7
- data.tar.gz: 47f28ae6f5521b0300ad65bdbadd889f8ab393544e305517489ad307a7cb380af676a09bdfd1d7507a6b6b6f0aa959441cedf5af377fd9fe44a6f8beb5aaf0e0
6
+ metadata.gz: f21716870519e6fca63473053c7cbe7f09f447b7fe1515236523a1b9659fcb8fea8d19fac7492a376fde9afd1aef29a586d85ecfb6b086c171b2bd36fa59c095
7
+ data.tar.gz: 76b8ae9036b3a5e95853b11a7b6cc330b44f0c1815de212949417fa32c8f8edfb3aab00335d974a745a7fe292b473ec26bb7f52a21bf739478889038cb79db25
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 1.0.0
2
+
3
+ ### Enhancements
4
+ - **Gem Changes**
5
+ - Updated to ruby 2.6.1
6
+
7
+ ### Bug Fix
8
+ - Deploying a dataset that contains strings with special characters (accents ñ,
9
+ emojis 😃, etc) now correctly encodes those characters
10
+
1
11
  ## 0.14.1 (July 19, 2018)
2
12
 
3
13
  ### Bug Fix
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2018 Remo Mueller
1
+ Copyright (c) 2013-2019 Remo Mueller
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Spout
2
2
 
3
- [![Build Status](https://travis-ci.org/sleepepi/spout.svg?branch=master)](https://travis-ci.org/sleepepi/spout)
3
+ [![Build Status](https://travis-ci.com/sleepepi/spout.svg?branch=master)](https://travis-ci.com/sleepepi/spout)
4
4
  [![Code Climate](https://codeclimate.com/github/sleepepi/spout/badges/gpa.svg)](https://codeclimate.com/github/sleepepi/spout)
5
5
 
6
6
  Turn your CSV data dictionary into a JSON repository. Collaborate with others to
@@ -9,6 +9,7 @@ require "spout/helpers/quietly"
9
9
  require "spout/helpers/send_file"
10
10
  require "spout/helpers/semantic"
11
11
  require "spout/helpers/json_request"
12
+ require "spout/helpers/send_json"
12
13
 
13
14
  # - **User Authorization**
14
15
  # - User authenticates via token, the user must be a dataset editor
@@ -322,7 +323,7 @@ module Spout
322
323
 
323
324
  print "Launch Server Scripts: "
324
325
  params = { auth_token: @token, dataset: @slug, version: @version, folders: @created_folders.compact.uniq }
325
- (json, _status) = Spout::Helpers::JsonRequest.post("#{@url}/api/v1/dictionary/refresh.json", params)
326
+ (json, _status) = Spout::Helpers::SendJson.post("#{@url}/api/v1/dictionary/refresh.json", params)
326
327
  if json.is_a?(Hash) && json["refresh"] == "success"
327
328
  puts "DONE".green
328
329
  else
@@ -338,7 +339,7 @@ module Spout
338
339
  end
339
340
  print " Set Default Version: "
340
341
  params = { auth_token: @token, dataset: @slug, version: @version }
341
- (json, _status) = Spout::Helpers::JsonRequest.post(
342
+ (json, _status) = Spout::Helpers::SendJson.post(
342
343
  "#{@url}/api/v1/dictionary/update_default_version.json", params
343
344
  )
344
345
  if json.is_a?(Hash) && json["version_update"] == "success"
@@ -13,7 +13,7 @@ require "spout/models/graphables"
13
13
  require "spout/models/tables"
14
14
  require "spout/helpers/config_reader"
15
15
  require "spout/helpers/send_file"
16
- require "spout/helpers/json_request"
16
+ require "spout/helpers/send_json"
17
17
  require "spout/version"
18
18
 
19
19
  module Spout
@@ -175,7 +175,7 @@ module Spout
175
175
  domain: (variable.domain ? variable.domain.deploy_params : nil),
176
176
  forms: variable.forms.collect(&:deploy_params) }
177
177
  params[:variable][:spout_stats] = stats.to_json
178
- (json, status) = Spout::Helpers::JsonRequest.post("#{@url}/api/v1/variables/create_or_update.json", params)
178
+ (json, status) = Spout::Helpers::SendJson.post("#{@url}/api/v1/variables/create_or_update.json", params)
179
179
  if json.is_a?(Hash) && status.is_a?(Net::HTTPSuccess)
180
180
  @progress[variable.id]["uploaded"] << @webserver_name
181
181
  else
@@ -7,20 +7,12 @@ require "cgi"
7
7
 
8
8
  module Spout
9
9
  module Helpers
10
- # Generates JSON web requests for GET, POST, and PATCH.
10
+ # Generates JSON web requests for GET.
11
11
  class JsonRequest
12
12
  class << self
13
13
  def get(url, *args)
14
14
  new(url, *args).get
15
15
  end
16
-
17
- def post(url, *args)
18
- new(url, *args).post
19
- end
20
-
21
- def patch(url, *args)
22
- new(url, *args).patch
23
- end
24
16
  end
25
17
 
26
18
  attr_reader :url
@@ -41,6 +33,7 @@ module Spout
41
33
 
42
34
  def get
43
35
  return unless @error.nil?
36
+
44
37
  full_path = @url.path
45
38
  query = ([@url.query] + @params).flatten.compact.join("&")
46
39
  full_path += "?#{query}" if query.to_s != ""
@@ -52,22 +45,6 @@ module Spout
52
45
  puts "GET Error: #{e}".red
53
46
  end
54
47
 
55
- def post
56
- return unless @error.nil?
57
- response = @http.start do |http|
58
- http.post(@url.path, @params.flatten.compact.join("&"))
59
- end
60
- [JSON.parse(response.body), response]
61
- rescue => e
62
- puts "POST ERROR: #{e}".red
63
- nil
64
- end
65
-
66
- def patch
67
- @params << "_method=patch"
68
- post
69
- end
70
-
71
48
  def nested_hash_to_params(args)
72
49
  args.collect do |key, value|
73
50
  key_value_to_string(key, value, nil)
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "openssl"
4
+ require "net/http"
5
+ require "json"
6
+
7
+ module Spout
8
+ module Helpers
9
+ # Generates JSON web requests for POST and PATCH.
10
+ class SendJson
11
+ class << self
12
+ def post(*args)
13
+ new(*args).post
14
+ end
15
+
16
+ def patch(url, *args)
17
+ new(url, *args).patch
18
+ end
19
+ end
20
+
21
+ def initialize(url, args = {})
22
+ @params = args
23
+ @url = URI.parse(url)
24
+
25
+ @http = Net::HTTP.new(@url.host, @url.port)
26
+ if @url.scheme == "https"
27
+ @http.use_ssl = true
28
+ @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
29
+ end
30
+ rescue
31
+ @error = "Invalid URL: #{url.inspect}"
32
+ puts @error.red
33
+ end
34
+
35
+ def post
36
+ return unless @error.nil?
37
+
38
+ header = { "Content-Type" => "application/json", "Accept" => "application/json" }
39
+ response = @http.start do |http|
40
+ http.post(@url.path, @params.to_json, header)
41
+ end
42
+ [JSON.parse(response.body), response]
43
+ rescue => e
44
+ puts "POST ERROR".red
45
+ puts e.to_s.white
46
+ nil
47
+ end
48
+
49
+ def patch
50
+ @params["_method"] = "patch"
51
+ post
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,7 +1,7 @@
1
1
  <%= @project_name.capitalize %> Data Dictionary
2
2
  ======================
3
3
 
4
- [![Build Status](https://travis-ci.org/<REPOSITORY>/<%= @project_name.downcase %>-data-dictionary.svg?branch=master)](https://travis-ci.org/<REPOSITORY>/<%= @project_name.downcase %>-data-dictionary)
4
+ [![Build Status](https://travis-ci.com/<REPOSITORY>/<%= @project_name.downcase %>-data-dictionary.svg?branch=master)](https://travis-ci.com/<REPOSITORY>/<%= @project_name.downcase %>-data-dictionary)
5
5
 
6
6
  ### Exports
7
7
 
@@ -3,7 +3,6 @@
3
3
 
4
4
  # Project Files
5
5
  /gems.locked
6
- /Gemfile.lock
7
6
 
8
7
  # Data Dictionary folders
9
8
  /coverage
@@ -1 +1 @@
1
- ruby-2.5.1
1
+ ruby-2.6.1
@@ -1,5 +1,4 @@
1
- sudo: false
2
1
  language: ruby
3
- rvm: 2.5.1
2
+ rvm: 2.6.1
4
3
  gemfile: "gems.rb"
5
4
  script: spout test
data/lib/spout/version.rb CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Spout
4
4
  module VERSION #:nodoc:
5
- MAJOR = 0
6
- MINOR = 14
7
- TINY = 1
8
- BUILD = nil # "pre", "rc", "rc2", nil
5
+ MAJOR = 1
6
+ MINOR = 0
7
+ TINY = 0
8
+ BUILD = "beta1" # "pre", "rc", "rc2", nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join(".").freeze
11
11
  end
data/spout.gemspec CHANGED
@@ -26,18 +26,21 @@ Gem::Specification.new do |spec|
26
26
  "further validations."
27
27
  spec.homepage = "https://github.com/sleepepi/spout"
28
28
 
29
+ # spec.required_ruby_version = ">= 2.6.1"
30
+ # spec.required_rubygems_version = ">= 3.0.1"
31
+
29
32
  spec.required_ruby_version = ">= 2.5.1"
30
33
  spec.required_rubygems_version = ">= 2.7.6"
31
34
 
32
35
  spec.license = "MIT"
33
36
 
34
- spec.files = Dir["{bin,lib}/**/*"] + ["CHANGELOG.md", "LICENSE", "Rakefile", "README.md", "spout.gemspec"]
37
+ spec.files = Dir["{bin,lib}/**/*"] + ["CHANGELOG.md", "LICENSE", "Rakefile", "README.md", "spout.gemspec"]
35
38
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
36
39
  spec.test_files = spec.files.grep(%r{^(test)/})
37
40
  spec.require_paths = ["lib"]
38
41
 
39
- spec.add_dependency "bundler", "~> 1.16"
42
+ spec.add_dependency "bundler", ">= 1.3.0"
43
+ spec.add_dependency "json"
40
44
  spec.add_dependency "minitest"
41
45
  spec.add_dependency "minitest-reporters"
42
- spec.add_dependency "json"
43
46
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Remo Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-19 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: minitest
28
+ name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: minitest-reporters
42
+ name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: json
56
+ name: minitest-reporters
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -104,6 +104,7 @@ files:
104
104
  - lib/spout/helpers/quietly.rb
105
105
  - lib/spout/helpers/semantic.rb
106
106
  - lib/spout/helpers/send_file.rb
107
+ - lib/spout/helpers/send_json.rb
107
108
  - lib/spout/helpers/subject_loader.rb
108
109
  - lib/spout/helpers/table_formatting.rb
109
110
  - lib/spout/models/bucket.rb
@@ -181,8 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  - !ruby/object:Gem::Version
182
183
  version: 2.7.6
183
184
  requirements: []
184
- rubyforge_project:
185
- rubygems_version: 2.7.6
185
+ rubygems_version: 3.0.2
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Turn your CSV data dictionary into a JSON repository. Collaborate with others