pendulum 0.1.3 → 0.1.4

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: fc5be8a5a9ee22af8db653d00440f081c8c368d7
4
- data.tar.gz: 38ad5a3d2c26a564c4067abf3507b1b431b253c3
3
+ metadata.gz: 1cae79bb4f1c0795054e3ce9da0cffeda994daa5
4
+ data.tar.gz: 4e60f9c46bdac7093fc655b87ce45d505e7563d3
5
5
  SHA512:
6
- metadata.gz: d1db1129a5724d97b214bbf17b163de97d7e1ff75740c01f16e3446cfc738dcf5c342c65b2abc3cf70190c0c41bde228649ca9cdaa2cb79085c679fb9260c5a7
7
- data.tar.gz: 0bafc9e48d4c623cff9b472b378b5c58c68a4a7cd0d32138beb3bcf9e8dd0fd33263f031d918e4d7f6369d95f5c821aede6f87d2f8f92f8a1bcc008510745e9f
6
+ metadata.gz: faea929e28c412ddbf15282eae6f2d8941d8553cb27bfd6531d729ecdf5a8dad4df4cc1e99899acdb4dbcdef4db8a35f7ec9435f5cc2235027c99a2c4f58056a
7
+ data.tar.gz: ea297310a42fe6bb76319209177762b169b1d67347b845a4fd908b09ab9f53ea00ddd0351c2e6f4e70a51c9f92ae62187c14a659ecff10d7495c4e77d142ddc4
data/lib/pendulum.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "json"
1
2
  require "pendulum/version"
2
3
  require "pendulum/client"
3
4
  require "pendulum/settings"
@@ -8,6 +9,7 @@ require "pendulum/dsl/result"
8
9
  require "pendulum/dsl/output/base"
9
10
  require "pendulum/dsl/output/treasure_data"
10
11
  require "pendulum/dsl/output/postgresql"
12
+ require "pendulum/dsl/output/nend"
11
13
  require "pendulum/dsl/output/result"
12
14
  require "pendulum/dsl/converter"
13
15
  require "pendulum/command/apply"
@@ -9,6 +9,28 @@ module Pendulum::Command
9
9
  end
10
10
 
11
11
  def changed?
12
+ if from.start_with?('{')
13
+ json_changed?
14
+ else
15
+ url_changed?
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def json_changed?
22
+ to_json = JSON.parse(to)
23
+
24
+ name = to_json['type']
25
+ result = result_by(name)
26
+ to_json = JSON.parse(result.url) if result
27
+
28
+ to_json.delete('apikey')
29
+
30
+ JSON.parse(from) != to_json
31
+ end
32
+
33
+ def url_changed?
12
34
  from_uri = to_uri(from)
13
35
  to_uri = mask(to_uri(to))
14
36
 
@@ -16,8 +38,6 @@ module Pendulum::Command
16
38
  query_hash(from_uri) != query_hash(to_uri)
17
39
  end
18
40
 
19
- private
20
-
21
41
  def mask(uri)
22
42
  uri.password = '***' if uri.user
23
43
  uri
@@ -62,7 +62,7 @@ module Pendulum::Command
62
62
 
63
63
  @diff ||= begin
64
64
  default_params.merge(to.to_params).select do |k, v|
65
- if k == :result
65
+ if k == :result || k == :result_json
66
66
  result_url_changed?(from.result_url, v)
67
67
  else
68
68
  v != from.send(k)
@@ -75,9 +75,16 @@ module Pendulum::Command
75
75
  return diff unless diff.key?(:result)
76
76
 
77
77
  masked = diff.dup
78
- uri = URI.parse(masked[:result])
79
- uri.password = '***' if uri.user
80
- masked[:result] = uri.to_s
78
+
79
+ if masked[:result].start_with?('{') || diff.key?(:result_json)
80
+ hashed_result = JSON.parse(masked[:result])
81
+ hashed_result.delete('apikey')
82
+ masked[:result] = hashed_result.to_json
83
+ else
84
+ uri = URI.parse(masked[:result])
85
+ uri.password = '***' if uri.user
86
+ masked[:result] = uri.to_s
87
+ end
81
88
 
82
89
  masked
83
90
  end
@@ -0,0 +1,19 @@
1
+ module Pendulum::DSL::Output
2
+ class Nend < Base
3
+ define_setter :api_key, :type, :name,
4
+ :retry_delay, :retry_limit
5
+
6
+ def to_url
7
+ {
8
+ type: 'nend',
9
+ apikey: @api_key,
10
+ target_type: @type,
11
+ target_name: @name,
12
+ retry_initial_wait_sec: @retry_delay || 5,
13
+ retry_limit: @retry_limit || 4,
14
+ application_name: 'Treasure Data nend Output'
15
+ }.to_json
16
+ end
17
+ end
18
+ end
19
+
@@ -20,6 +20,8 @@ module Pendulum::DSL
20
20
  Output::TreasureData.new
21
21
  when :postgresql
22
22
  Output::Postgresql.new
23
+ when :nend
24
+ Output::Nend.new
23
25
  else
24
26
  Output::Result.new(type)
25
27
  end
@@ -33,6 +33,10 @@ module Pendulum::DSL
33
33
  @result = result.to_url
34
34
  end
35
35
 
36
+ def result_json(type, hash = {})
37
+ @result = {type: type}.merge(hash).to_json
38
+ end
39
+
36
40
  def to_params
37
41
  instance_variables.inject({}) do |params, v|
38
42
  params[v.to_s.delete('@').to_sym] = instance_variable_get(v)
@@ -1,3 +1,3 @@
1
1
  module Pendulum
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pendulum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - monochromegane
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-17 00:00:00.000000000 Z
11
+ date: 2016-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: td
@@ -149,6 +149,7 @@ files:
149
149
  - lib/pendulum/dsl/converter.rb
150
150
  - lib/pendulum/dsl/helper.rb
151
151
  - lib/pendulum/dsl/output/base.rb
152
+ - lib/pendulum/dsl/output/nend.rb
152
153
  - lib/pendulum/dsl/output/postgresql.rb
153
154
  - lib/pendulum/dsl/output/result.rb
154
155
  - lib/pendulum/dsl/output/treasure_data.rb