ahub 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1dd53ca33d1f090cf62539d029b4eb07adb8591c
4
+ data.tar.gz: 025c3061b2a858b1e4df1029a156aab41672a5f9
5
+ SHA512:
6
+ metadata.gz: 5528bababcb56b065c9b88ed382bfc87ad55c6a962c80e927540d5a503ca90a31e0a27beafcf5cfb0aa6180f7a0442fc30f262f2e0726b4d987fd09853c3ecee
7
+ data.tar.gz: e9c00719479dde3676e350522c6d5a5af44571678d4c50c09b48074c2c144e28c8fa92182d277ba89bfb6f3e1ac54c67a65c66182b295ea7340d09dc6306f832
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
11
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.4
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ahub.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Abel Martin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Ahub
2
+ A gem to interact with the [Answer Hub API](docs.answerhubapiv2.apiary.io)
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'ahub'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install ahub
19
+
20
+ ## Usage
21
+
22
+ ## Development
23
+
24
+ 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.
25
+
26
+ 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).
27
+
28
+ ## Contributing
29
+
30
+ Bug reports and pull requests are welcome on GitHub at https://github.com/abelmartin/ahub. 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.
31
+
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/ahub.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ahub/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ahub"
8
+ spec.version = Ahub::VERSION
9
+ spec.authors = ["Abel Martin"]
10
+ spec.email = ["abel.martin@gmail.com"]
11
+
12
+ spec.summary = "A gem to interact with the Answer Hub API"
13
+ spec.description = "Answer Hub is a great product. This gem allows you to easily interact with it's API"
14
+ spec.homepage = "https://github.com/abelmartin/ahub"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "bin"
19
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.executables << 'ahub'
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency "rest-client", "~> 1.8"
24
+ spec.add_runtime_dependency "humanize", "~> 1.1"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.10"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.3"
29
+ spec.add_development_dependency "pry-byebug", "~> 3.2"
30
+ end
data/bin/ahub ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "ahub"
4
+
5
+ p '¡Go Hub!'
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ahub"
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
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ require 'rest_client'
2
+ require 'pry-byebug'
3
+ require 'ahub/modules/api_helpers'
4
+
5
+ module Ahub
6
+ class Answer
7
+ extend Ahub::APIHelpers
8
+ def self.find(id)
9
+ end
10
+
11
+ def self.create(question_id:, body:)
12
+ data = {
13
+ body: body
14
+ }
15
+
16
+ url = "http://localhost:8888/services/v2/question/#{question_id}/answer.json"
17
+
18
+ JSON.parse RestClient.post(url, data.to_json, headers)
19
+ rescue => e
20
+ {error: e.message}
21
+ end
22
+
23
+ def self.get_all_by_question(question_id:)
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ module Ahub
2
+ module APIHelpers
3
+ require 'base64'
4
+ def headers(username:'answerhub', password:'answerhub')
5
+ encoded = "Basic #{::Base64.strict_encode64("#{username}:#{password}")}"
6
+
7
+ headers = {
8
+ 'Authorization' => encoded,
9
+ 'Accept' => "application/json",
10
+ 'Content-type' => "application/json",
11
+ }
12
+ end
13
+ end
14
+ end
data/lib/ahub/user.rb ADDED
@@ -0,0 +1,48 @@
1
+ require 'rest_client'
2
+ require 'pry-byebug'
3
+ require 'csv'
4
+ require 'humanize'
5
+ require 'ahub/modules/api_helpers'
6
+
7
+ module Ahub
8
+ class User
9
+ extend Ahub::APIHelpers
10
+ def self.find(id)
11
+ url = "http://localhost:8888/services/v2/user/#{id}.json"
12
+ JSON.parse(RestClient.get url, headers)
13
+ rescue => e
14
+ {error: e.message}
15
+ end
16
+
17
+ def self.create_test_user(prefix: 'ahuser', index: 0)
18
+ url = "http://localhost:8888/services/v2/user"
19
+ number = '%03d' % index
20
+ username = "#{prefix}#{number}"
21
+ data = {
22
+ email: "#{username}@example.com",
23
+ username: username,
24
+ password: 'password',
25
+ }
26
+
27
+ JSON.parse RestClient.post(url, data.to_json, headers)
28
+ {error: nil, newUserURL: response.headers[:location]}
29
+ rescue => e
30
+ {error: e.message}
31
+ end
32
+
33
+ def self.create_user_csv(prefix: 'ahuser', count: 10)
34
+ ::CSV.open('./users.csv', 'w') do |csv|
35
+ (0..count).each do |n|
36
+ number = '%03d' % n
37
+ username = "#{prefix}#{number}"
38
+ csv << [
39
+ "#{username}",
40
+ "#{prefix} user-#{n.humanize.gsub(/\s/,'-')}",
41
+ "#{username}@example.com",
42
+ "password"
43
+ ]
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Ahub
2
+ VERSION = "0.0.3"
3
+ end
data/lib/ahub.rb ADDED
@@ -0,0 +1,9 @@
1
+ require "ahub/version"
2
+ require "ahub/user"
3
+ require "ahub/answer"
4
+
5
+ module Ahub
6
+ def self.fire
7
+ "Nailed it!"
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ahub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Abel Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: humanize
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.10'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
97
+ description: Answer Hub is a great product. This gem allows you to easily interact
98
+ with it's API
99
+ email:
100
+ - abel.martin@gmail.com
101
+ executables:
102
+ - ahub
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - CODE_OF_CONDUCT.md
110
+ - Gemfile
111
+ - LICENSE
112
+ - README.md
113
+ - Rakefile
114
+ - ahub.gemspec
115
+ - bin/ahub
116
+ - bin/console
117
+ - bin/setup
118
+ - lib/ahub.rb
119
+ - lib/ahub/answer.rb
120
+ - lib/ahub/modules/api_helpers.rb
121
+ - lib/ahub/user.rb
122
+ - lib/ahub/version.rb
123
+ homepage: https://github.com/abelmartin/ahub
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.4.6
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: A gem to interact with the Answer Hub API
147
+ test_files: []