stash_api 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +25 -8
- data/lib/stash_api/base.rb +1 -0
- data/lib/stash_api/core.rb +8 -1
- data/lib/stash_api/resource.rb +5 -1
- data/lib/stash_api/user.rb +9 -0
- data/lib/stash_api/version.rb +1 -1
- data/lib/stash_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3ec81f8d9a97960441b463f1e963cb0b69cc44b
|
4
|
+
data.tar.gz: 7134590611aaf4f9538f7b2d836a21802970529f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf0c8080faf3c4383d825eab07cae2aff25610a0d1218ce6aee436a4d2cb6a9ae80879e87eda2615b614872910432e9c14fed1ae82656c0df00e1d96188cc39
|
7
|
+
data.tar.gz: 199c5afb721b5f012dbe25e65ce26c4c8103c40da0584542700ceaf0445e6030884f105e627d65c099335da62de1ac574e27981fe11ef265838502eda5e1ac01
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# StashAPI
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
A client for interacting with Atlassian Stash API
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,18 +20,37 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
```ruby
|
24
|
+
StashAPI::Base.domain("stash.mycompany.com") # address of your stash server
|
25
|
+
StashAPI::Base.basic_auth("username", "password") # optional credentials
|
26
|
+
```
|
27
|
+
Now you can send requests to Stash
|
28
|
+
```ruby
|
29
|
+
# You can interact with the core rest API as follows
|
30
|
+
StashAPI::Core.projects.fetch # to return projects
|
31
|
+
StashAPI::Core.users.fetch # to return users
|
32
|
+
|
33
|
+
# to supply query parameters pass them in as a hash
|
34
|
+
StashAPI::Core.projects.fetch(name: "project_name")
|
35
|
+
|
36
|
+
# or if you know the id/key of the resource
|
37
|
+
StashAPI::Core.projects('ID').fetch
|
38
|
+
```
|
39
|
+
Users and projects are a top level resource, accessible directly from Core. To access something like pull requests you need to use resource chaining.
|
40
|
+
```ruby
|
41
|
+
# retrieves pull requests for the specified repo
|
42
|
+
StashAPI::Core.projects('key').repos('slug').pull_requests.fetch
|
43
|
+
```
|
26
44
|
|
27
45
|
## Development
|
28
46
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
48
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`
|
32
50
|
|
33
51
|
## Contributing
|
34
52
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
36
|
-
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/zach-chai/stash_api. Please add tests to your pull requests so it isn't broken unintentionally.
|
37
54
|
|
38
55
|
## License
|
39
56
|
|
data/lib/stash_api/base.rb
CHANGED
data/lib/stash_api/core.rb
CHANGED
@@ -1,11 +1,18 @@
|
|
1
1
|
module StashAPI
|
2
2
|
class Core < Resource
|
3
3
|
class << self
|
4
|
+
@@position = 0
|
4
5
|
|
5
6
|
def projects(id = nil)
|
6
|
-
add_resource_to_chain
|
7
|
+
add_resource_to_chain @@position, 'projects', id
|
7
8
|
Project
|
8
9
|
end
|
10
|
+
|
11
|
+
def users(id = nil)
|
12
|
+
add_resource_to_chain @@position, 'users', id
|
13
|
+
User
|
14
|
+
end
|
15
|
+
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
data/lib/stash_api/resource.rb
CHANGED
@@ -4,6 +4,8 @@ module StashAPI
|
|
4
4
|
@@resource_ids = []
|
5
5
|
|
6
6
|
def self.fetch(query = {})
|
7
|
+
raise "set a domain first 'StashAPI::Base.domain(<domain>)'" unless StashAPI::Options.option(:domain)
|
8
|
+
|
7
9
|
options = {}
|
8
10
|
options[:query] = query
|
9
11
|
|
@@ -18,8 +20,9 @@ module StashAPI
|
|
18
20
|
end
|
19
21
|
|
20
22
|
def self.fetch_all(query = {})
|
23
|
+
raise "set a domain first 'StashAPI::Base.domain(<domain>)'" unless StashAPI::Options.option(:domain)
|
24
|
+
|
21
25
|
options = {}
|
22
|
-
|
23
26
|
query[:limit] = 1000
|
24
27
|
query[:start] = 0
|
25
28
|
options[:query] = query
|
@@ -41,6 +44,7 @@ module StashAPI
|
|
41
44
|
end
|
42
45
|
|
43
46
|
def self.create_resource(payload, options = {})
|
47
|
+
raise "set a domain first 'StashAPI::Base.domain(<domain>)'" unless StashAPI::Options.option(:domain)
|
44
48
|
|
45
49
|
options[:body] = payload.to_json
|
46
50
|
options[:headers] = {'Content-Type' => 'application/json'}
|
data/lib/stash_api/version.rb
CHANGED
data/lib/stash_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stash_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zachary Chai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/stash_api/pull_request.rb
|
92
92
|
- lib/stash_api/repo.rb
|
93
93
|
- lib/stash_api/resource.rb
|
94
|
+
- lib/stash_api/user.rb
|
94
95
|
- lib/stash_api/version.rb
|
95
96
|
- stash_api.gemspec
|
96
97
|
homepage:
|