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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 371e11640e32bc9b2ba0bb54f3fbdfd3b84dcb5f4be69fd0d4e89163fdf544bb
4
- data.tar.gz: 8f27026960fb8cc21c1f25c76dba6a26e4c33be192a635728a939284f52bea09
3
+ metadata.gz: 2bf3e6e8fbd83defe0525c7d692eb797d2650eeb6919ffdc5c55505345da233e
4
+ data.tar.gz: 7880ed3f94d9ce4784668a20eb254635e72484e2d0dfba9cb2b988cfc5846756
5
5
  SHA512:
6
- metadata.gz: bed3f9319a9dc8db09aa7a050d3724055e502cece3a2b3400c19fb7125fb4a38c1cf5366deff6e22f7ff34fc9db69d380c29e4f18df69763d422941efcd47019
7
- data.tar.gz: 64b3ddc122391b6d3fd44ec0cbe123ae92b306a632ebce366a9a43ee7acee0ef705e919c8d05661d6906e6d2454435352fc5b5c7422bd58d9320adc92ac5f4f7
6
+ metadata.gz: 14385b0ece499e0092dd3de5de1de3b6fcb89c5acc90407a597c0a06658489302e9f7199def1ccb4dc58c118371fe4481e142060ad319c52cee99f55d4bf16ea
7
+ data.tar.gz: ce08579ea8415650d1599fff9cc31e6c14da1bbd90eea8974a9ef16c961b803de838bd0d5fd8a97e559140ce0b9e21cdf0b6fd3bb0769e09402272a5227799ac
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hubspot-ruby"
3
- s.version = "0.6.0"
3
+ s.version = "0.6.1"
4
4
  s.require_paths = ["lib"]
5
5
  s.authors = ["Andrew DiMichele", "Chris Bisnett"]
6
6
  s.description = "hubspot-ruby is a wrapper for the HubSpot REST API"
@@ -16,6 +16,7 @@ require 'hubspot/topic'
16
16
  require 'hubspot/deal'
17
17
  require 'hubspot/deal_pipeline'
18
18
  require 'hubspot/deal_properties'
19
+ require 'hubspot/deprecator'
19
20
  require 'hubspot/owner'
20
21
  require 'hubspot/engagement'
21
22
  require 'hubspot/subscription'
@@ -0,0 +1,7 @@
1
+ module Hubspot
2
+ class Deprecator
3
+ def self.build(version: "1.0")
4
+ ActiveSupport::Deprecation.new(version, "hubspot-ruby")
5
+ end
6
+ end
7
+ end
@@ -4,6 +4,7 @@ module Hubspot
4
4
  class Railtie < Rails::Railtie
5
5
  rake_tasks do
6
6
  spec = Gem::Specification.find_by_name('hubspot-ruby')
7
+ load "#{spec.gem_dir}/lib/tasks/hubspot.rake"
7
8
  end
8
9
  end
9
10
  end
@@ -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
@@ -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.0
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-28 00:00:00.000000000 Z
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