splunk-sdk-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/CHANGELOG.md +160 -0
  2. data/Gemfile +8 -0
  3. data/LICENSE +177 -0
  4. data/README.md +310 -0
  5. data/Rakefile +40 -0
  6. data/examples/1_connect.rb +51 -0
  7. data/examples/2_manage.rb +103 -0
  8. data/examples/3_blocking_searches.rb +82 -0
  9. data/examples/4_asynchronous_searches.rb +79 -0
  10. data/examples/5_stream_data_to_splunk.rb +79 -0
  11. data/lib/splunk-sdk-ruby.rb +47 -0
  12. data/lib/splunk-sdk-ruby/ambiguous_entity_reference.rb +28 -0
  13. data/lib/splunk-sdk-ruby/atomfeed.rb +323 -0
  14. data/lib/splunk-sdk-ruby/collection.rb +417 -0
  15. data/lib/splunk-sdk-ruby/collection/apps.rb +35 -0
  16. data/lib/splunk-sdk-ruby/collection/case_insensitive_collection.rb +58 -0
  17. data/lib/splunk-sdk-ruby/collection/configuration_file.rb +50 -0
  18. data/lib/splunk-sdk-ruby/collection/configurations.rb +80 -0
  19. data/lib/splunk-sdk-ruby/collection/jobs.rb +136 -0
  20. data/lib/splunk-sdk-ruby/collection/messages.rb +51 -0
  21. data/lib/splunk-sdk-ruby/context.rb +522 -0
  22. data/lib/splunk-sdk-ruby/entity.rb +260 -0
  23. data/lib/splunk-sdk-ruby/entity/index.rb +191 -0
  24. data/lib/splunk-sdk-ruby/entity/job.rb +339 -0
  25. data/lib/splunk-sdk-ruby/entity/message.rb +36 -0
  26. data/lib/splunk-sdk-ruby/entity/saved_search.rb +71 -0
  27. data/lib/splunk-sdk-ruby/entity/stanza.rb +45 -0
  28. data/lib/splunk-sdk-ruby/entity_not_ready.rb +26 -0
  29. data/lib/splunk-sdk-ruby/illegal_operation.rb +27 -0
  30. data/lib/splunk-sdk-ruby/namespace.rb +239 -0
  31. data/lib/splunk-sdk-ruby/resultsreader.rb +716 -0
  32. data/lib/splunk-sdk-ruby/service.rb +339 -0
  33. data/lib/splunk-sdk-ruby/splunk_http_error.rb +49 -0
  34. data/lib/splunk-sdk-ruby/synonyms.rb +50 -0
  35. data/lib/splunk-sdk-ruby/version.rb +27 -0
  36. data/lib/splunk-sdk-ruby/xml_shim.rb +117 -0
  37. data/splunk-sdk-ruby.gemspec +27 -0
  38. data/test/atom_test_data.rb +472 -0
  39. data/test/data/atom/atom_feed_with_message.xml +19 -0
  40. data/test/data/atom/atom_with_feed.xml +99 -0
  41. data/test/data/atom/atom_with_several_entries.xml +101 -0
  42. data/test/data/atom/atom_with_simple_entries.xml +30 -0
  43. data/test/data/atom/atom_without_feed.xml +248 -0
  44. data/test/data/export/4.2.5/export_results.xml +88 -0
  45. data/test/data/export/4.3.5/export_results.xml +87 -0
  46. data/test/data/export/5.0.1/export_results.xml +78 -0
  47. data/test/data/export/5.0.1/nonreporting.xml +232 -0
  48. data/test/data/results/4.2.5/results-empty.xml +0 -0
  49. data/test/data/results/4.2.5/results-preview.xml +255 -0
  50. data/test/data/results/4.2.5/results.xml +336 -0
  51. data/test/data/results/4.3.5/results-empty.xml +0 -0
  52. data/test/data/results/4.3.5/results-preview.xml +1057 -0
  53. data/test/data/results/4.3.5/results.xml +626 -0
  54. data/test/data/results/5.0.2/results-empty.xml +1 -0
  55. data/test/data/results/5.0.2/results-empty_preview.xml +1 -0
  56. data/test/data/results/5.0.2/results-preview.xml +448 -0
  57. data/test/data/results/5.0.2/results.xml +501 -0
  58. data/test/export_test_data.json +360 -0
  59. data/test/resultsreader_test_data.json +1119 -0
  60. data/test/services.server.info.xml +43 -0
  61. data/test/services.xml +111 -0
  62. data/test/test_atomfeed.rb +71 -0
  63. data/test/test_collection.rb +278 -0
  64. data/test/test_configuration_file.rb +124 -0
  65. data/test/test_context.rb +119 -0
  66. data/test/test_entity.rb +95 -0
  67. data/test/test_helper.rb +250 -0
  68. data/test/test_http_error.rb +52 -0
  69. data/test/test_index.rb +91 -0
  70. data/test/test_jobs.rb +319 -0
  71. data/test/test_messages.rb +17 -0
  72. data/test/test_namespace.rb +188 -0
  73. data/test/test_restarts.rb +49 -0
  74. data/test/test_resultsreader.rb +106 -0
  75. data/test/test_roles.rb +41 -0
  76. data/test/test_saved_searches.rb +119 -0
  77. data/test/test_service.rb +65 -0
  78. data/test/test_users.rb +33 -0
  79. data/test/test_xml_shim.rb +28 -0
  80. data/test/testfile.txt +1 -0
  81. metadata +200 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,160 @@
