hubspot-ruby 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/hubspot-ruby.gemspec +1 -1
- data/lib/hubspot-ruby.rb +1 -0
- data/lib/hubspot/deprecator.rb +7 -0
- data/lib/hubspot/railtie.rb +1 -0
- data/lib/hubspot/utils.rb +4 -0
- data/lib/tasks/hubspot.rake +4 -0
- data/spec/lib/hubspot/deprecator_spec.rb +15 -0
- data/spec/lib/hubspot/utils_spec.rb +35 -0
- data/spec/lib/tasks/hubspot_spec.rb +27 -8
- data/spec/support/capture_output.rb +21 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bf3e6e8fbd83defe0525c7d692eb797d2650eeb6919ffdc5c55505345da233e
|
4
|
+
data.tar.gz: 7880ed3f94d9ce4784668a20eb254635e72484e2d0dfba9cb2b988cfc5846756
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14385b0ece499e0092dd3de5de1de3b6fcb89c5acc90407a597c0a06658489302e9f7199def1ccb4dc58c118371fe4481e142060ad319c52cee99f55d4bf16ea
|
7
|
+
data.tar.gz: ce08579ea8415650d1599fff9cc31e6c14da1bbd90eea8974a9ef16c961b803de838bd0d5fd8a97e559140ce0b9e21cdf0b6fd3bb0769e09402272a5227799ac
|
data/hubspot-ruby.gemspec
CHANGED
data/lib/hubspot-ruby.rb
CHANGED
data/lib/hubspot/railtie.rb
CHANGED
data/lib/hubspot/utils.rb
CHANGED
@@ -15,6 +15,8 @@ module Hubspot
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def dump_properties(klass, hapikey=ENV['HUBSPOT_API_KEY'], filter={})
|
18
|
+
Hubspot::Deprecator.build.deprecation_warning("Hubspot::Utils.dump_properties")
|
19
|
+
|
18
20
|
with_hapikey(hapikey) do
|
19
21
|
{ 'groups' => klass.groups({}, filter),
|
20
22
|
'properties' => klass.all({}, filter).select { |p| !p['hubspotDefined'] }
|
@@ -23,6 +25,8 @@ module Hubspot
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def restore_properties(klass, hapikey=ENV['HUPSPOT_API_KEY'], properties={}, dry_run=false)
|
28
|
+
Hubspot::Deprecator.build.deprecation_warning("Hubspot::Utils.restore_properties")
|
29
|
+
|
26
30
|
existing_properties = dump_properties(klass, hapikey)
|
27
31
|
skip, new_groups, new_props, update_props = compare_property_lists(klass, properties, existing_properties)
|
28
32
|
puts '', 'Dry Run - Changes will not be applied' if dry_run
|
data/lib/tasks/hubspot.rake
CHANGED
@@ -3,6 +3,8 @@ require 'hubspot-ruby'
|
|
3
3
|
namespace :hubspot do
|
4
4
|
desc 'Dump properties to file'
|
5
5
|
task :dump_properties, [:kind, :file, :hapikey, :include, :exclude] do |_, args|
|
6
|
+
Hubspot::Deprecator.build.deprecation_warning("hubspot:dump_properties")
|
7
|
+
|
6
8
|
hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
|
7
9
|
kind = args[:kind]
|
8
10
|
unless %w(contact deal).include?(kind)
|
@@ -21,6 +23,8 @@ namespace :hubspot do
|
|
21
23
|
|
22
24
|
desc 'Restore properties from file'
|
23
25
|
task :restore_properties, [:kind, :file, :hapikey, :dry_run] do |_, args|
|
26
|
+
Hubspot::Deprecator.build.deprecation_warning("hubspot:restore_properties")
|
27
|
+
|
24
28
|
hapikey = args[:hapikey] || ENV['HUBSPOT_API_KEY']
|
25
29
|
if args[:file].blank?
|
26
30
|
raise ArgumentError, ':file is a required parameter'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
RSpec.describe Hubspot::Deprecator do
|
2
|
+
describe ".build" do
|
3
|
+
it "returns an instance of ActiveSupport::Deprecation" do
|
4
|
+
deprecator = Hubspot::Deprecator.build
|
5
|
+
|
6
|
+
expect(deprecator).to be_an_instance_of(ActiveSupport::Deprecation)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "uses the correct gem name" do
|
10
|
+
deprecator = Hubspot::Deprecator.build
|
11
|
+
|
12
|
+
expect(deprecator.gem_name).to eq("hubspot-ruby")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -126,4 +126,39 @@ describe Hubspot::Utils do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
129
|
+
|
130
|
+
describe ".dump_properties" do
|
131
|
+
it "prints a deprecation warning" do
|
132
|
+
VCR.use_cassette("dump_deal_properties_and_groups") do
|
133
|
+
api_key = "demo"
|
134
|
+
|
135
|
+
output = capture_stderr do
|
136
|
+
Hubspot::Utils.dump_properties(Hubspot::DealProperties, api_key)
|
137
|
+
end
|
138
|
+
|
139
|
+
expected_warning = "Hubspot::Utils.dump_properties is deprecated"
|
140
|
+
expect(output).to include(expected_warning)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe ".restore_properties" do
|
146
|
+
it "prints a deprecation warning" do
|
147
|
+
VCR.use_cassette("restore_deal_properties_and_groups") do
|
148
|
+
api_key = "demo"
|
149
|
+
properties = {"groups" => {}, "properties" => {}}
|
150
|
+
|
151
|
+
output = capture_stderr do
|
152
|
+
Hubspot::Utils.restore_properties(
|
153
|
+
Hubspot::DealProperties,
|
154
|
+
api_key,
|
155
|
+
properties
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
expected_warning = "Hubspot::Utils.restore_properties is deprecated"
|
160
|
+
expect(output).to include(expected_warning)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
129
164
|
end
|
@@ -20,6 +20,18 @@ RSpec.describe "hubspot rake tasks", type: :rake do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
it "prints a deprecation warning" do
|
24
|
+
VCR.use_cassette("dump_contact_properties_and_groups") do
|
25
|
+
file = Tempfile.new ""
|
26
|
+
|
27
|
+
output = capture_stderr do
|
28
|
+
invoke_rake_task("hubspot:dump_properties", ["contact", file, hapikey])
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(output).to include("hubspot:dump_properties is deprecated")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
23
35
|
context "given an unknown class" do
|
24
36
|
it "raises an error" do
|
25
37
|
file = Tempfile.new ""
|
@@ -55,6 +67,21 @@ RSpec.describe "hubspot rake tasks", type: :rake do
|
|
55
67
|
end
|
56
68
|
end
|
57
69
|
|
70
|
+
it "prints a deprecation warning" do
|
71
|
+
VCR.use_cassette("restore_contact_properties_and_groups") do
|
72
|
+
file = build_file_with_matching_properties("contact")
|
73
|
+
|
74
|
+
output = capture_stderr do
|
75
|
+
invoke_rake_task(
|
76
|
+
"hubspot:restore_properties",
|
77
|
+
["contact", file, hapikey]
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(output).to include("hubspot:restore_properties is deprecated")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
58
85
|
context "when a file is not provided" do
|
59
86
|
it "raises an error" do
|
60
87
|
missing_file = ""
|
@@ -89,12 +116,4 @@ RSpec.describe "hubspot rake tasks", type: :rake do
|
|
89
116
|
invoke_rake_task("hubspot:dump_properties", ["contact", file, hapikey])
|
90
117
|
file
|
91
118
|
end
|
92
|
-
|
93
|
-
def capture_stdout
|
94
|
-
previous, $stdout = $stdout, StringIO.new
|
95
|
-
yield
|
96
|
-
$stdout.string
|
97
|
-
ensure
|
98
|
-
$stdout = previous
|
99
|
-
end
|
100
119
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CaptureOutput
|
2
|
+
def capture_stderr
|
3
|
+
previous, $stderr = $stderr, StringIO.new
|
4
|
+
yield
|
5
|
+
$stderr.string
|
6
|
+
ensure
|
7
|
+
$stderr = previous
|
8
|
+
end
|
9
|
+
|
10
|
+
def capture_stdout
|
11
|
+
previous, $stdout = $stdout, StringIO.new
|
12
|
+
yield
|
13
|
+
$stdout.string
|
14
|
+
ensure
|
15
|
+
$stdout = previous
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.include CaptureOutput
|
21
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew DiMichele
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-11-
|
12
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- lib/hubspot/deal.rb
|
220
220
|
- lib/hubspot/deal_pipeline.rb
|
221
221
|
- lib/hubspot/deal_properties.rb
|
222
|
+
- lib/hubspot/deprecator.rb
|
222
223
|
- lib/hubspot/engagement.rb
|
223
224
|
- lib/hubspot/exceptions.rb
|
224
225
|
- lib/hubspot/form.rb
|
@@ -242,6 +243,7 @@ files:
|
|
242
243
|
- spec/lib/hubspot/deal_pipeline_spec.rb
|
243
244
|
- spec/lib/hubspot/deal_properties_spec.rb
|
244
245
|
- spec/lib/hubspot/deal_spec.rb
|
246
|
+
- spec/lib/hubspot/deprecator_spec.rb
|
245
247
|
- spec/lib/hubspot/engagement_spec.rb
|
246
248
|
- spec/lib/hubspot/form_spec.rb
|
247
249
|
- spec/lib/hubspot/owner_spec.rb
|
@@ -250,6 +252,7 @@ files:
|
|
250
252
|
- spec/lib/hubspot/utils_spec.rb
|
251
253
|
- spec/lib/tasks/hubspot_spec.rb
|
252
254
|
- spec/spec_helper.rb
|
255
|
+
- spec/support/capture_output.rb
|
253
256
|
- spec/support/cassette_helper.rb
|
254
257
|
- spec/support/hubspot_api_helpers.rb
|
255
258
|
- spec/support/rake.rb
|