ravendb-api-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +16 -0
- data/README.md +35 -0
- data/Rakefile +31 -0
- data/appveyor.yml +28 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/lib/ravendb/api/client.rb +108 -0
- data/lib/ravendb/api/client/version.rb +5 -0
- data/ravendb-api-client.gemspec +28 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9238a8b6bbec9ba64c8afb27c0d9d01fc7630dcfa16ae13925c060c7451696c
|
4
|
+
data.tar.gz: 32353c5ce224b3a79b5f01400e4a33fdd90473c0a4963d597bb98b66ed159f4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 37a1c16c5743757efb49aa9bad000172ecae277fae9f2cf2750af7d79875d57ec0cf9416f49c8e63f882db3f8ea02169ef8f82aeba5566b765738ea50dc86073
|
7
|
+
data.tar.gz: 7b515df59b357421ea547422204c09e4efee6391941648f3c957b65ebf4613f4eb04ef7bb70b1fdc388bc7b5e8775b1a8ccb8322e44e3645edd4b50100c77d25
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in ravendb-api-client.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'beaker'
|
9
|
+
gem 'beaker-puppet_install_helper'
|
10
|
+
gem 'beaker-rspec'
|
11
|
+
gem 'serverspec'
|
12
|
+
gem 'winrm'
|
13
|
+
gem 'puppet'
|
14
|
+
gem "beaker-testmode_switcher"
|
15
|
+
gem 'rspec-collection_matchers'
|
16
|
+
gem 'github_changelog_generator'
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ravendb::Api::Client
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ravendb/api/client`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ravendb-api-client'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ravendb-api-client
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ravendb-api-client.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require 'github_changelog_generator/task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
6
|
+
t.rspec_opts = ['--color']
|
7
|
+
t.exclude_pattern = "spec/acceptance/*"
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
desc "Run beaker acceptance tests"
|
13
|
+
RSpec::Core::RakeTask.new(:beaker) do |t|
|
14
|
+
t.rspec_opts ||= []
|
15
|
+
t.rspec_opts << "--color"
|
16
|
+
if (ENV['APPVEYOR'])
|
17
|
+
ENV['BEAKER_localmode'] = 'yes'
|
18
|
+
end
|
19
|
+
if (ENV['BEAKER_localmode'])
|
20
|
+
t.rspec_opts << "-r ./spec/spec_helper_acceptance_local"
|
21
|
+
else
|
22
|
+
t.rspec_opts << "-r ./spec/spec_helper_acceptance"
|
23
|
+
end
|
24
|
+
t.pattern = 'spec/acceptance'
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
desc 'Generates a changelog'
|
29
|
+
task :generate_changelog do
|
30
|
+
sh("github_changelog_generator --cache_log C:/github-changelog-logger.log --token #{ENV['CHANGELOG_GITHUB_TOKEN']}")
|
31
|
+
end
|
data/appveyor.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
version: 1.0.{build}-{branch}
|
3
|
+
os: Windows Server 2012 R2
|
4
|
+
|
5
|
+
install:
|
6
|
+
- set PATH=C:\Ruby22\bin;%PATH%
|
7
|
+
- bundle install --path .bundle
|
8
|
+
|
9
|
+
build: off
|
10
|
+
|
11
|
+
before_test:
|
12
|
+
- ruby -v
|
13
|
+
- gem -v
|
14
|
+
- bundle -v
|
15
|
+
|
16
|
+
test_script:
|
17
|
+
- bundle exec rake spec
|
18
|
+
- bundle exec rake beaker
|
19
|
+
|
20
|
+
|
21
|
+
notifications:
|
22
|
+
- provider: Slack
|
23
|
+
incoming_webhook:
|
24
|
+
secure: oYviEmkGtgAO8Ij90h3s60tvql2KDBmHGkL7YHb1HAdd2hlEHsC36Xkew7Ei01nUsI7ZfcvbbjDCu+lImrHOpl4Jcmvd5lsZL9k1bhxup7Q=
|
25
|
+
channel: general
|
26
|
+
on_build_success: true
|
27
|
+
on_build_failure: true
|
28
|
+
on_build_status_changed: false
|
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "ravendb/api/client"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
|
+
|
data/bin/setup
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
require "ravendb/api/client/version"
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
# RavenDB HTTP Api
|
7
|
+
# https://ravendb.net/docs/article-page/3.5/http/client-api/commands/how-to/get-database-configuration
|
8
|
+
module Ravendb
|
9
|
+
module Api
|
10
|
+
class Client
|
11
|
+
|
12
|
+
attr_reader :url
|
13
|
+
|
14
|
+
def initialize(url:)
|
15
|
+
@url = URI(url)
|
16
|
+
end
|
17
|
+
|
18
|
+
def databases
|
19
|
+
get(url: @url + get_databases_endpoint())
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_database(name:)
|
23
|
+
get(url: @url + create_delete_database_endpoint() + name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def database_exists?(name:)
|
27
|
+
databases.include?(name)
|
28
|
+
end
|
29
|
+
|
30
|
+
# $body = @{
|
31
|
+
# Settings = @{
|
32
|
+
# "Raven/DataDir" = "~\Databases\$RavenDatabaseName"
|
33
|
+
# "Raven/ActiveBundles" = "PeriodicBackup;DocumentExpiration;SqlReplication"
|
34
|
+
# }
|
35
|
+
# Disabled = $false
|
36
|
+
# }
|
37
|
+
#
|
38
|
+
# Invoke-RestMethod -Uri http://$($HostName):$($Port)/admin/databases/$RavenDatabaseName -Method PUT -Body (ConvertTo-Json $body)
|
39
|
+
# test(options: { Settings: 'test'})
|
40
|
+
# test(options: { :Settings => 'test'})
|
41
|
+
def create_database(name:, options: {})
|
42
|
+
default_options = {
|
43
|
+
Settings: {
|
44
|
+
'Raven/ActiveBundles': '',
|
45
|
+
'Raven/DataDir': "~/#{name}"
|
46
|
+
},
|
47
|
+
Disabled: false
|
48
|
+
}
|
49
|
+
|
50
|
+
create_database_options = default_options.merge(options)
|
51
|
+
put(url: @url + create_delete_database_endpoint() + name, json_hash: create_database_options)
|
52
|
+
end
|
53
|
+
# Invoke-RestMethod -Uri http://$($HostName):$($Port)/admin/databases/$RavenDatabaseName`?hard-delete=true -Method Delete
|
54
|
+
def delete_database(name:)
|
55
|
+
delete(url: @url + create_delete_database_endpoint() + name)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def create_delete_database_endpoint
|
60
|
+
return '/admin/databases/'
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_databases_endpoint
|
64
|
+
return '/databases'
|
65
|
+
end
|
66
|
+
|
67
|
+
def get(url:)
|
68
|
+
_url = URI(url)
|
69
|
+
http = Net::HTTP.new(_url.host, _url.port)
|
70
|
+
req = Net::HTTP::Get.new(_url.request_uri)
|
71
|
+
res = http.request(req)
|
72
|
+
check_response(res)
|
73
|
+
JSON.parse(res.body)
|
74
|
+
end
|
75
|
+
|
76
|
+
def put(url:, json_hash:)
|
77
|
+
_url = URI(url)
|
78
|
+
http = Net::HTTP.new(_url.host, _url.port)
|
79
|
+
req = Net::HTTP::Put.new(_url.request_uri, 'Content-Type' => 'application/json')
|
80
|
+
# These are hashes
|
81
|
+
# They're equivalent. The second one is a more compact style that's common since lots of hashes have symbols for keys.
|
82
|
+
# { :Settings => 'd', :Go: 'test' }.class
|
83
|
+
# { Settings: '', Go: 'test' }.class
|
84
|
+
req.body = json_hash.to_json
|
85
|
+
check_response(http.request(req))
|
86
|
+
end
|
87
|
+
|
88
|
+
def delete(url:)
|
89
|
+
_url = URI(url)
|
90
|
+
http = Net::HTTP.new(_url.host, _url.port)
|
91
|
+
req = Net::HTTP::Delete.new(_url.request_uri)
|
92
|
+
check_response(http.request(req))
|
93
|
+
end
|
94
|
+
# TODO: Create post wrapper
|
95
|
+
|
96
|
+
def check_response(response)
|
97
|
+
case response
|
98
|
+
when Net::HTTPSuccess
|
99
|
+
return
|
100
|
+
else
|
101
|
+
raise RuntimeError, "Request failed with an HTTP status code of #{response.code} and a message of #{response.body}."
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ravendb/api/client/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ravendb-api-client"
|
8
|
+
spec.version = Ravendb::Api::VERSION
|
9
|
+
spec.authors = ["tragiccode"]
|
10
|
+
spec.email = ["michael@tragiccode.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Client for accessing RavenDB APIs}
|
13
|
+
spec.homepage = "https://github.com/tragiccode/ravendb-api-client"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency 'pry'
|
26
|
+
spec.add_development_dependency 'simplecov'
|
27
|
+
spec.add_development_dependency 'simplecov-console'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ravendb-api-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tragiccode
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-console
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- michael@tragiccode.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rspec"
|
106
|
+
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
108
|
+
- Gemfile
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- appveyor.yml
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/ravendb/api/client.rb
|
115
|
+
- lib/ravendb/api/client/version.rb
|
116
|
+
- ravendb-api-client.gemspec
|
117
|
+
homepage: https://github.com/tragiccode/ravendb-api-client
|
118
|
+
licenses: []
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.7.1
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Client for accessing RavenDB APIs
|
140
|
+
test_files: []
|