1
+ # Splunk SDK for Ruby Changelog
2
+
3
+ ## Version 0.1.0 (preview)
4
+
5
+ ### Breaking changes
6
+
7
+ * The Splunk SDK for Ruby now uses the same **.splunkrc** format as the other SDKs.
8
+ * Moved `Service#connect` to being a static method of the `Splunk` module, so you now call connect as
9
+
10
+ service = Splunk::connect(...)
11
+
12
+ instead of
13
+
14
+ service = Splunk::Service.connect(...)
15
+
16
+ * **aloader.rb** and the `AtomResponseLoader` it contained have been replaced in their entirety by atomfeed.rb and the `AtomFeed` class it contains.
17
+ * Changes to `Context`:
18
+ * Removed `Context#post`, `Context#delete`, and `Context#get`. Replaced
19
+ them all with `Context#request` (which takes a structured specification of
20
+ the resource) and `Context#request_by_url` (which takes an already
21
+ constructed URL to the resource).
22
+ * Removed the methods `Context#fullpath`, `Context#init_default`,
23
+ `Context#url`, `Context#create_resource`, `Context#check_for_error_return`,
24
+ `Context#build_stream`, `Context#handle_key`, `Context#flatten_params`,
25
+ and `Context#flatten_params_array` since simplification of the request
26
+ infrastructure made them unnecessary.
27
+ * Renamed `Context#protocol` to `Context#scheme` to match correct naming in RFC.
28
+ * Removed the `parse` method from `Service`, since it didn't actually parse
29
+ the response in any useful way.
30
+ * Changes to naming of the configuration endpoints:
31
+ * `ConfCollection` renamed to `ConfigurationFile` (and **conf_collection.rb**
32
+ renamed to **configuration_file.rb**).
33
+ * `Conf` renamed to `Stanza` (and **conf.rb** renamed to **stanza.rb**).
34
+ * `Index#submit` and `Index#attach` now take hash arguments instead of positional
35
+ arguments.
36
+ * `Job#setttl` renamed to `Job#set_ttl`.
37
+ * `Job#setpriority` renamed to `Job#set_priority`.
38
+ * `Job#disable_preview` removed, since a working test scenario couldn't be found
39
+ for it.
40
+ * `Collection`'s constructor arguments have changed.
41
+ * `Entity`'s constructor arguments have changed.
42
+ * `SplunkError` has been removed, and `SplunkHTTPError` has been made a direct
43
+ subclass of `StandardError`.
44
+ * Deleted `SearchResults`, since it was superseded by `ResultsReader`.
45
+ * The metaprogramming to allow fetching entries of a `Hash` via dot notation has
46
+ been removed. That is, `hash.key` is no longer a synonym for `hash["key"]`.
47
+ * The `urlencode` method previously monkeypatched onto `Hash` has been removed.
48
+ * `Service#create_collection` was removed.
49
+
50
+ ### New features and APIs
51
+
52
+ * New examples in the **/examples** directory, showing how to:
53
+ * connect to Splunk
54
+ * manage entities in Splunk
55
+ * run searches and fetch their results from Splunk
56
+ * write data into Splunk
57
+ * The whole SDK now handles namespaces properly, and namespaces are first class
58
+ objects. See the header comments of **namespace.rb** for a detailed description
59
+ of Splunk namespaces and their representation in this SDK.
60
+ * All XML handling is shimmed to work with either Nokogiri or REXML. It tries
61
+ Nokogiri first, which can process XML vastly faster, and falls back to REXML,
62
+ which will be present in all Ruby installs. The user may all call
63
+ `require_xml_library` to force the SDK to use a Nokogiri or REXML. See
64
+ **xml_shim.rb** for all this behavior.
65
+ * Added documentation throughout the SDK.
66
+ * The unit testing suite has been completely rewritten and expanded.
67
+ * Added a `ResultsReader` class to parse and iterate over sets of XML results from
68
+ search jobs.
69
+ * Added methods to `Context`:
70
+ * `host`
71
+ * `port`
72
+ * `token`
73
+ * `username`
74
+ * `password`
75
+ * `namespace`
76
+ * `server_accepting_connections?`
77
+ * `Context#restart` takes an optional timeout, and properly handles waiting for
78
+ Splunk to restart.
79
+ * Added convenience methods to `Service` to create searches:
80
+ * `create_oneshot`
81
+ * `create_search`
82
+ * `create_stream`
83
+ * Added methods to `Service`:
84
+ * `splunk_version`
85
+ * `saved_searches`
86
+ * New features added to `Collection`:
87
+ * `Collection#each`, when called without a block, now returns an enumerator over
88
+ all elements in the collection.
89
+ * Added an optional _namespace_ argument to `Collection#delete` and
90
+ `Collection#fetch` so entities can be specified uniquely even in the presence
91
+ of name collisions.
92
+ * Added new methods to `Collection`, mostly designed to recapitulate the
93
+ relevant methods of `Hash`. In the notation below, synonym sets are separated
94
+ by slashes, and names in a set of synonyms that already existed are
95
+ surrounded by square brackets:
96
+ * `[contains?]/has_key?/include?/key?/member?`
97
+ * `[list]/values/to_a`
98
+ * `each_key`
99
+ * `each_pair`
100
+ * `empty?`
101
+ * `entity_class`
102
+ * `fetch/[ [] ]`
103
+ * `keys`
104
+ * `length`
105
+ * `resource`
106
+ * `service`
107
+ * Added methods to `Entity`. In the notation below, synonym sets are separated
108
+ by slashes, and names in a set of synonyms that already existed are
109
+ surrounded by square brackets:
110
+ * `content`
111
+ * `delete`
112
+ * `fetch/[ [] ]`
113
+ * `links`
114
+ * `namespace`
115
+ * `refresh`
116
+ * `resource`
117
+ * `service`
118
+ * Entities now cache their state. To update the cache, call the entity's `refresh`
119
+ method.
120
+ * `Index#clean` takes a timeout instead of waiting forever. If no timeout is
121
+ specified, a default value will be used.
122
+ * Added new methods to `Job`. In the notation below, synonym sets are separated
123
+ by slashes, and names in a set of synonyms that already existed are
124
+ surrounded by square brackets:
125
+ * `control`
126
+ * `is_done?`
127
+ * `is_ready?`
128
+ * `sid`
129
+ * Added saved search support, accessible via `Service#saved_searches`. `SavedSearch`
130
+ entities have the following additional methods beyond `Entity`:
131
+ * `dispatch`
132
+ * `history`
133
+ * Added the following methods to `Stanza` (was: `Conf`). In the notation below, synonym sets are separated by slashes, and names in a set of synonyms that already existed are surrounded by square brackets:
134
+ * `length`
135
+ * `update/[submit]`
136
+ * Added new custom exceptions:
137
+ * `AmbiguousEntityReference`, for when a fetch of an entity by name would
138
+ return multiple entities due to name collisions.
139
+ * `EntityNotReady`, raised when a program tries to fetch the state of an entity
140
+ which is queued for creation, but not yet created, such as a search job that
141
+ is not yet ready.
142
+ * `IllegalOperation`, raised by a program when an operation known statically not
143
+ to work, such as deleting an index on Splunk 4.x, is called.
144
+
145
+ ### Architectural changes
146
+
147
+ * `Job` is now a subclass of `Entity`.
148
+ * `Service` is now a subclass of `Context` instead of including the `Context` as
149
+ an instance variable.
150
+ * Removed dependence of `Context` (and the SDK) on the libraries `netrc`, `pathname`,
151
+ and `rest-client`. Now it uses only the standard library plus (optionally)
152
+ Nokogiri.
153
+ * Reorganized directory structure of the SDK.
154
+ * The contents of `lib/splunk-sdk-ruby/client/` have been moved to
155
+ `lib/splunk-sdk-ruby`, and **client.rb** has been deleted.
156
+ * **jobs.rb** was moved to `lib/splunk-sdk-ruby/collection/`
157
+ * **job.rb** was moved to `lib/splunk-sdk-ruby/entity/`
158
+ * Made all unit test filenames start with **test_** instead of **tc_**.
159
+
160
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+ # This line is required to let RubyMine run the test suite,
3
+ # since otherwise random packages load other random packages
4
+ # in random order and clobber RubyMine's configuration.
5
+ # See http://youtrack.jetbrains.com/issue/RUBY-11922
6
+ gem 'test-unit', :require => false
7
+ gem 'nokogiri', :require => true
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
data/README.md ADDED
@@ -0,0 +1,310 @@
1
+ # The Splunk Software Development Kit for Ruby (Preview Release)
2
+
3
+ #### Version 0.1
4
+ This Splunk Software Development Kit (SDK) contains library code and examples
5
+ designed to enable developers to build applications using Splunk.
6
+
7
+ Splunk is a search engine and analytic environment that uses a distributed
8
+ map-reduce architecture to efficiently index, search, and process large
9
+ time-varying data sets.
10
+
11
+ The Splunk product is popular with system administrators for aggregation and
12
+ monitoring of IT machine data, security, compliance, and a wide variety of
13
+ other scenarios that share a requirement to efficiently index, search, analyze,
14
+ and generate real-time notifications from large volumes of time series data.
15
+
16
+ The Splunk developer platform enables developers to take advantage of the
17
+ same technology used by the Splunk product to build exciting new applications
18
+ that are enabled by Splunk's unique capabilities.
19
+
20
+ 1. This Preview release is pre-beta, and therefore is incomplete and may have
21
+ bugs. A Beta release is planned prior to a general release.
22
+
23
+ 2. The Apache license only applies to this SDK and no other software provided
24
+ by Splunk.
25
+
26
+ 3. Splunk, in using the Apache license, is not providing any warranties or
27
+ indemnification, or accepting any liabilities with the Preview of this SDK.
28
+
29
+ ## Getting started with the Splunk SDK for Ruby
30
+
31
+ The Splunk SDK for Ruby contains code and some examples that show how to
32
+ programmatically interact with Splunk for a variety of scenarios, including
33
+ searching, saved searches, configuration, and many more. This SDK is still
34
+ in progress and is missing features such as inputs. Stay tuned.
35
+
36
+
37
+ ### Requirements
38
+
39
+ Here's what you need to get going with the Splunk SDK for Ruby.
40
+
41
+ #### Splunk
42
+
43
+ If you haven't already installed Splunk, download it
44
+ [here](http://www.splunk.com/download). For more information about installing
45
+ and running Splunk and system requirements, see
46
+ [Installing & Running Splunk](http://dev.splunk.com/view/SP-CAAADRV).
47
+
48
+ #### Ruby
49
+
50
+ The Splunk SDK for Ruby requires Ruby 1.9.2 or later.
51
+
52
+ #### Splunk SDK for Ruby
53
+
54
+ Get the Splunk SDK for Ruby from [GitHub](https://www.github.com) and clone the
55
+ resources to your computer. Use the following command:
56
+
57
+ git clone https://github.com/splunk/splunk-sdk-ruby.git
58
+
59
+ You can also download the SDK as a ZIP file, or install it directly (see below).
60
+
61
+
62
+ ### Installing the Splunk SDK for Ruby
63
+
64
+ If you have cloned the Splunk SDK for Ruby from GitHub, you should first
65
+ install the latest version of `rake`. For example, open a command prompt and
66
+ enter the following:
67
+
68
+ gem install rake
69
+
70
+ Then you can install the Splunk SDK for Ruby by running the following
71
+ command from the root of the repository (**/splunk-sdk-ruby**):
72
+
73
+ rake install
74
+
75
+ Or, install the Splunk SDK for Ruby directly from RubyGems,
76
+ without cloning the repository or downloading the ZIP file, by running:
77
+
78
+ gem install splunk-sdk-ruby
79
+
80
+ If you are using the Splunk SDK for Ruby in an application, we highly
81
+ recommend that you use [bundler](http://gembundler.com/), which installs
82
+ the prerequisites when you deploy your application. Add the following
83
+ line to your application's Gemfile to make bundler aware of the Splunk
84
+ SDK for Ruby:
85
+
86
+ gem 'splunk-sdk-ruby'
87
+
88
+ Then run the following command to install all of your application's
89
+ dependencies, including the Splunk SDK for Ruby:
90
+
91
+ bundle
92
+
93
+ #### Examples
94
+
95
+ Examples are located in several locations within the Splunk SDK for Ruby:
96
+
97
+ * The **/splunk-sdk-ruby/examples/** directory
98
+ * Inline with the source code within the SDK
99
+ * In the documentation on the [Splunk Developer Portal](http://dev.splunk.com/view/ruby-sdk/SP-CAAAENQ).
100
+
101
+ #### Prepare for the unit tests
102
+
103
+ First, do not run the test suite against your production Splunk server! Install
104
+ another copy of Splunk and run the test suite against that.
105
+
106
+ Second, update your installations of both the [Rake](http://rake.rubyforge.org)
107
+ build tool and the [Test::Unit](http://test-unit.rubyforge.org) unit
108
+ test framework from RubyGems:
109
+
110
+ gem install rake
111
+ gem install test-unit
112
+
113
+ The test suite reads the host to connect to and credentials to use from a
114
+ **.splunkrc** file. To connect to Splunk, all of the SDK examples and unit
115
+ tests take command-line arguments that specify values for the host, port,
116
+ and login credentials for Splunk. For convenience during development, you
117
+ can store these arguments as key-value pairs in a text file named
118
+ **.splunkrc**. Then, when you don't specify these arguments at the command
119
+ line, the SDK examples and unit tests use the values from the .splunkrc file.
120
+
121
+ **To set up a .splunkrc file**
122
+
123
+ 1. Create a text file with the following format:
124
+
125
+ <pre> # Splunk host (default: localhost)
126
+ host=localhost
127
+ # Splunk admin port (default: 8089)
128
+ port=8089
129
+ # Splunk username
130
+ username=admin
131
+ # Splunk password
132
+ password=changeme
133
+ # Access scheme (default: https)
134
+ scheme=https
135
+ # Your version of Splunk (default: 5.0)
136
+ version=5.0</pre>
137
+
138
+ 2. Save the file as .splunkrc in the current user's home directory.
139
+
140
+ **On Mac OS X**
141
+
142
+ Save the file as:
143
+
144
+ ~/.splunkrc
145
+
146
+ **On Windows**
147
+
148
+ Save the file as:
149
+
150
+ C:\Users\[currentusername]\.splunkrc
151
+
152
+ You might get errors in Windows when you try to name the file because
153
+ ".splunkrc" looks like a nameless file with an extension. You can use
154
+ the command line to create this file; go to the
155
+ **C:\Users\\[currentusername]\\** directory and enter the following command:
156
+
157
+ Notepad.exe .splunkrc
158
+
159
+ Click **Yes**, then continue creating the file.
160
+
161
+ **Notes**
162
+
163
+ * Storing login credentials in the .splunkrc file is only for
164
+ convenience during development; this file isn't part of the
165
+ Splunk platform and shouldn't be used for storing user credentials
166
+ for production. And, if you're at all concerned about the security
167
+ of your credentials, just enter them at the command line and don't
168
+ bother using the .splunkrc file.
169
+ * The format of the .splunkrc file has changed between releases. If
170
+ you are using a preview or beta version of the SDK, some of the
171
+ newer fields might not be recognized and you might see errors while
172
+ running the examples. You can either update to the latest version
173
+ of the SDK, or comment out the <tt>app</tt>, <tt>owner</tt>, and
174
+ <tt>version</tt> fields.
175
+ * The <tt>version</tt> field is only used by the Splunk SDK for JavaScript.
176
+
177
+ #### Run the unit tests
178
+
179
+ In the base directory where you installed the Splunk SDK for Ruby, run
180
+
181
+ rake test
182
+
183
+ It should run many tests without error.
184
+
185
+ To generate code coverage of the test suite, first ensure you've installed
186
+ the latest version of [SimpleCov](http://rubygems.org/gems/simplecov):
187
+
188
+ gem install simplecov
189
+
190
+ To generate the code coverage, run:
191
+
192
+ rake test COVERAGE=true
193
+
194
+ It will produce a directory called **coverage**. Open coverage/index.html to
195
+ see the coverage report.
196
+
197
+ **Note**: To protect your Splunk password, you may want to delete the .splunkrc
198
+ file when you are done running the unit tests.
199
+
200
+ ## Repository
201
+
202
+ <table>
203
+
204
+ <tr>
205
+ <tr>
206
+ <td><b>/examples</b></td>
207
+ <td>Examples demonstrating various SDK features</td>
208
+ </tr>
209
+
210
+ <tr>
211
+ <td><b>/lib</b></td>
212
+ <td>Source for the Splunk library modules</td>
213
+ </tr>
214
+
215
+ <tr>
216
+ <td><b>/test</b></td>
217
+ <td>Source for unit tests</td>
218
+ </tr>
219
+
220
+ </table>
221
+
222
+ ### Changelog
223
+
224
+ The **CHANGELOG.md** file in the root of the repository contains a description
225
+ of changes for each version of the SDK. You can also find it online at
226
+ [https://github.com/splunk/splunk-sdk-ruby/blob/master/CHANGELOG.md](https://github.com/splunk/splunk-sdk-ruby/blob/master/CHANGELOG.md).
227
+
228
+ ### Branches
229
+
230
+ The **master** branch always represents a stable and released version of the SDK.
231
+
232
+ ## Documentation and resources
233
+
234
+ If you need to know more:
235
+
236
+ * For all things developer with Splunk, your main resource is the [Splunk Developer Portal](http://dev.splunk.com).
237
+
238
+ * For conceptual and how-to documentation, see the [Overview of the Splunk SDK for Ruby](http://dev.splunk.com/view/SP-CAAAENQ).
239
+
240
+ * For API reference documentation, see the [Splunk SDK for Ruby Reference](http://docs.splunk.com/Documentation/RubySDK).
241
+
242
+ * For more about the Splunk REST API, see the [REST API Reference](http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI).
243
+
244
+ * For more about about Splunk in general, see [Splunk>Docs](http://docs.splunk.com/Documentation/Splunk).
245
+
246
+ * For more about this SDK's repository, see our [GitHub Wiki](https://github.com/splunk/splunk-sdk-ruby/wiki/).
247
+
248
+ ## Community
249
+
250
+ <table>
251
+
252
+ <tr>
253
+ <td><b>Email</b></td>
254
+ <td><a href="mailto:devinfo@splunk.com">devinfo@splunk.com</a></td>
255
+ </tr>
256
+
257
+ <tr>
258
+ <td><strong>Forum</strong></td>
259
+ <td><a href="https://groups.google.com/forum/#!forum/splunkdev">https://groups.google.com/forum/#!forum/splunkdev</a>
260
+ </tr>
261
+
262
+ <tr>
263
+ <td><b>Issues</b>
264
+ <td><a href="https://github.com/splunk/splunk-sdk-ruby/issues/">https://github.com/splunk/splunk-sdk-ruby/issues/</a></td>
265
+ </tr>
266
+
267
+ <tr>
268
+ <td><b>Answers</b>
269
+ <td><a href="http://splunk-base.splunk.com/tags/ruby/">http://splunk-base.splunk.com/tags/ruby/</a></td>
270
+ </tr>
271
+
272
+ <tr>
273
+ <td><b>Blog</b>
274
+ <td><a href="http://blogs.splunk.com/dev/">http://blogs.splunk.com/dev/</a></td>
275
+ </tr>
276
+
277
+ <tr>
278
+ <td><b>Twitter</b>
279
+ <td><a href="http://twitter.com/#!/splunkdev">@splunkdev</a></td>
280
+ </tr>
281
+
282
+ </table>
283
+
284
+ ### How to contribute
285
+
286
+ If you would like to contribute to the SDK, go here for more information:
287
+
288
+ * [Splunk and open source](http://dev.splunk.com/view/opensource/SP-CAAAEDM)
289
+
290
+ * [Individual contributions](http://dev.splunk.com/goto/individualcontributions)
291
+
292
+ * [Company contributions](http://dev.splunk.com/view/companycontributions/SP-CAAAEDR)
293
+
294
+ ### Support
295
+
296
+ * SDKs in Preview are not Splunk supported. Once the Splunk SDK for Ruby moves to
297
+ an open beta we will provide more detail on support.
298
+
299
+ * File any issues on
300
+ [GitHub](https://github.com/splunk/splunk-sdk-ruby/issues).
301
+
302
+ ### Contact Us
303
+
304
+ You can reach the Dev Platform team at <a href="mailto:devinfo@splunk.com">
305
+ devinfo@splunk.com</a>.
306
+
307
+ ## License
308
+
309
+ The Splunk Software Development Kit for Ruby is licensed under the Apache
310
+ License 2.0. Details can be found in the LICENSE file.