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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac36a7380c0a32c9849de48e57a8f1215b065742
4
- data.tar.gz: a536d5ea4ae443344691f49736fccc7e3542bf24
3
+ metadata.gz: b3ec81f8d9a97960441b463f1e963cb0b69cc44b
4
+ data.tar.gz: 7134590611aaf4f9538f7b2d836a21802970529f
5
5
  SHA512:
6
- metadata.gz: bc3589b49f7b3621219eaa38edfcd7dd3465a970bf2cab3306be9e27f07cfa75f6f749568d6127672da2b1119d22b626d93508b514fd203a137238d10038519e
7
- data.tar.gz: f33106c04f3419d5777eec32f67f42288358af336dda3811c6e0503d945edb0c71b1529d0385bfb2a225fd894e1c1edec1ee220123cbb4fb4577138378a69200
6
+ metadata.gz: 2bf0c8080faf3c4383d825eab07cae2aff25610a0d1218ce6aee436a4d2cb6a9ae80879e87eda2615b614872910432e9c14fed1ae82656c0df00e1d96188cc39
7
+ data.tar.gz: 199c5afb721b5f012dbe25e65ce26c4c8103c40da0584542700ceaf0445e6030884f105e627d65c099335da62de1ac574e27981fe11ef265838502eda5e1ac01
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # StashAPI
2
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/stash_api`. 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
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
- TODO: Write usage instructions here
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. Run `bundle exec stash_api` to use the gem in this directory, ignoring other installed copies of this gem.
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`. 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).
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/[USERNAME]/stash_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
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
 
@@ -4,6 +4,7 @@ module StashAPI
4
4
 
5
5
  def domain(value = nil)
6
6
  return Options.option(:domain) unless value
7
+ value.chomp! '/' if value[-1]
7
8
  Options.option :domain, value
8
9
  end
9
10
 
@@ -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 0, 'projects', id
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
@@ -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'}
@@ -0,0 +1,9 @@
1
+ module StashAPI
2
+ class User < Resource
3
+ class << self
4
+ @@position = 1
5
+
6
+ #TODO add user operations
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module StashAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/stash_api.rb CHANGED
@@ -6,6 +6,7 @@ require 'stash_api/base'
6
6
  require 'stash_api/resource'
7
7
  require 'stash_api/core'
8
8
  require 'stash_api/project'
9
+ require 'stash_api/user'
9
10
  require 'stash_api/repo'
10
11
  require 'stash_api/pull_request'
11
12
  require 'stash_api/comment'
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.0
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-12 00:00:00.000000000 Z
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: