camp3 0.0.1 → 0.0.2
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/.github/workflows/release_metadata.yml +60 -0
- data/.rubocop_todo.yml +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/camp3.rb +0 -1
- data/lib/camp3/api/resource.rb +1 -1
- data/lib/camp3/client.rb +14 -2
- data/lib/camp3/error.rb +1 -1
- data/lib/camp3/request.rb +1 -1
- data/lib/camp3/resource.rb +53 -1
- data/lib/camp3/version.rb +1 -1
- metadata +3 -3
- data/lib/camp3/objectified_hash.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1494749b2bca6c9abf1b88fb92f095cb7b9a304a7109984dc625a1db82bd3983
|
4
|
+
data.tar.gz: 62cb4e89f50f16c162e8c74e06286fe8437980d5f542751a1b3cb49a3b38475e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 173586f31acad3b9d8219694c3268d5611d8c24eddf057f552c8fd3ab757745eb21a0ed4adb7d729da12e7e650c919602b5856bf595fad9ca6d8c94a90534b9c
|
7
|
+
data.tar.gz: 403f48695817d15d305ec6aca49c3bf91aecb76cce9292001dbbd8505fdff54284d2c585178c364a1c45e44d0a28a1bda5dd50f6477e4efde3e85b12a7168fe7
|
@@ -0,0 +1,60 @@
|
|
1
|
+
name: Release Metadata
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
changelog:
|
10
|
+
name: Update Changelog
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- name: Checkout code
|
14
|
+
uses: actions/checkout@v2
|
15
|
+
- name: Update Changelog
|
16
|
+
uses: heinrichreimer/github-changelog-generator-action@v2.1.1
|
17
|
+
with:
|
18
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
19
|
+
- uses: stefanzweifel/git-auto-commit-action@v4
|
20
|
+
with:
|
21
|
+
# Required
|
22
|
+
commit_message: Update Changelog
|
23
|
+
file_pattern: CHANGELOG.md
|
24
|
+
|
25
|
+
release_notes:
|
26
|
+
name: Create Release Notes
|
27
|
+
runs-on: ubuntu-latest
|
28
|
+
needs: changelog
|
29
|
+
steps:
|
30
|
+
- name: Get version from tag
|
31
|
+
env:
|
32
|
+
GITHUB_REF: ${{ github.ref }}
|
33
|
+
run: |
|
34
|
+
export CURRENT_VERSION=${GITHUB_TAG/refs\/tags\/v/}
|
35
|
+
echo "::set-env name=CURRENT_VERSION::$CURRENT_VERSION"
|
36
|
+
|
37
|
+
- name: Checkout code
|
38
|
+
uses: actions/checkout@v2
|
39
|
+
with:
|
40
|
+
ref: master
|
41
|
+
|
42
|
+
- name: Get Changelog Entry
|
43
|
+
id: changelog_reader
|
44
|
+
uses: mindsers/changelog-reader-action@v1
|
45
|
+
with:
|
46
|
+
version: ${{ env.CURRENT_VERSION }}
|
47
|
+
path: ./CHANGELOG.md
|
48
|
+
|
49
|
+
- name: Create Release
|
50
|
+
id: create_release
|
51
|
+
uses: actions/create-release@v1
|
52
|
+
env:
|
53
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
54
|
+
with:
|
55
|
+
tag_name: ${{ github.ref }}
|
56
|
+
release_name: Release ${{ github.ref }}
|
57
|
+
body: ${{ steps.changelog_reader.outputs.log_entry }}
|
58
|
+
draft: false
|
59
|
+
prerelease: false
|
60
|
+
|
data/.rubocop_todo.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# camp3 
|
1
|
+
# camp3  [](https://badge.fury.io/rb/camp3)
|
2
2
|
|
3
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/camp3`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
data/lib/camp3.rb
CHANGED
data/lib/camp3/api/resource.rb
CHANGED
data/lib/camp3/client.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Camp3
|
4
|
-
# Wrapper for the
|
4
|
+
# Wrapper for the Camp3 REST API.
|
5
5
|
class Client < Request
|
6
6
|
Dir[File.expand_path('api/*.rb', __dir__)].each { |f| require f }
|
7
7
|
|
8
8
|
# Keep in alphabetical order
|
9
9
|
include Authorization
|
10
|
-
include ProjectAPI
|
11
10
|
include MessageAPI
|
11
|
+
include ProjectAPI
|
12
|
+
include ResourceAPI
|
12
13
|
include TodoAPI
|
13
14
|
|
14
15
|
# @private
|
@@ -48,5 +49,16 @@ module Camp3
|
|
48
49
|
def only_show_last_four_chars(token)
|
49
50
|
"#{'*' * (token.size - 4)}#{token[-4..-1]}"
|
50
51
|
end
|
52
|
+
|
53
|
+
# Utility method for transforming Basecamp Web URLs into API URIs
|
54
|
+
# e.g 'https://3.basecamp.com/1/buckets/2/todos/3' will be
|
55
|
+
# converted into 'https://3.basecampapi.com/1/buckets/2/todos/3.json'
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def url_transform(url)
|
59
|
+
api_uri = url.gsub('3.basecamp.com', '3.basecampapi.com')
|
60
|
+
api_uri += '.json' unless url.end_with? '.json'
|
61
|
+
api_uri
|
62
|
+
end
|
51
63
|
end
|
52
64
|
end
|
data/lib/camp3/error.rb
CHANGED
@@ -79,7 +79,7 @@ module Camp3
|
|
79
79
|
# Handle error response message in case of nested hashes
|
80
80
|
def handle_message(message)
|
81
81
|
case message
|
82
|
-
when Camp3::
|
82
|
+
when Camp3::Resource
|
83
83
|
message.to_h.sort.map do |key, val|
|
84
84
|
"'#{key}' #{(val.is_a?(Hash) ? val.sort.map { |k, v| "(#{k}: #{v.join(' ')})" } : [val].flatten).join(' ')}"
|
85
85
|
end.join(', ')
|
data/lib/camp3/request.rb
CHANGED
data/lib/camp3/resource.rb
CHANGED
@@ -1,8 +1,60 @@
|
|
1
1
|
module Camp3
|
2
|
-
class Resource
|
2
|
+
class Resource
|
3
3
|
|
4
4
|
Dir[File.expand_path('resources/*.rb', __dir__)].each { |f| require f }
|
5
5
|
|
6
|
+
# Creates a new Resource object.
|
7
|
+
def initialize(hash)
|
8
|
+
@hash = hash
|
9
|
+
@data = resourcify_data
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [Hash] The original hash.
|
13
|
+
def to_hash
|
14
|
+
hash
|
15
|
+
end
|
16
|
+
alias to_h to_hash
|
17
|
+
|
18
|
+
# @return [String] Formatted string with the class name, object id and original hash.
|
19
|
+
def inspect
|
20
|
+
"#<#{self.class}:#{object_id} {hash: #{hash.inspect}}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def [](key)
|
24
|
+
data[key]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :hash, :data
|
30
|
+
|
31
|
+
def resourcify_data
|
32
|
+
result = @hash.each_with_object({}) do |(key, value), data|
|
33
|
+
value = resourcify_value(value)
|
34
|
+
|
35
|
+
data[key.to_s] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
def resourcify_value(input)
|
42
|
+
return Resource.new(input) if input.is_a? Hash
|
43
|
+
|
44
|
+
return input unless input.is_a? Array
|
45
|
+
|
46
|
+
input.map { |curr| resourcify_value(curr) }
|
47
|
+
end
|
48
|
+
|
49
|
+
# Respond to messages for which `self.data` has a key
|
50
|
+
def method_missing(method_name, *args, &block)
|
51
|
+
@data.key?(method_name.to_s) ? @data[method_name.to_s] : super
|
52
|
+
end
|
53
|
+
|
54
|
+
def respond_to_missing?(method_name, include_private = false)
|
55
|
+
@hash.keys.map(&:to_sym).include?(method_name.to_sym) || super
|
56
|
+
end
|
57
|
+
|
6
58
|
def self.create(hash)
|
7
59
|
klass = detect_type(hash["url"])
|
8
60
|
|
data/lib/camp3/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camp3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- renehernandez
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- ".editorconfig"
|
77
77
|
- ".github/workflows/ci.yml"
|
78
78
|
- ".github/workflows/gem-push.yml"
|
79
|
+
- ".github/workflows/release_metadata.yml"
|
79
80
|
- ".gitignore"
|
80
81
|
- ".rspec"
|
81
82
|
- ".rubocop.yml"
|
@@ -103,7 +104,6 @@ files:
|
|
103
104
|
- lib/camp3/configuration.rb
|
104
105
|
- lib/camp3/error.rb
|
105
106
|
- lib/camp3/logging.rb
|
106
|
-
- lib/camp3/objectified_hash.rb
|
107
107
|
- lib/camp3/page_links.rb
|
108
108
|
- lib/camp3/paginated_response.rb
|
109
109
|
- lib/camp3/request.rb
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Camp3
|
4
|
-
# Converts hashes to the objects.
|
5
|
-
class ObjectifiedHash
|
6
|
-
# Creates a new ObjectifiedHash object.
|
7
|
-
def initialize(hash)
|
8
|
-
@hash = hash
|
9
|
-
@data = objectify_data
|
10
|
-
end
|
11
|
-
|
12
|
-
# @return [Hash] The original hash.
|
13
|
-
def to_hash
|
14
|
-
hash
|
15
|
-
end
|
16
|
-
alias to_h to_hash
|
17
|
-
|
18
|
-
# @return [String] Formatted string with the class name, object id and original hash.
|
19
|
-
def inspect
|
20
|
-
"#<#{self.class}:#{object_id} {hash: #{hash.inspect}}"
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
attr_reader :hash, :data
|
26
|
-
|
27
|
-
def objectify_data
|
28
|
-
result = @hash.each_with_object({}) do |(key, value), data|
|
29
|
-
value = objectify_value(value)
|
30
|
-
|
31
|
-
data[key.to_s] = value
|
32
|
-
end
|
33
|
-
|
34
|
-
result
|
35
|
-
end
|
36
|
-
|
37
|
-
def objectify_value(input)
|
38
|
-
return ObjectifiedHash.new(input) if input.is_a? Hash
|
39
|
-
|
40
|
-
return input unless input.is_a? Array
|
41
|
-
|
42
|
-
input.map { |curr| objectify_value(curr) }
|
43
|
-
end
|
44
|
-
|
45
|
-
# Respond to messages for which `self.data` has a key
|
46
|
-
def method_missing(method_name, *args, &block)
|
47
|
-
@data.key?(method_name.to_s) ? @data[method_name.to_s] : super
|
48
|
-
end
|
49
|
-
|
50
|
-
def respond_to_missing?(method_name, include_private = false)
|
51
|
-
@hash.keys.map(&:to_sym).include?(method_name.to_sym) || super
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|