api_queries 0.1.6 → 0.1.7

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
  SHA256:
3
- metadata.gz: 0e2ffc36bc14ef3fa1695201119ddb8039709924ae1a8d5ad08e0ff7ce518d95
4
- data.tar.gz: d926f83065802c9b70b06773ea1b568adbf6e16f68b10857dfbca38dca48d424
3
+ metadata.gz: c1958a30567b647aa2bc495824621610186e7c5b44b20dd9608910ef36c255b7
4
+ data.tar.gz: 852282cd93676f3bd1aa6049e040ed9be527516b902f13c2751f8a9153e47f64
5
5
  SHA512:
6
- metadata.gz: 9b201d964f73f04127be2000eaad2aba229202aebfb6ffd240d9ae28ed3e7a2c972417c176d4509f6e6a7c51d78aa1f944adb271000429465775bced1a6e0b69
7
- data.tar.gz: 83e7eeb5a9f5a8482960e6b86536117f306c3e1a2f702fd724973560cf6178382020a1ca10e5a298127d5447e40297378182be696922bdf3e81420078f9f9ad9
6
+ metadata.gz: e3e3c14fe9ebdbf0963cd38464840a8b2b7f3aed9b1455eb12220e54a7d286c09a181d0fe80ea5f238bed9afdc6c78b45a78baaffe725c1672067d9baa8c02dd
7
+ data.tar.gz: a72bc82ee0d9b79ccc3d7d333d1a8efbd7c6601c850cf4e78a4629f10c0893b399448481c56a4958cc8353e987be90e9bb6dd2599b20eb1465872d012b681d7c
data/.gitignore CHANGED
@@ -6,4 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
- .rspec_status
9
+ .rspec_status
10
+ Guardfile
data/.rspec_status CHANGED
@@ -1,11 +1,14 @@
1
- example_id | status | run_time |
2
- --------------------------------- | ------ | --------------- |
3
- ./spec/api_queries_spec.rb[1:1:1] | passed | 0.00588 seconds |
4
- ./spec/api_queries_spec.rb[1:1:2] | passed | 0.0209 seconds |
5
- ./spec/api_queries_spec.rb[1:1:3] | passed | 0.00068 seconds |
6
- ./spec/api_queries_spec.rb[1:1:4] | passed | 0.01339 seconds |
7
- ./spec/api_queries_spec.rb[1:1:5] | passed | 0.00339 seconds |
8
- ./spec/api_queries_spec.rb[1:1:6] | passed | 0.00318 seconds |
9
- ./spec/api_queries_spec.rb[1:1:7] | passed | 0.00644 seconds |
10
- ./spec/api_queries_spec.rb[1:1:8] | passed | 0.00293 seconds |
11
- ./spec/api_queries_spec.rb[1:1:9] | passed | 0.00166 seconds |
1
+ example_id | status | run_time |
2
+ ----------------------------------- | ------ | --------------- |
3
+ ./spec/api_queries_spec.rb[1:1:1:1] | passed | 0.00361 seconds |
4
+ ./spec/api_queries_spec.rb[1:1:1:2] | passed | 0.00971 seconds |
5
+ ./spec/api_queries_spec.rb[1:1:1:3] | passed | 0.00057 seconds |
6
+ ./spec/api_queries_spec.rb[1:1:1:4] | passed | 0.00761 seconds |
7
+ ./spec/api_queries_spec.rb[1:1:1:5] | passed | 0.00393 seconds |
8
+ ./spec/api_queries_spec.rb[1:1:1:6] | passed | 0.00675 seconds |
9
+ ./spec/api_queries_spec.rb[1:1:1:7] | passed | 0.00654 seconds |
10
+ ./spec/api_queries_spec.rb[1:1:1:8] | passed | 0.00291 seconds |
11
+ ./spec/api_queries_spec.rb[1:1:1:9] | passed | 0.00149 seconds |
12
+ ./spec/api_queries_spec.rb[1:1:2:1] | passed | 0.01001 seconds |
13
+ ./spec/api_queries_spec.rb[1:1:2:2] | passed | 0.00015 seconds |
14
+ ./spec/api_queries_spec.rb[1:1:2:3] | passed | 0.00234 seconds |
data/.rubocop_todo.yml CHANGED
@@ -20,17 +20,17 @@ Lint/UnreachableCode:
20
20
 
21
21
  # Offense count: 1
22
22
  Metrics/AbcSize:
23
- Max: 61
23
+ Max: 65
24
24
 
25
25
  # Offense count: 2
26
26
  # Configuration parameters: CountComments, ExcludedMethods.
27
27
  # ExcludedMethods: refine
28
28
  Metrics/BlockLength:
29
- Max: 58
29
+ Max: 80
30
30
 
31
31
  # Offense count: 1
32
32
  Metrics/CyclomaticComplexity:
33
- Max: 16
33
+ Max: 20
34
34
 
35
35
  # Offense count: 1
36
36
  # Configuration parameters: CountComments.
@@ -39,7 +39,7 @@ Metrics/MethodLength:
39
39
 
