auctioneer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e893eb7d7ad2d71547b2e288b0bf161cb409a43
4
+ data.tar.gz: c2a97e50333ef5ef3d572a9258219fe7fd6e47f9
5
+ SHA512:
6
+ metadata.gz: 40c291467691f769286bd54c31724f4429b42665f769a5e2b99a5a374e16aaef7cfe49f9c7cd5c6ffd0e2e923c84ef1f69cbc5cf776e0514bdca8fae10dc07a8
7
+ data.tar.gz: 6c4fcab4cee5ffa90668f89335cc81eae70fefa649c7aa4b1282da168b04cc115fbb00272aed4d9fb0f5995604cf19664705f32895a02bbaf79332903ebe5e6f
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler -v 1.10.4
@@ -0,0 +1,19 @@
1
+ ## Welcome!
2
+
3
+ We're so glad you're thinking about contributing to an 18F open source project! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. We love all friendly contributions.
4
+
5
+ We want to ensure a welcoming environment for all of our projects. Our staff follow the [18F Code of Conduct](https://github.com/18F/code-of-conduct/blob/master/code-of-conduct.md) and all contributors should do the same.
6
+
7
+ We encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md).
8
+
9
+ If you have any questions or want to read more, check out the [18F Open Source Policy GitHub repository]( https://github.com/18f/open-source-policy), or just [shoot us an email](mailto:18f@gsa.gov).
10
+
11
+ ## Public domain
12
+
13
+ This project is in the public domain within the United States, and
14
+ copyright and related rights in the work worldwide are waived through
15
+ the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
16
+
17
+ All contributions to this project will be released under the CC0
18
+ dedication. By submitting a pull request, you are agreeing to comply
19
+ with this waiver of copyright interest.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in auctioneer.gemspec
4
+ gemspec
@@ -0,0 +1,31 @@
1
+ As a work of the United States Government, this project is in the
2
+ public domain within the United States.
3
+
4
+ Additionally, we waive copyright and related rights in the work
5
+ worldwide through the CC0 1.0 Universal public domain dedication.
6
+
7
+ ## CC0 1.0 Universal Summary
8
+
9
+ This is a human-readable summary of the [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
10
+
11
+ ### No Copyright
12
+
13
+ The person who associated a work with this deed has dedicated the work to
14
+ the public domain by waiving all of his or her rights to the work worldwide
15
+ under copyright law, including all related and neighboring rights, to the
16
+ extent allowed by law.
17
+
18
+ You can copy, modify, distribute and perform the work, even for commercial
19
+ purposes, all without asking permission.
20
+
21
+ ### Other Information
22
+
23
+ In no way are the patent or trademark rights of any person affected by CC0,
24
+ nor are the rights that other persons may have in the work or in how the
25
+ work is used, such as publicity or privacy rights.
26
+
27
+ Unless expressly stated otherwise, the person who associated a work with
28
+ this deed makes no warranties about the work, and disclaims liability for
29
+ all uses of the work, to the fullest extent permitted by applicable law.
30
+ When using or citing the work, you should not imply endorsement by the
31
+ author or the affirmer.
@@ -0,0 +1,64 @@
1
+ # Auctioneer
2
+
3
+ A Ruby API Client for 18F's Micropurchase application.
4
+
5
+ ## Requirements
6
+
7
+ - Ruby
8
+
9
+ ## Installation
10
+
11
+ This is not yet a gem. Many parts are still moving, use at your own risk, etc, etc.
12
+
13
+ Clone the repo, `cd` into it, run `bundle`.
14
+
15
+ ## Obtaining an API key
16
+
17
+ Go to https://github.com/settings/tokens (make sure you are logged in), and generate a Personal Access Token. Uncheck all of the "scope" options, too.
18
+
19
+ Add this key to your `.zshrc`, `.bash_profile` or similar as:
20
+
21
+ ```
22
+ export MICROPURCHASE_API_KEY='your personal access token goes here'
23
+ ```
24
+
25
+ ## Use
26
+
27
+ Run `ruby auctioneer.rb` to access the API client inside of a `pry` session.
28
+
29
+ ## Admin Methods
30
+
31
+ These methods are only available to authenticated system admins (e.g. 18F staff only).
32
+
33
+ ### admin_users
34
+
35
+ ```ruby
36
+ client.admin_user
37
+ #=> {...}
38
+ ```
39
+
40
+ ### admin_auctions
41
+
42
+ ```ruby
43
+ client.admin_auctions
44
+ #=> {...}
45
+ ```
46
+
47
+ ### Reporting tasks
48
+
49
+ We're including in this gem methods for common data reporting/updating tasks.
50
+
51
+ #### CSV of Email addresses
52
+
53
+ ```ruby
54
+ email_csv
55
+ # generates a CSV of email addresses in `emails.csv` in the root of the project
56
+ ```
57
+
58
+ ## Public domain
59
+
60
+ This project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.md):
61
+
62
+ > This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
63
+ >
64
+ > All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to
@@ -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
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'auctioneer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "auctioneer"
8
+ spec.version = Auctioneer::VERSION
9
+ spec.authors = ["Alan deLevie"]
10
+ spec.email = ["alan.delevie@gsa.gov"]
11
+
12
+ spec.summary = %q{Ruby access to 18F's micro-purchase API}
13
+ spec.homepage = "https://micropurchase.18f.gov"
14
+
15
+ # # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
16
+ # # delete this section to allow pushing this gem to any host.
17
+ # if spec.respond_to?(:metadata)
18
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
19
+ # else
20
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
21
+ # end
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.10"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec"
31
+ end
@@ -0,0 +1,60 @@
1
+ require 'bundler/setup'
2
+ require 'pry'
3
+ require 'curb'
4
+ require 'json'
5
+
6
+ module Auctioneer
7
+ class Client
8
+ def initialize(api_key: ENV['MICROPURCHASE_API_KEY'])
9
+ #@client = HTTPClient.new
10
+ @headers = {'Accept' => 'text/x-json'}
11
+ @headers['Api-Key'] = api_key if api_key
12
+ end
13
+
14
+ def admin_users
15
+ get(Auctioneer::Protocol.admin_users_path)
16
+ end
17
+
18
+ def admin_auctions
19
+ get(Auctioneer::Protocol.admin_auctions_path)
20
+ end
21
+
22
+ def get(url)
23
+ #response = @client.get(path, nil, @headers)
24
+ http = Curl.get(url) do |http|
25
+ http.headers = @headers
26
+ end
27
+
28
+ JSON.parse(http.body_str)
29
+ end
30
+ end
31
+
32
+ module Protocol
33
+ BASE_URL = 'https://micropurchase.18f.gov'
34
+
35
+ def self.admin_auctions_path
36
+ "#{BASE_URL}/admin/auctions"
37
+ end
38
+
39
+ def self.admin_users_path
40
+ "#{BASE_URL}/admin/users"
41
+ end
42
+ end
43
+ end
44
+
45
+ def email_csv
46
+ client = Auctioneer::Client.new
47
+ users = client.admin_users['admin_report']['non_admin_users']
48
+ emails = users.map {|u| u['email']}.reject(&:nil?)
49
+
50
+ require "csv"
51
+ CSV.open("emails.csv", "wb") do |csv|
52
+ emails.each do |email|
53
+ csv << [email]
54
+ end
55
+ end
56
+ end
57
+
58
+ client = Auctioneer::Client.new
59
+
60
+ binding.pry
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
4
+ before_install: gem install bundler -v 1.10.4
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in auctioneer.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # Auctioneer
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/auctioneer`. 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 'auctioneer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install auctioneer
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 rspec` 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]/auctioneer.
36
+
@@ -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
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'auctioneer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "auctioneer"
8
+ spec.version = Auctioneer::VERSION
9
+ spec.authors = ["Alan deLevie"]
10
+ spec.email = ["alan.delevie@gsa.gov"]
11
+
12
+ spec.summary = %q{Ruby access to 18F's micro-purchase API}
13
+ spec.description = %q{A longer description about Ruby access to 18F's micro-purchase API}
14
+ spec.homepage = "https://micropurchase.18f.gov"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.10"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec"
32
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "auctioneer"
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
@@ -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,5 @@
1
+ require "auctioneer/version"
2
+
3
+ module Auctioneer
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Auctioneer
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Auctioneer do
4
+ it 'has a version number' do
5
+ expect(Auctioneer::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'auctioneer'
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "auctioneer"
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
@@ -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,5 @@
1
+ require "auctioneer/version"
2
+
3
+ module Auctioneer
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Auctioneer
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: auctioneer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan deLevie
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-02-19 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - alan.delevie@gsa.gov
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CONTRIBUTING.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.md
69
+ - README.md
70
+ - Rakefile
71
+ - auctioneer.gemspec
72
+ - auctioneer.rb
73
+ - auctioneer/.gitignore
74
+ - auctioneer/.rspec
75
+ - auctioneer/.travis.yml
76
+ - auctioneer/Gemfile
77
+ - auctioneer/README.md
78
+ - auctioneer/Rakefile
79
+ - auctioneer/auctioneer.gemspec
80
+ - auctioneer/bin/console
81
+ - auctioneer/bin/setup
82
+ - auctioneer/lib/auctioneer.rb
83
+ - auctioneer/lib/auctioneer/version.rb
84
+ - auctioneer/spec/auctioneer_spec.rb
85
+ - auctioneer/spec/spec_helper.rb
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/auctioneer.rb
89
+ - lib/auctioneer/version.rb
90
+ homepage: https://micropurchase.18f.gov
91
+ licenses: []
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Ruby access to 18F's micro-purchase API
113
+ test_files: []