cassie 1.1.5 → 1.1.6.pre2

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: f9ccfed850a04525540b907377c45bc184fc2b29
4
- data.tar.gz: 4c7fc37a9271510ffbae658d630142f67c7a8209
3
+ metadata.gz: 7257a6f02ed7e3fe15e51332ba3a7eabbaf0c368
4
+ data.tar.gz: 3129c8b2c54ecb809e35dee8cc7447c8b983ee5a
5
5
  SHA512:
6
- metadata.gz: ec535d27f438aae219169b0ef714dcedd28eb055d74c0c6ef388c4101433a543d5d03aa157e14e765b2cad0062b6538650738627d75d362eb1eb7daf05d46675
7
- data.tar.gz: 2e0853ebe696698f137b83bd06366bca34f7bd9c713ccb42f93c7a6e5fdaeea8b6f7964fb0b5f0f31b46083ddb992a040de62b8c8a8bc3574197c29ac1933ad1
6
+ metadata.gz: dd25023715242ec4d9a6b97383229c9b4f1b5bb89cc4408fde3d33ee6648147691f09c126a5ae258eceb72208683e2a7a3172e9a2a7011eccf1133e0e8847696
7
+ data.tar.gz: d1abfcb2272ceffa2ad265cefe2543aeab8b94ced10deefa1277bd1f560efe17c5e7dbc99e18b15bfc00579be1ddfb04c645420081a8ae805b9cbaa338418f72
@@ -215,7 +215,7 @@ query.execute
215
215
  #=> true
216
216
  ```
217
217
 
218
- Mapping assignemtnt values from a domain object is supported.
218
+ Mapping assignment values from a domain object is supported.
219
219
 
220
220
  ```ruby
221
221
  class UpdateUserQuery < Cassandra::Modification
@@ -270,41 +270,6 @@ user
270
270
  UpdateUserQuery.new(user: user).execute
271
271
  ```
272
272
 
273
- <pre><b>
274
- (1.2ms) UPDATE users_by_id (phone, email, address, username) VALUES (?, ?, ?, ?) WHERE id = ?; [["+15555555555", "etp@example.com", nil, "etp", 6539]]
275
- </b></pre>
276
-
277
- The above examples use positional terms (e.g. the term is '?' in the statement). The assignement's term can be defined explicitly.
278
-
279
- ```ruby
280
- insert_into :posts
281
-
282
- set :id, term: "now()"
283
- ```
284
-
285
- ```ruby
286
- update :post_counts
287
-
288
- set :comments_count, "comments_count + 1"
289
-
290
- non_idempotent
291
- ```
292
-
293
- A value will be fetched and placed as an argument in the statement if the provided term includes a positional marker ('?').
294
-
295
- ```ruby
296
- select :posts
297
-
298
- where :id, :gteq, term: "minTimeuuid(?)", value: :window_min_timestamp
299
-
300
- def window_min_timestamp
301
- '2013-02-02 10:00+0000'
302
- end
303
- ```
304
-
305
- > Note: The `term` option should be used with care. Using it innapropriately could result in inefficient use of prepared statements, and/or leave you potentially vulnerable to injection attacks.
306
-
307
-
308
273
  #### Column Selection (`select`)
309
274
 
310
275
  By default, all columns will be selected (e.g. '*'). Specify a column for selection with `select`.
@@ -374,6 +339,59 @@ By default, all columns for specified CQL rows will be deleted. Identify a subse
374
339
  #=> DELETE nickname FROM authors_by_id where id = 123;
375
340
  ```
376
341
 
342
+ #### Non-Positional Terms
343
+
344
+ <pre><b>
345
+ (1.2ms) UPDATE users_by_id (phone, email, address, username) VALUES (?, ?, ?, ?) WHERE id = ?; [["+15555555555", "etp@example.com", nil, "etp", 6539]]
346
+ </b></pre>
347
+
348
+ BY default, Cassie uses positional terms as shown in this update statement (e.g. the term is '?' in the statement). The assignement's term can also be defined explicitly.
349
+
350
+ ```ruby
351
+ insert_into :posts
352
+
353
+ set :id, term: "now()"
354
+ ```
355
+ <pre><b>
356
+ (1.2ms) INSERT into posts_by_id (id) VALUES (now());
357
+ </b></pre>
358
+
359
+ ```ruby
360
+ update :post_counts
361
+
362
+ set :comments_count, "comments_count + 1"
363
+
364
+ non_idempotent
365
+ ```
366
+
367
+ A value will be fetched and placed as an argument in the statement if the provided term includes a positional marker ('?').
368
+
369
+ ```ruby
370
+ select :posts
371
+
372
+ where :id, :gteq, term: "minTimeuuid(?)", value: :window_min_timestamp
373
+
374
+ def window_min_timestamp
375
+ '2013-02-02 10:00+0000'
376
+ end
377
+ ```
378
+
379
+ > Note: The `term` option should be used with care. Using it innapropriately could result in inefficient use of prepared statements, and/or leave you potentially vulnerable to injection attacks.
380
+
381
+ #### Setting Column TTL and Timestamp (`using`)
382
+
383
+ ```ruby
384
+ class InsertSessionQuery < Cassandra::Modification
385
+
386
+ insert :sessions_by_token
387
+
388
+ set :token
389
+ set :username
390
+
391
+ using ttl: 300, if: :expiring?
392
+ end
393
+ ```
394
+
377
395
  #### Execution and Result
