sqlite_ext 1.1.0 → 1.2.0

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: 78941c80576ab0ae3a12eadd30c76532873d2be7
4
- data.tar.gz: 4d39aa19528e2630b5bb0ca20f9030f7aab7a8c8
3
+ metadata.gz: f2ac7b8599723e023de076d8fc62821ede76d464
4
+ data.tar.gz: ad7a63c1e1870fdacd2368537f75edac40d4e9f0
5
5
  SHA512:
6
- metadata.gz: 9b637e9f54e0cb68cc775c9022fb16a4ebb41635f62c6636d4cc35f0d694e9075de94819c0183f958bf1ef421bc9b228762f8aa2bb980ae556679ecdcc33866f
7
- data.tar.gz: 61aeab9272af31030d3ecc4e526882f70c240eca9202d52f3120f8640ced8ceda66e2b3401300e33921a1f59843c976c12334308a29ed32d2cc6a2ef90121597
6
+ metadata.gz: f86af039695928eb8396def84a17a5e5b396795fb06fe77859753b587fcd62bde1328a6fb3c2c2f833927a0040dfbaa1145da2ac1363967450b428e071c9dfe0
7
+ data.tar.gz: cdd395bde546846f181254d74aeccbc9d9aecd6a607e930f82fe6a6741f10cdf14082f7d9a96ae469382c238514b58a0cdb1480bd8a3e1d9835fd1efa4a12f51
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 1.2.0 - 2016-05-25
2
+ * Enhancements
3
+ * `SqliteExt.register_ruby_math` no longer re-registers functions when
4
+ they should already/still be registered.
5
+ * Features
6
+ * `SqliteExt.register_ruby_math!` has been added to unconditionally
7
+ register or re-register Ruby math functions.
8
+
1
9
  ### 1.1.0 - 2016-05-25
2
10
  * Enhancements
3
11
  * `SqliteExt.register_ruby_math` now also registers `floor` and `ceil`
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # SqliteExt
2
2
 
3
3
  Provides a convenient way of writing functions in Ruby that can
4
- be called from within SQLite queries through the SQLite3 gem.
4
+ be called from within SQLite queries through the sqlite3 gem.
5
5
 
6
6
  Although it is already possible to write ruby code for functions
7
7
  that can be called from within SQL queries using SQLite via the
8
- SQLite3 gem, that has some limitations which this gem seeks to
8
+ sqlite3 gem, that has some limitations which this gem seeks to
9
9
  address.
10
10
 
11
11
  First, when utilizing `SQLite3::Database#create_function`, the
data/lib/sqlite_ext.rb CHANGED
@@ -80,7 +80,23 @@ module SqliteExt
80
80
  #
81
81
  # `NULL`s are propagated as described in the documentation
82
82
  # for `register_function`.
83
+ #
84
+ # Note that calling `register_ruby_math` more than once
85
+ # without calling `purge_function_registrations` in between
86
+ # has no effect. Ruby math functions remain registered and
87
+ # are not re-registered in that case.
83
88
  def register_ruby_math
89
+ return if ruby_math_is_registered
90
+ register_ruby_math!
91
+ end
92
+
93
+ # Registers or re-registers Ruby math. You may want to call
94
+ # this method if one or more of the functions defined by a
95
+ # previous call to `register_ruby_math` or
96
+ # `register_ruby_math!` may have been subsequently replaced.
97
+ #
98
+ # See `register_ruby_math`.
99
+ def register_ruby_math!
84
100
  fn_methods = Math.public_methods - (Module.instance_methods << :frexp)
85
101
  fn_methods.each do |m|
86
102
  register_function m, Math.method(m)
@@ -88,6 +104,7 @@ module SqliteExt
88
104
  [:floor, :ceil].each do |m|
89
105
  register_function m, m.to_proc
90
106
  end
107
+ self.ruby_math_is_registered = true
91
108
  end
92
109
 
93
110
  # Registers a #create_function call to be invoked on every
@@ -137,6 +154,7 @@ module SqliteExt
137
154
  # existing instances of `SQLite3::Database`.
138
155
  def purge_function_registrations
139
156
  registered_function_creations.clear
157
+ self.ruby_math_is_registered = false
140
158
  end
141
159
 
142
160
  # Creates all of the registered functions on an instance of
@@ -154,8 +172,11 @@ module SqliteExt
154
172
 
155
173
  private
156
174
 
175
+ attr_accessor :ruby_math_is_registered
176
+
157
177
  def registered_function_creations
158
178
  @registered_function_creations ||= {}
159
179
  end
180
+
160
181
  end
161
182
  end
@@ -1,3 +1,3 @@
1
1
  module SqliteExt
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/sqlite_ext.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["stevej@stevej.name"]
11
11
 
12
12
  spec.summary = "Provides a convenient way of writing functions in Ruby that can " \
13
- "be called from within SQLite queries through the SQLite3 gem."
13
+ "be called from within SQLite queries through the sqlite3 gem."
14
14
  spec.homepage = "https://github.com/stevecj/sqlite_ext"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqlite_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Jorgensen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-25 00:00:00.000000000 Z
11
+ date: 2016-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -112,5 +112,5 @@ rubygems_version: 2.5.1
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Provides a convenient way of writing functions in Ruby that can be called
115
- from within SQLite queries through the SQLite3 gem.
115
+ from within SQLite queries through the sqlite3 gem.
116
116
  test_files: []