algolia 2.0.0.pre.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.circleci/config.yml +146 -0
  3. data/.github/ISSUE_TEMPLATE.md +20 -0
  4. data/.github/PULL_REQUEST_TEMPLATE.md +22 -0
  5. data/.gitignore +38 -0
  6. data/.rubocop.yml +186 -0
  7. data/.rubocop_todo.yml +14 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +18 -0
  10. data/LICENSE +21 -0
  11. data/README.md +56 -0
  12. data/Rakefile +45 -0
  13. data/Steepfile +6 -0
  14. data/algolia.gemspec +41 -0
  15. data/bin/console +21 -0
  16. data/bin/setup +8 -0
  17. data/lib/algolia.rb +42 -0
  18. data/lib/algolia/account_client.rb +65 -0
  19. data/lib/algolia/analytics_client.rb +105 -0
  20. data/lib/algolia/config/algolia_config.rb +40 -0
  21. data/lib/algolia/config/analytics_config.rb +20 -0
  22. data/lib/algolia/config/insights_config.rb +20 -0
  23. data/lib/algolia/config/recommendation_config.rb +20 -0
  24. data/lib/algolia/config/search_config.rb +40 -0
  25. data/lib/algolia/defaults.rb +35 -0
  26. data/lib/algolia/enums/call_type.rb +4 -0
  27. data/lib/algolia/enums/retry_outcome_type.rb +5 -0
  28. data/lib/algolia/error.rb +29 -0
  29. data/lib/algolia/helpers.rb +83 -0
  30. data/lib/algolia/http/http_requester.rb +84 -0
  31. data/lib/algolia/http/response.rb +23 -0
  32. data/lib/algolia/insights_client.rb +238 -0
  33. data/lib/algolia/iterators/base_iterator.rb +19 -0
  34. data/lib/algolia/iterators/object_iterator.rb +27 -0
  35. data/lib/algolia/iterators/paginator_iterator.rb +44 -0
  36. data/lib/algolia/iterators/rule_iterator.rb +9 -0
  37. data/lib/algolia/iterators/synonym_iterator.rb +9 -0
  38. data/lib/algolia/logger_helper.rb +14 -0
  39. data/lib/algolia/recommendation_client.rb +60 -0
  40. data/lib/algolia/responses/add_api_key_response.rb +38 -0
  41. data/lib/algolia/responses/base_response.rb +9 -0
  42. data/lib/algolia/responses/delete_api_key_response.rb +40 -0
  43. data/lib/algolia/responses/indexing_response.rb +28 -0
  44. data/lib/algolia/responses/multiple_batch_indexing_response.rb +29 -0
  45. data/lib/algolia/responses/multiple_response.rb +45 -0
  46. data/lib/algolia/responses/restore_api_key_response.rb +36 -0
  47. data/lib/algolia/responses/update_api_key_response.rb +39 -0
  48. data/lib/algolia/search_client.rb +614 -0
  49. data/lib/algolia/search_index.rb +1094 -0
  50. data/lib/algolia/transport/request_options.rb +94 -0
  51. data/lib/algolia/transport/retry_strategy.rb +117 -0
  52. data/lib/algolia/transport/stateful_host.rb +26 -0
  53. data/lib/algolia/transport/transport.rb +161 -0
  54. data/lib/algolia/user_agent.rb +25 -0
  55. data/lib/algolia/version.rb +3 -0
  56. data/sig/config/algolia_config.rbs +24 -0
  57. data/sig/config/analytics_config.rbs +11 -0
  58. data/sig/config/insights_config.rbs +11 -0
  59. data/sig/config/recommendation_config.rbs +11 -0
  60. data/sig/config/search_config.rbs +11 -0
  61. data/sig/enums/call_type.rbs +5 -0
  62. data/sig/helpers.rbs +12 -0
  63. data/sig/http/http_requester.rbs +17 -0
  64. data/sig/http/response.rbs +14 -0
  65. data/sig/interfaces/_connection.rbs +16 -0
  66. data/sig/iterators/base_iterator.rbs +15 -0
  67. data/sig/iterators/object_iterator.rbs +6 -0
  68. data/sig/iterators/paginator_iterator.rbs +8 -0
  69. data/sig/iterators/rule_iterator.rbs +5 -0
  70. data/sig/iterators/synonym_iterator.rbs +5 -0
  71. data/sig/transport/request_options.rbs +33 -0
  72. data/sig/transport/stateful_host.rbs +21 -0
  73. data/test/algolia/integration/account_client_test.rb +47 -0
  74. data/test/algolia/integration/analytics_client_test.rb +113 -0
  75. data/test/algolia/integration/base_test.rb +9 -0
  76. data/test/algolia/integration/insights_client_test.rb +80 -0
  77. data/test/algolia/integration/mocks/mock_requester.rb +45 -0
  78. data/test/algolia/integration/recommendation_client_test.rb +30 -0
  79. data/test/algolia/integration/search_client_test.rb +361 -0
  80. data/test/algolia/integration/search_index_test.rb +698 -0
  81. data/test/algolia/unit/helpers_test.rb +69 -0
  82. data/test/algolia/unit/retry_strategy_test.rb +139 -0
  83. data/test/algolia/unit/user_agent_test.rb +16 -0
  84. data/test/test_helper.rb +89 -0
  85. data/upgrade_guide.md +595 -0
  86. metadata +307 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d60205951ef158935268ca5acdea467072a3e06355b1937a81ae78724da0e909