378
396
 
379
397
  Executing a `Cassie::Query` populates the `result` attribute.
@@ -3,17 +3,93 @@ module Cassie
3
3
  class SystemCommand
4
4
  attr_reader :binary, :args, :command, :status, :duration, :output
5
5
 
6
- # When a block is given, the command runs before yielding
7
- def initialize(binary, args=[])
8
- @binary = binary
9
- @args = args
10
- @command = (Array(binary) + args).join(" ")
11
- @command = command + " 2>&1" unless command =~ / > /
6
+ # Indicates whether a binary exists in the current user's PATH
7
+ # @param [String, Symbol] name the name of the command to search for
8
+ # @return [Boolean] true if the binary could be found
9
+ def self.exist?(name)
10
+ !!which(name)
11
+ end
12
12
 
13
- if block_given?
14
- run
15
- yield self
13
+ # Find the path to the executable file, using the current user's PATH
14
+ # @param [String, Symbol] name the name of the command to search for
15
+ # @return [String, nil] the fully qualified path
16
+ def self.which(name)
17
+ # windows support
18
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
19
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
20
+ exts.each { |ext|
21
+ exe = File.join(path, "#{name}#{ext}")
22
+ return exe if File.executable?(exe) && !File.directory?(exe)
23
+ }
16
24
  end
25
+ return nil
26
+ end
27
+
28
+ # Creates a new SystemCommand object that has
29
+ # not yet been executed.
30
+ #
31
+ # @overload initialize(command)
32
+ # @param [#to_s] the command to execute
33
+ #
34
+ # @overload initialize(binary, [args]=[])
35
+ # @param [#to_s] binary the binary to be called
36
+ # @param [Array<#to_s>] args Arguments to be passed to the binary
37
+ #
38
+ # @overload initialize(binary, arg, ...)
39
+ # @param [#to_s] binary the binary to be called
40
+ # @param [#to_s, Array<#to_s>] arg Argument(s) to be passed to the binary
41
+ # @param [#to_s, Array<#to_s>] ... more argument(s) to be passed to the binary
42
+ #
43
+ # @example command string
44
+ # cmd = SystemCommand.new("git reset --hard HEAD")
45
+ # cmd.binary
46
+ # #=> "git"
47
+ # cmd.args
48
+ # #=> ["reset", "--hard", "HEAD"]
49
+ #
50
+ # @example binary and arguments strings
51
+ # cmd = SystemCommand.new("git", "reset --hard HEAD")
52
+ # cmd.binary
53
+ # #=> "git"
54
+ # cmd.args
55
+ # #=> ["reset", "--hard", "HEAD"]
56
+ #
57
+ # @example binary and arguments string with splat
58
+ # cmd = SystemCommand.new("git", "reset", "--hard HEAD")
59
+ # cmd.binary
60
+ # #=> "git"
61
+ # cmd.args
62
+ # #=> ["reset", "--hard", "HEAD"]
63
+ #
64
+ # @example binary with arguments array
65
+ # cmd = SystemCommand.new("git", ["reset", "--hard", "HEAD"])
66
+ # cmd.binary
67
+ # #=> "git"
68
+ # cmd.args
69
+ # #=> ["reset", "--hard", "HEAD"]
70
+ #
71
+ # @example array
72
+ # cmd = SystemCommand.new(["git", "reset", "--hard", "HEAD"])
73
+ # cmd.binary
74
+ # #=> "git"
75
+ # cmd.args
76
+ # #=> ["reset", "--hard", "HEAD"]
77
+ def initialize(*cmd)
78
+ @args = []
79
+ cmd.flatten.each{|a| @args += a.to_s.split(" ")}
80
+
81
+ @command = args.join(" ")
82
+ @command = command + " 2>&1" unless command =~ / > /
83
+
84
+ @binary = @args.shift
85
+ end
86
+
87
+ def exist?
88
+ self.class.exist?(binary)
89
+ end
90
+
91
+ def which
92
+ self.class.which(binary)
17
93
  end
18
94
 
19
95
  # Runs the command
@@ -22,8 +98,8 @@ module Cassie
22
98
  t1=Time.now
23
99
 
24
100
  IO.popen(command) do |io|
25
- @output=io.read
26
101
  @status=Process.waitpid2(io.pid)[1]
102
+ @output=io.read.sub(/\n\z/, "")
27
103
  end
28
104
 
29
105
  @duration=Time.now-t1
@@ -1,3 +1,3 @@
1
1
  module Cassie
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6.pre2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Prothro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver
@@ -269,9 +269,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
269
  version: '0'
270
270
  required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  requirements:
272
- - - ">="
272
+ - - ">"
273
273
  - !ruby/object:Gem::Version
274
- version: '0'
274
+ version: 1.3.1
275
275
  requirements: []
276
276
  rubyforge_project:
277
277
  rubygems_version: 2.5.2