40
40
  # Offense count: 1
41
41
  Metrics/PerceivedComplexity:
42
- Max: 18
42
+ Max: 20
43
43
 
44
44
  # Offense count: 1
45
45
  Style/MixinUsage:
@@ -56,4 +56,4 @@ Style/RescueModifier:
56
56
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
57
57
  # URISchemes: http, https
58
58
  Metrics/LineLength:
59
- Max: 129
59
+ Max: 135
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- api_queries (0.1.6)
4
+ api_queries (0.1.7)
5
5
  will_paginate (>= 3.0)
6
6
 
7
7
  GEM
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: 'bundle exec rspec' do
28
+ require 'guard/rspec/dsl'
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
69
+ end
70
+ end
Binary file
@@ -1,3 +1,3 @@
1
1
  module ApiQueries
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
data/lib/api_queries.rb CHANGED
@@ -11,36 +11,38 @@ module ApiQueries
11
11
  # add default value
12
12
  opts[:column_date] = 'updated_at' unless opts[:column_date].present?
13
13
 
14
- # check if specified column exists
15
- raise Errors::UnknownColumn, 'Invalid value for column_date.' if column_names.exclude?(opts[:column_date])
16
-
17
- # last updated at q
18
- if opts[:q] == 'last_updated_at'
19
- return { last_updated_at: (begin
20
- order(opts[:column_date] => :desc).limit(1).first.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ')
21
- rescue StandardError
22
- nil
23
- end) }
24
- end
25
-
26
14
  # condition hash
27
15
  conditions = {}
28
16
 
29
- # AFTER: updated_at > given_date
30
- if opts[:after].present?
31
- conditions = ["#{opts[:column_date]} > ?", fdate(opts[:after])]
32
- # BEFORE: updated_at < given_date
33
- elsif opts[:before].present?
34
- conditions = ["#{opts[:column_date]} < ?", fdate(opts[:before])]
35
- # FROM & TO: between "from date" to "to date"
36
- elsif opts[:from].present? && opts[:to].present?
37
- conditions[opts[:column_date].to_sym] = (fdate(opts[:from])..fdate(opts[:to]))
38
- # FROM: updated_at >= given_date
39
- elsif opts[:from].present?
40
- conditions = ["#{opts[:column_date]} >= ?", fdate(opts[:from])]
41
- # TO: updated_at <= given_date
42
- elsif opts[:to].present?
43
- conditions = ["#{opts[:column_date]} <= ?", fdate(opts[:to])]
17
+ # check if specified column exists
18
+ if column_names.include?(opts[:column_date])
19
+ # last updated at q
20
+ if opts[:q] == 'last_updated_at'
21
+ return { last_updated_at: (begin
22
+ order(opts[:column_date] => :desc).limit(1).first.updated_at.strftime('%Y-%m-%dT%H:%M:%SZ')
23
+ rescue StandardError
24
+ nil
25
+ end) }
26
+ end
27
+
28
+ # AFTER: updated_at > given_date
29
+ if opts[:after].present?
30
+ conditions = ["#{opts[:column_date]} > ?", fdate(opts[:after])]
31
+ # BEFORE: updated_at < given_date
32
+ elsif opts[:before].present?
33
+ conditions = ["#{opts[:column_date]} < ?", fdate(opts[:before])]
34
+ # FROM & TO: between "from date" to "to date"
35
+ elsif opts[:from].present? && opts[:to].present?
36
+ conditions[opts[:column_date].to_sym] = (fdate(opts[:from])..fdate(opts[:to]))
37
+ # FROM: updated_at >= given_date
38
+ elsif opts[:from].present?
39
+ conditions = ["#{opts[:column_date]} >= ?", fdate(opts[:from])]
40
+ # TO: updated_at <= given_date
41
+ elsif opts[:to].present?
42
+ conditions = ["#{opts[:column_date]} <= ?", fdate(opts[:to])]
43
+ end
44
+ else
45
+ raise Errors::UnknownColumn, 'Invalid value for column_date.' unless opts[:column_date] == 'updated_at'
44
46
  end
45
47
 
46
48
  # get by status
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_queries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nujian Den Mark Meralpis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-06 00:00:00.000000000 Z
11
+ date: 2018-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: will_paginate
@@ -96,6 +96,7 @@ files:
96
96
  - CODE_OF_CONDUCT.md
97
97
  - Gemfile
98
98
  - Gemfile.lock
99
+ - Guardfile
99
100
  - LICENSE.txt
100
101
  - README.md
101
102
  - Rakefile
@@ -104,8 +105,7 @@ files:
104
105
  - bin/setup
105
106
  - builds/api_queries-0.1.2.gem
106
107
  - builds/api_queries-0.1.3.gem
107
- - builds/api_queries-0.1.4.gem.bad_release
108
- - builds/api_queries-0.1.5.gem
108
+ - builds/api_queries-0.1.6.gem
109
109
  - lib/api_queries.rb
110
110
  - lib/api_queries/errors/unknown_column.rb
111
111
  - lib/api_queries/version.rb
Binary file