4
+ data.tar.gz: eba4990f0591fb94fbcbc4d7e834f9fdb8ff0092d05a05e658b5a89272999bd5
5
+ SHA512:
6
+ metadata.gz: e458b5c6be67e8c73338995485cfb01783e83d0e22be7bdce4fa0b23f7bedada8f9630ce274569a30ce7e792ad35324f22d8dbd2761e1ed5f08a6bbcd69984fb
7
+ data.tar.gz: 68b2b9af700d930b34ccab5340515935ee56b81eb1bec1703ae9cf4db6f7cb065322dc88705ebc8025e3579a065f6cbbed8b288347d2e15d7e68df4e54b378de
@@ -0,0 +1,146 @@
1
+ aliases:
2
+ - &check_bundler
3
+ name: Which bundler?
4
+ command: bundle -v
5
+
6
+ - &restore_cache
7
+ name: Restore Bundler cache
8
+ keys:
9
+ - ruby-cache-<< parameters.version >>-{{ checksum "Gemfile" }}
10
+ - ruby-cache-<< parameters.version >>-
11
+
12
+ - &install_bundler
13
+ name: Bundle Install
14
+ command: bundle check || bundle install
15
+
16
+ - &save_cache
17
+ name: Save Bundler cache
18
+ key: ruby-cache-<< parameters.version >>-{{ checksum "Gemfile" }}
19
+ paths:
20
+ - vendor/bundle
21
+
22
+ - &run_lint
23
+ name: Run linting tool
24
+ command: bundle exec rake rubocop
25
+
26
+ - &run_tests
27
+ name: Run unit and integration tests
28
+ command: |
29
+ mkdir /tmp/test-results
30
+ bundle exec rake test:all
31
+
32
+ references:
33
+ default_docker_ruby_executor: &default_docker_ruby_executor
34
+ image: circleci/ruby:<< parameters.version >>
35
+ environment:
36
+ BUNDLE_JOBS: 3
37
+ BUNDLE_RETRY: 3
38
+ BUNDLE_PATH: vendor/bundle
39
+
40
+ default_docker_jruby_executor: &default_docker_jruby_executor
41
+ image: circleci/jruby:<< parameters.version >>
42
+ environment:
43
+ BUNDLE_JOBS: 3
44
+ BUNDLE_RETRY: 3
45
+ BUNDLE_PATH: vendor/bundle
46
+
47
+ version: 2.1
48
+
49
+ jobs:
50
+ format:
51
+ description: Run our linter checks against the entire code base
52
+ parameters:
53
+ version:
54
+ type: string
55
+ docker:
56
+ - *default_docker_ruby_executor
57
+ steps:
58
+ - checkout
59
+ - run: *check_bundler
60
+ - run: *install_bundler
61
+ - run: *run_lint
62
+
63
+ test_ruby:
64
+ description: Build, unit and integration tests for Ruby
65
+ parameters:
66
+ version:
67
+ type: string
68
+ docker:
69
+ - *default_docker_ruby_executor
70
+ steps:
71
+ - checkout
72
+ - run: *check_bundler
73
+ - restore_cache: *restore_cache
74
+ - run: *install_bundler
75
+ - save_cache: *save_cache
76
+ - run: *run_tests
77
+
78
+ test_jruby:
79
+ description: Build, unit and integration tests for JRuby
80
+ parameters:
81
+ version:
82
+ type: string
83
+ docker:
84
+ - *default_docker_jruby_executor
85
+ steps:
86
+ - checkout
87
+ - run: *check_bundler
88
+ - restore_cache: *restore_cache
89
+ - run: *install_bundler
90
+ - save_cache: *save_cache
91
+ - run: *run_tests
92
+
93
+ release:
94
+ description: Release a new version of the Ruby client
95
+ parameters:
96
+ version:
97
+ type: string
98
+ docker:
99
+ - *default_docker_ruby_executor
100
+ steps:
101
+ - checkout
102
+ - run: *check_bundler
103
+ - run: *install_bundler
104
+ - run:
105
+ name: Build new gem
106
+ command: gem build algolia.gemspec
107
+ - run:
108
+ name: Publish new gem
109
+ command: |
110
+ if [[ -z "$RUBYGEMS_API_KEY" ]]; then echo '$RUBYGEMS_API_KEY is not set'; exit 1; fi
111
+ gem push --key $RUBYGEMS_API_KEY $(ls algolia-*.gem)
112
+
113
+ workflows:
114
+ version: 2
115
+ ci:
116
+ jobs:
117
+ - format:
118
+ version: '2.7'
119
+ filters:
120
+ tags:
121
+ only: /.*/
122
+ - test_ruby:
123
+ matrix:
124
+ parameters:
125
+ version: ['2.2', '2.3', '2.4', '2.5', '2.6', '2.7']
126
+ filters:
127
+ tags:
128
+ only: /.*/
129
+ - test_jruby:
130
+ matrix:
131
+ parameters:
132
+ version: ['9.1', '9.2']
133
+ filters:
134
+ tags:
135
+ only: /.*/
136
+ - release:
137
+ version: '2.7'
138
+ requires:
139
+ - format
140
+ - test_ruby
141
+ - test_jruby
142
+ filters:
143
+ branches:
144
+ ignore: /.*/
145
+ tags:
146
+ only: /^[1-9]+.[0-9]+.[0-9]+.*/
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Please use this issue tracker only for reporting bugs or feature requests.
3
+
4
+ If you need support, please use:
5
+
6
+ - our community forum
7
+ http://discourse.algolia.com
8
+
9
+ - StackOverflow with the `algolia` tag
10
+ https://stackoverflow.com/questions/tagged/algolia
11
+
12
+ -->
13
+
14
+ - Algolia Client Version: #.#.#
15
+ - Language Version:
16
+
17
+ ### Description
18
+
19
+
20
+ ### Steps To Reproduce
@@ -0,0 +1,22 @@
1
+ | Q | A
2
+ | ----------------- | ----------
3
+ | Bug fix? | yes/no
4
+ | New feature? | yes/no <!-- please update the /CHANGELOG.md file -->
5
+ | BC breaks? | no
6
+ | Related Issue | Fix #... <!-- will close issue automatically, if any -->
7
+ | Need Doc update | yes/no
8
+
9
+
10
+ ## Describe your change
11
+
12
+ <!--
13
+ Please describe your change, add as much detail as
14
+ necessary to understand your code.
15
+ -->
16
+
17
+ ## What problem is this fixing?
18
+
19
+ <!--
20
+ Please include everything needed to understand the problem,
21
+ its context and consequences, and, if possible, how to recreate it.
22
+ -->
@@ -0,0 +1,38 @@
1
+ # rspec failure tracking
2
+ .rspec_status
3
+
4
+ ## MAC OS
5
+ .DS_Store
6
+ .idea/
7
+
8
+ ## TEXTMATE
9
+ *.tmproj
10
+ tmtags
11
+
12
+ ## EMACS
13
+ *~
14
+ \#*
15
+ .\#*
16
+
17
+ ## VIM
18
+ *.swp
19
+
20
+ ## PROJECT::GENERAL
21
+ coverage
22
+ rdoc
23
+ pkg
24
+ .rvmrc
25
+ /.bundle/
26
+ /.yardoc
27
+ /_yardoc/
28
+ /coverage/
29
+ /doc/
30
+ /pkg/
31
+ /spec/reports/
32
+ /tmp/
33
+
34
+ ## PROJECT::SPECIFIC
35
+ Gemfile.lock
36
+ spec/integration_spec_conf.rb
37
+ data.sqlite3
38
+ debug.log
@@ -0,0 +1,186 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+
6
+ # Metrics
7
+ Metrics/BlockLength:
8
+ Enabled: false
9
+
10
+ Metrics/MethodLength:
11
+ Enabled: false
12
+
13
+ Metrics/AbcSize:
14
+ Enabled: false
15
+
16
+ Metrics/CyclomaticComplexity:
17
+ Enabled: false
18
+
19
+ Metrics/PerceivedComplexity:
20
+ Enabled: false
21
+
22
+ Metrics/ModuleLength:
23
+ Enabled: false
24
+
25
+ Metrics/ClassLength:
26
+ Enabled: false
27
+
28
+ Metrics/ParameterLists:
29
+ Enabled: false
30
+
31
+ # Lint
32
+ Lint/UnreachableCode:
33
+ Exclude:
34
+ - 'Dangerfile'
35
+
36
+ Lint/RaiseException:
37
+ Enabled: true
38
+
39
+ Lint/StructNewOverride:
40
+ Enabled: true
41
+
42
+ # Naming
43
+ Naming/AccessorMethodName:
44
+ Enabled: false
45
+
46
+ Naming/VariableName:
47
+ Enabled: false
48
+
49
+ Naming/MethodParameterName:
50
+ AllowedNames:
51
+ - 'autoGenerateObjectIDIfNotExist'
52
+
53
+ # Disabled since it's not working when using variables instead of a name
54
+ Naming/RescuedExceptionsVariableName:
55
+ Enabled: false
56
+
57
+ # Layout
58
+ Layout/LineLength:
59
+ Enabled: false
60
+
61
+ Layout/SpaceAroundOperators:
62
+ Enabled: false
63
+
64
+ Layout/IndentationWidth:
65
+ Enabled: false
66
+
67
+ Layout/EmptyLineAfterGuardClause:
68
+ Enabled: false
69
+
70
+ Layout/RescueEnsureAlignment:
71
+ Enabled: false
72
+
73
+ Layout/IndentationConsistency:
74
+ Exclude:
75
+ - 'app/helpers/demos_helper.rb'
76
+
77
+ Layout/ParameterAlignment:
78
+ EnforcedStyle: with_fixed_indentation
79
+
80
+ Layout/MultilineMethodCallIndentation:
81
+ EnforcedStyle: indented
82
+
83
+ Layout/MultilineOperationIndentation:
84
+ EnforcedStyle: indented
85
+ IndentationWidth: 2
86
+
87
+ Layout/SpaceInLambdaLiteral:
88
+ EnforcedStyle: require_space
89
+
90
+ Layout/CaseIndentation:
91
+ EnforcedStyle: end
92
+
93
+ Layout/FirstHashElementIndentation:
94
+ EnforcedStyle: consistent
95
+
96
+ Layout/FirstArrayElementIndentation:
97
+ EnforcedStyle: consistent
98
+
99
+ Layout/EndAlignment:
100
+ EnforcedStyleAlignWith: start_of_line
101
+
102
+ Layout/ExtraSpacing:
103
+ AllowBeforeTrailingComments: true
104
+ # When true, forces the alignment of `=` in assignments on consecutive lines.
105
+ ForceEqualSignAlignment: true
106
+
107
+ # Style
108
+ Style/Documentation:
109
+ Enabled: false
110
+
111
+ Style/FrozenStringLiteralComment:
112
+ Enabled: false
113
+
114
+ Style/NumericLiterals:
115
+ Enabled: false
116
+
117
+ Style/IfUnlessModifier:
118
+ Enabled: false
119
+
120
+ Style/WhileUntilModifier:
121
+ Enabled: false
122
+
123
+ Style/NumericPredicate:
124
+ Enabled: false
125
+
126
+ Style/ClassAndModuleChildren:
127
+ Enabled: false
128
+
129
+ Style/GuardClause:
130
+ Enabled: false
131
+
132
+ Style/EmptyMethod:
133
+ Enabled: false
134
+
135
+ Style/Next:
136
+ Enabled: false
137
+
138
+ Style/NegatedIf:
139
+ Enabled: false
140
+
141
+ Style/RedundantSelf:
142
+ Enabled: true
143
+
144
+ Style/SymbolArray:
145
+ Enabled: false
146
+
147
+ Style/SafeNavigation:
148
+ Enabled: false
149
+
150
+ Style/SignalException:
151
+ Exclude:
152
+ - 'Dangerfile'
153
+
154
+ Style/PreferredHashMethods:
155
+ EnforcedStyle: verbose
156
+
157
+ Style/Alias:
158
+ EnforcedStyle: prefer_alias_method
159
+
160
+ Style/Lambda:
161
+ EnforcedStyle: literal
162
+
163
+ Style/PercentLiteralDelimiters:
164
+ PreferredDelimiters:
165
+ default: '()'
166
+ '%w': '()'
167
+ '%W': '()'
168
+ '%i': '()'
169
+
170
+ Style/MutableConstant:
171
+ Enabled: false
172
+
173
+ Style/ClassVars:
174
+ Enabled: false
175
+
176
+ Style/SpecialGlobalVars:
177
+ Enabled: false
178
+
179
+ Style/HashTransformKeys:
180
+ Enabled: false
181
+
182
+ Style/HashTransformValues:
183
+ Enabled: false
184
+
185
+ Style/HashEachMethods:
186
+ Enabled: true
@@ -0,0 +1,14 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-12-12 11:07:55 +0100 using RuboCop version 0.77.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Style/Documentation:
11
+ Exclude:
12
+ - 'spec/**/*'
13
+ - 'test/**/*'
14
+ - 'lib/rubybundle/search_config.rb'
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at chloe.liban@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/