chronicle-github 0.1.0

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
+ SHA256:
3
+ metadata.gz: 810f7ec8bdae2b41566f3a49b524fa0532bfe3663f9e0185135503439ec31f61
4
+ data.tar.gz: '09ecce50199d63d55c106a08c7d4350a46b2d36db84d7417020e2d2cd4466a07'
5
+ SHA512:
6
+ metadata.gz: d28c2f2f6fbdd6f10b5c2ad52c5b5eed0f82fd4f302f04c4da72d2a046e3e1be066499990343781994f7e41eae3715c44f1048c618fffb23864457454728afc6
7
+ data.tar.gz: 1d47fa00f114802005103ede182b2daf3c4ce1e19609642fa7f1cf623d7b4e4aedf853985a1bb5137ee3002e0db6dee547e45dcd52d3e3172c1fd76e667e47de
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders 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, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at andrew@hyfen.net. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in chronicle-github.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Chronicle::Github
2
+ [![Gem Version](https://badge.fury.io/rb/chronicle-github.svg)](https://badge.fury.io/rb/chronicle-github)
3
+
4
+ Extract your Github history using the command line with this plugin for [chronicle-etl](https://github.com/chronicle-app/chronicle-etl)
5
+
6
+ ## Available Connectors
7
+ ### Extractors
8
+ - `activity` - Extractor for a user's recent events
9
+
10
+ ### Transformers
11
+ - Pending
12
+
13
+ ## Usage
14
+
15
+ ```sh
16
+ # Install chronicle-etl and this plugin
17
+ $ gem install chronicle-etl
18
+ $ chronicle-etl connectors:install github
19
+
20
+ # You can get a Github personal access token from https://github.com/settings/tokens
21
+ $ chronicle-etl secrets:set github access_token FOO123
22
+
23
+ # Extract github events from the last 10 days
24
+ $ chronicle-etl --extractor github:activity --since 10d
25
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/chronicle/github/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "chronicle-github"
7
+ spec.version = Chronicle::Github::VERSION
8
+ spec.authors = ["Andrew Louis"]
9
+ spec.email = ["andrew@hyfen.net"]
10
+
11
+ spec.summary = "Github connectors for Chronicle-ETL"
12
+ spec.description = "Extract github user event stream, repository events, and more"
13
+ spec.homepage = "https://github.com/chronicle-app/chronicle-github"
14
+ spec.required_ruby_version = ">= 2.7.0"
15
+ spec.license = "MIT"
16
+
17
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/chronicle-app/chronicle-github"
21
+ spec.metadata["changelog_uri"] = "https://github.com/chronicle-app/chronicle-github/releases"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "chronicle-etl", "~> 0.5"
35
+ spec.add_dependency "octokit", "~> 4.0"
36
+ end
@@ -0,0 +1,54 @@
1
+ require 'chronicle/etl'
2
+ require 'octokit'
3
+
4
+ module Chronicle
5
+ module Github
6
+ class ActivityExtractor < Chronicle::ETL::Extractor
7
+ register_connector do |r|
8
+ r.provider = 'github'
9
+ r.description = 'user activity'
10
+ r.identifier = 'activity'
11
+ end
12
+
13
+ setting :access_token, required: true
14
+ setting :username
15
+
16
+ def prepare
17
+ @client = ::Octokit::Client.new(access_token: @config.access_token)
18
+ @access_token_owner = @client.user
19
+ end
20
+
21
+ def results_count
22
+ end
23
+
24
+ def extract
25
+ events = @client.user_events(username)
26
+ has_more = events.any?
27
+ count = 0
28
+
29
+ while has_more
30
+ events = events.first(@config.limit - count) if @config.limit
31
+ events = events.filter { |event| event.created_at > @config.since } if @config.since
32
+
33
+ break unless events.any?
34
+
35
+ events.each do |event|
36
+ count += 1
37
+ yield Chronicle::ETL::Extraction.new(data: event, meta: { user: @user})
38
+ end
39
+
40
+ break unless @client.last_response.rels[:next]
41
+
42
+ events = @client.get(@client.last_response.rels[:next].href)
43
+ has_more = events.any?
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def username
50
+ @config.username || @access_token_owner.login
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Chronicle
4
+ module Github
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "github/version"
4
+ require_relative "github/activity_extractor"
5
+
6
+ module Chronicle
7
+ module Github
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chronicle-github
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Louis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chronicle-etl
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ description: Extract github user event stream, repository events, and more
42
+ email:
43
+ - andrew@hyfen.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - CODE_OF_CONDUCT.md
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - chronicle-github.gemspec
53
+ - lib/chronicle/github.rb
54
+ - lib/chronicle/github/activity_extractor.rb
55
+ - lib/chronicle/github/version.rb
56
+ homepage: https://github.com/chronicle-app/chronicle-github
57
+ licenses:
58
+ - MIT
59
+ metadata:
60
+ allowed_push_host: https://rubygems.org
61
+ homepage_uri: https://github.com/chronicle-app/chronicle-github
62
+ source_code_uri: https://github.com/chronicle-app/chronicle-github
63
+ changelog_uri: https://github.com/chronicle-app/chronicle-github/releases
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.7.0
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.3.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Github connectors for Chronicle-ETL
83
+ test_files: []