harvest-ruby-v2 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +117 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.rst +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/EXAMPLE.conf +4 -0
- data/Gemfile +39 -0
- data/LICENSE.txt +21 -0
- data/Makefile +9 -0
- data/README.md +44 -0
- data/Rakefile +34 -0
- data/bin/console +53 -0
- data/bin/setup +8 -0
- data/harvest-ruby-v2.gemspec +31 -0
- data/lib/harvest.rb +115 -0
- data/lib/harvest/client.rb +0 -0
- data/lib/harvest/config.rb +21 -0
- data/lib/harvest/creates.rb +46 -0
- data/lib/harvest/discovers.rb +58 -0
- data/lib/harvest/exceptions.rb +11 -0
- data/lib/harvest/finders.rb +17 -0
- data/lib/harvest/http/client.rb +0 -0
- data/lib/harvest/httpclient.rb +178 -0
- data/lib/harvest/resourcefactory.rb +220 -0
- data/lib/harvest/resources.rb +15 -0
- data/lib/harvest/resources/client.rb +34 -0
- data/lib/harvest/resources/company.rb +62 -0
- data/lib/harvest/resources/estimates.rb +173 -0
- data/lib/harvest/resources/expenses.rb +90 -0
- data/lib/harvest/resources/invoices.rb +262 -0
- data/lib/harvest/resources/message.rb +16 -0
- data/lib/harvest/resources/project.rb +84 -0
- data/lib/harvest/resources/project_assignment.rb +46 -0
- data/lib/harvest/resources/task.rb +35 -0
- data/lib/harvest/resources/task_assignment.rb +38 -0
- data/lib/harvest/resources/timeentry.rb +105 -0
- data/lib/harvest/resources/user.rb +75 -0
- data/lib/harvest/resources/user_assignment.rb +43 -0
- data/lib/harvest/version.rb +5 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 197576a0a9aea49a4ff0acd96668a8c6407a0f487270567998f158657ff33ab6
|
4
|
+
data.tar.gz: 3a013efe25ea3ec70d4f239f59aedf1b4c1fd4de3476614b7ea72b0403a3740e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 953730ac41de134c4d11a1448cc7efdd5ed753359208c75920ad1d72a229b56cf160d28aa1520e7226725a361bc277122d1e8f1b36c1edd4ab3e49d7f5cd9f75
|
7
|
+
data.tar.gz: cfac326cd27d5b372a7460ea4034d1c4d712bbedbe2e87057b68f319ca0eea2b4d33562014a62fc17698b856ee4655f35202d445031ef11f0268080b83fc0bf9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# This is the configuration used to check the rubocop source code.
|
2
|
+
|
3
|
+
# inherit_from: .rubocop_todo.yml
|
4
|
+
require:
|
5
|
+
- rubocop/cop/internal_affairs
|
6
|
+
- rubocop-performance
|
7
|
+
- rubocop-rspec
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
NewCops: enable
|
11
|
+
Exclude:
|
12
|
+
- 'vendor/**/*'
|
13
|
+
- 'spec/fixtures/**/*'
|
14
|
+
- 'tmp/**/*'
|
15
|
+
- '.git/**/*'
|
16
|
+
- 'bin/*'
|
17
|
+
- 'gems/**/*'
|
18
|
+
TargetRubyVersion: 2.7
|
19
|
+
|
20
|
+
Naming/PredicateName:
|
21
|
+
# Method define macros for dynamically generated method.
|
22
|
+
MethodDefinitionMacros:
|
23
|
+
- define_method
|
24
|
+
- define_singleton_method
|
25
|
+
- def_node_matcher
|
26
|
+
- def_node_search
|
27
|
+
|
28
|
+
Style/FormatStringToken:
|
29
|
+
# Because we parse a lot of source codes from strings. Percent arrays
|
30
|
+
# look like unannotated format string tokens to this cop.
|
31
|
+
Exclude:
|
32
|
+
- spec/**/*
|
33
|
+
|
34
|
+
Style/IpAddresses:
|
35
|
+
# The test for this cop includes strings that would cause offenses
|
36
|
+
Exclude:
|
37
|
+
- spec/rubocop/cop/style/ip_addresses_spec.rb
|
38
|
+
|
39
|
+
Layout/EndOfLine:
|
40
|
+
EnforcedStyle: lf
|
41
|
+
|
42
|
+
Layout/ClassStructure:
|
43
|
+
Enabled: true
|
44
|
+
Categories:
|
45
|
+
module_inclusion:
|
46
|
+
- include
|
47
|
+
- prepend
|
48
|
+
- extend
|
49
|
+
ExpectedOrder:
|
50
|
+
- module_inclusion
|
51
|
+
- constants
|
52
|
+
- public_class_methods
|
53
|
+
- initializer
|
54
|
+
- instance_methods
|
55
|
+
- protected_methods
|
56
|
+
- private_methods
|
57
|
+
|
58
|
+
# Trailing white space is meaningful in code examples
|
59
|
+
Layout/TrailingWhitespace:
|
60
|
+
AllowInHeredoc: true
|
61
|
+
|
62
|
+
Lint/AmbiguousBlockAssociation:
|
63
|
+
Exclude:
|
64
|
+
- 'spec/**/*.rb'
|
65
|
+
|
66
|
+
Layout/HashAlignment:
|
67
|
+
EnforcedHashRocketStyle:
|
68
|
+
- key
|
69
|
+
- table
|
70
|
+
EnforcedColonStyle:
|
71
|
+
- key
|
72
|
+
- table
|
73
|
+
|
74
|
+
Layout/LineLength:
|
75
|
+
Max: 100
|
76
|
+
IgnoredPatterns:
|
77
|
+
- !ruby/regexp /\A +(it|describe|context|shared_examples|include_examples|it_behaves_like) ["']/
|
78
|
+
|
79
|
+
Lint/InterpolationCheck:
|
80
|
+
Exclude:
|
81
|
+
- 'spec/**/*.rb'
|
82
|
+
|
83
|
+
Lint/UselessAccessModifier:
|
84
|
+
MethodCreatingMethods:
|
85
|
+
- 'def_matcher'
|
86
|
+
- 'def_node_matcher'
|
87
|
+
|
88
|
+
Lint/BooleanSymbol:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Metrics/BlockLength:
|
92
|
+
Exclude:
|
93
|
+
- 'Rakefile'
|
94
|
+
- '**/*.rake'
|
95
|
+
- 'spec/**/*.rb'
|
96
|
+
- '**/*.gemspec'
|
97
|
+
|
98
|
+
Metrics/ClassLength:
|
99
|
+
Exclude:
|
100
|
+
- lib/rubocop/config_obsoletion.rb
|
101
|
+
|
102
|
+
Metrics/ModuleLength:
|
103
|
+
Exclude:
|
104
|
+
- 'spec/**/*.rb'
|
105
|
+
|
106
|
+
RSpec/FilePath:
|
107
|
+
Exclude:
|
108
|
+
- spec/rubocop/formatter/junit_formatter_spec.rb
|
109
|
+
|
110
|
+
RSpec/PredicateMatcher:
|
111
|
+
EnforcedStyle: explicit
|
112
|
+
|
113
|
+
RSpec/MessageSpies:
|
114
|
+
EnforcedStyle: receive
|
115
|
+
|
116
|
+
RSpec/NestedGroups:
|
117
|
+
Max: 7
|
data/.travis.yml
ADDED
data/CHANGELOG.rst
ADDED
File without changes
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at craig.davis@rackspace.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/EXAMPLE.conf
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in harvest.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 12.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
|
11
|
+
gem 'rest-client', '~> 2.1'
|
12
|
+
|
13
|
+
gem 'pry', '~> 0.13.1'
|
14
|
+
|
15
|
+
gem 'configparser', '~> 0.1.7'
|
16
|
+
|
17
|
+
gem 'rubocop', '~> 0.89.1'
|
18
|
+
|
19
|
+
gem 'activesupport', '~> 6.0'
|
20
|
+
|
21
|
+
gem 'reek', '~> 6.0'
|
22
|
+
|
23
|
+
gem 'webmock', '~> 3.8'
|
24
|
+
|
25
|
+
gem 'rubocop-rspec', '~> 1.43'
|
26
|
+
|
27
|
+
gem 'rubocop-rake', '~> 0.5.1'
|
28
|
+
|
29
|
+
gem 'yard', '~> 0.9.25'
|
30
|
+
|
31
|
+
gem 'rubocop-performance', '~> 1.7'
|
32
|
+
gem 'ruby-prof', '~> 1.4'
|
33
|
+
gem 'simplecov', '~> 0.19.0'
|
34
|
+
|
35
|
+
# gem 'pry-byebug', '~> 3.9'
|
36
|
+
|
37
|
+
gem 'redcarpet', '~> 3.5'
|
38
|
+
|
39
|
+
gem 'yard-struct', '~> 1.1'
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Craig Davis
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Harvest
|
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/harvest`. 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 'harvest'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install harvest
|
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]/harvest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/harvest/blob/master/CODE_OF_CONDUCT.md).
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
+
|
42
|
+
## Code of Conduct
|
43
|
+
|
44
|
+
Everyone interacting in the Harvest project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/harvest/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'yard'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
RuboCop::RakeTask.new(:spec) do |rubocop|
|
10
|
+
rubocop.options << '--auto-correct'
|
11
|
+
rubocop.options << '--display-cop-names'
|
12
|
+
end
|
13
|
+
|
14
|
+
YARD::Rake::YardocTask.new do |t|
|
15
|
+
t.files = ['lib/**/*.rb'] # optional
|
16
|
+
# t.options = ['--any', '--extra', '--opts'] # optional
|
17
|
+
t.options = ['-Mredcarpet', '--plugin', 'yard-struct']
|
18
|
+
t.stats_options = ['--list-undoc'] # optional
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'YARD Server'
|
22
|
+
task :'yard-server' do
|
23
|
+
`yard server`
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'analyze langauges in use'
|
27
|
+
task linguist: :build do
|
28
|
+
puts `github-linguist`
|
29
|
+
end
|
30
|
+
|
31
|
+
task default: :spec
|
32
|
+
task test: :spec
|
33
|
+
task 'yard-server': :yard
|
34
|
+
task 'yard-server': :build
|
data/bin/console
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'pry'
|
5
|
+
require 'configparser'
|
6
|
+
require 'date'
|
7
|
+
require "bundler/setup"
|
8
|
+
require 'harvest'
|
9
|
+
require 'active_support/core_ext/date/calculations'
|
10
|
+
|
11
|
+
def today
|
12
|
+
beginning_of_day
|
13
|
+
end
|
14
|
+
|
15
|
+
def beginning_of_day
|
16
|
+
DateTime.now.beginning_of_day
|
17
|
+
end
|
18
|
+
|
19
|
+
def beginning_of_day_epoch
|
20
|
+
beginning_of_day.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def yesterday_beginning_of_day
|
24
|
+
Date.today.yesterday.to_datetime
|
25
|
+
end
|
26
|
+
|
27
|
+
def convert_to_sym(data)
|
28
|
+
return data.map { |k, v| [k.to_sym, convert_to_sym(v)] }.to_h if data.respond_to?('keys')
|
29
|
+
|
30
|
+
return data.map { |v| convert_to_sym(v) } if data.respond_to?('each')
|
31
|
+
|
32
|
+
data
|
33
|
+
end
|
34
|
+
|
35
|
+
def config(configfile: File.expand_path('~/.config/start-harvest.conf'))
|
36
|
+
convert_to_sym(ConfigParser.new(configfile))
|
37
|
+
end
|
38
|
+
|
39
|
+
def config_subsection(key: :harvest)
|
40
|
+
config[key]
|
41
|
+
end
|
42
|
+
|
43
|
+
harvest = Harvest::Client.new(**config_subsection)
|
44
|
+
|
45
|
+
puts "Active user is #{harvest.active_user.first_name} #{harvest.active_user.last_name}"
|
46
|
+
|
47
|
+
if harvest.active_user.is_admin
|
48
|
+
puts "User is Admin"
|
49
|
+
else
|
50
|
+
puts "User is not an Admin"
|
51
|
+
end
|
52
|
+
|
53
|
+
binding.pry
|