xquery 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1e4c4058ba8d6f621da2a420773cd6b6578c899
4
- data.tar.gz: 617512ed3fa56d31783c79e6c1dd87cf990a64be
3
+ metadata.gz: c136c8a16f768441bc0e2dc4e26e84a2376454da
4
+ data.tar.gz: d43cc44d95877c754849b0dac45c29866ee37191
5
5
  SHA512:
6
- metadata.gz: 1fac614b682fe0b4673aafa5c9acd189ad4fa2a90da997244c427cf728fa62a24c781fb49b6bfca8666e9a2061bbb216ea8abc00a9b2593f707ccb0f675c5408
7
- data.tar.gz: 0fee5220b9fb5111e27a75979af3b7d40028f636ec31176a0bbca5bf8858ba1dc10af3edfe052a68be898a0f6c9ca05778bd1a8d58b712666ca41adf2120bee3
6
+ metadata.gz: 1032c489a451dc1f3f32371a7bbc1ddcd095eb2534103c5e1b02fcd8a8f3c5109c6054687c1c8ff87fe089bd34b3727a0fdf7bd89148d301cfd71dea2e859a4b
7
+ data.tar.gz: 8a0b8a61c0aeb65377c671573cea95cf1b5b2c4f123ab044114d4bf69746fb2669250e5051be5d989de23362df1276c90e0bc4b0c6903c5d41f053fccd069323
@@ -4,11 +4,11 @@ require 'xquery/query_proxy'
4
4
  require 'xquery/errors'
5
5
 
6
6
  module XQuery
7
- # abstract superclass, should be inherited, not used
7
+ # Abstract superclass, should be inherited, not used
8
8
  class Abstract
9
9
  class_attribute :query_superclass
10
10
 
11
- # yields instance inside block. I suggest to name it `q`
11
+ # Yields instance inside block. I suggest to name it `q`
12
12
  # @param args [Array(Object)] array of arguments would be passed to
13
13
  # @param block [#to_proc] block to witch instance would be yielded
14
14
  def self.with(*args, &block)
@@ -17,10 +17,6 @@ module XQuery
17
17
  instance.query
18
18
  end
19
19
 
20
- class << self
21
- alias_method :execute, :with
22
- end
23
-
24
20
  # Defines `method`, `__method` and `q.method`.
25
21
  # Both of wich changes query to query.method
26
22
  # @param name [#to_sym] name of method on query
@@ -30,13 +26,13 @@ module XQuery
30
26
  alias_on_q(as, true)
31
27
  end
32
28
 
33
- # same as wrap_method, but hanldes multiply methods
29
+ # Aame as wrap_method, but hanldes multiply methods
34
30
  # @param methods [Array(#to_sym)] names of methods defined
35
31
  def self.wrap_methods(*methods)
36
32
  methods.each(&method(:wrap_method))
37
33
  end
38
34
 
39
- # Aliases method to __method and q.method
35
+ # Aliases method to `#__method` and `q.method`
40
36
  # @param name [#to_sym] name of method
41
37
  # @param return_self [Boolean] should defined method return self or result
42
38
  def self.alias_on_q(name, return_self = false)
@@ -68,7 +64,27 @@ module XQuery
68
64
  @query_proxy = self.class.query_proxy.new(self)
69
65
  end
70
66
 
71
- # yields query inside block
67
+ # Yields iteself inside block. I suggest to name it `q`
68
+ # @param block [#to_proc] block to whitch instance would be yielded
69
+ # @return [Object] query
70
+ def with(&block)
71
+ block.call(self)
72
+ query
73
+ end
74
+
75
+ # Executes specified method, returns query.
76
+ # Feel free to redefine this method in case it's only public api method
77
+ # in your class
78
+ # @param method [#to_sym] any instance public method name
79
+ # @param args [Array(Object)] method call params
80
+ # @param block [#to_proc] block would be sent to method
81
+ # @return [Object] query
82
+ def execute(method, *args, &block)
83
+ public_send(method, *args, &block)
84
+ query
85
+ end
86
+
87
+ # Yields query inside block
72
88
  # @param block [#to_proc]
73
89
  # @return [XQuery::Abstract] self
74
90
  def apply(&block)
@@ -78,14 +94,14 @@ module XQuery
78
94
 
79
95
  private
80
96
 
81
- # @private_api
82
- # updates query by calling method on it and storing the result
97
+ # Private Api!
98
+ # Updates query by calling method on it and storing the result
83
99
  # @return [XQuery::Abstract] self
84
100
  def _update_query(method, *args, &block)
85
101
  apply { |x| x.public_send(method, *args, &block) }
86
102
  end
87
103
 
88
- # added constraints check
104
+ # Added constraints check
89
105
  # @raise XQuery::QuerySuperclassChanged
90
106
  def query=(x)
91
107
  unless x.is_a?(query_superclass)
@@ -1,4 +1,4 @@
1
1
  module XQuery
2
2
  # defines XQuery version
3
- VERSION = '0.1.3'
3
+ VERSION = '0.2.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xquery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jelf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.11'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.11'
111
125
  description: |
112
126
  # XQuery
113
127
  XQuery is designed to replace boring method call chains and allow to easier