middleman-github_api 0.0.1

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: 2e24b0955ede93b85cae094908796f8ad923124c
4
+ data.tar.gz: 8a144a2c18260c6e959118f11b3d61fe0b34e3f5
5
+ SHA512:
6
+ metadata.gz: df1e5b819b14d2006b0d7356f29b4b09ba6e90bf3010326baf0d39f9085287be3a3c82ef99a90a5bdc177cd4d42f93840493d310d8237498d15d2a83eb5e0f01
7
+ data.tar.gz: 6192650fe43d06398ba30dd91f294153f9ecbb671c2ffaef9bb1e3ad742c3b797bbf1fedbc3e9fffdc78ef8c02cf1b8116a0fde2eb1cfe650d494bf6cbe9a9d1
@@ -0,0 +1,3 @@
1
+ /Gemfile.lock
2
+ /pkg
3
+ /tmp
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-github_api.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'rake'
10
+ gem 'rdoc'
11
+ gem 'yard'
12
+ end
13
+
14
+ group :test do
15
+ gem 'cucumber'
16
+ gem 'aruba'
17
+ gem 'rspec'
18
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Masafumi Yokoyama <myokoym@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,45 @@
1
+ # Middleman::GithubApi
2
+
3
+ A [Middleman][] extension for GitHub API.
4
+
5
+ [Middleman]: https://middlemanapp.com/
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'middleman-github_api'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install middleman-github_api
20
+
21
+ ## Usage
22
+
23
+ Set access token for environment variables:
24
+
25
+ ```bash
26
+ $ export MIDDLEMAN_GITHUB_API_ACCESS_TOKEN=xxx
27
+ ```
28
+
29
+ config.rb:
30
+
31
+ ```ruby
32
+ activate :github_api, repo: "myokoym/middleman-github_api"
33
+ ```
34
+
35
+ source:
36
+
37
+ ```erb
38
+ <% data.github_api[:commits].each do |commit| %>
39
+ <% commit.files.each do |file| %>
40
+ <pre>
41
+ <%= file.patch %>
42
+ </pre>
43
+ <% end %>
44
+ <% end %>
45
+ ```
@@ -0,0 +1,14 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = "--color --tags ~@wip --strict"
8
+ end
9
+
10
+ require 'rake/clean'
11
+
12
+ task test: ['cucumber']
13
+
14
+ task default: :test
@@ -0,0 +1,23 @@
1
+ Feature: middleman-github_api is activated
2
+
3
+ Scenario: Activate middleman-github_api
4
+ Given a fixture app "empty-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :github_api, repo: "myokoym/middleman-github_api"
8
+ """
9
+ When I run `middleman build --verbose`
10
+ Then the exit status should be 0
11
+ And the output should not contain "Unknown Extension: github_api"
12
+
13
+ Scenario: Activate middleman-github_api using block
14
+ Given a fixture app "empty-app"
15
+ And a file named "config.rb" with:
16
+ """
17
+ activate :github_api do |github_api|
18
+ github_api.repo = "myokoym/middleman-github_api"
19
+ end
20
+ """
21
+ When I run `middleman build --verbose`
22
+ Then the exit status should be 0
23
+ And the output should not contain "Unknown Extension: github_api"
@@ -0,0 +1,29 @@
1
+ Feature: data
2
+
3
+ Scenario: target repository
4
+ Given a fixture app "empty-app"
5
+ And a file named "config.rb" with:
6
+ """
7
+ activate :github_api, repo: "myokoym/middleman-github_api"
8
+ """
9
+ And a file named "source/index.html.erb" with:
10
+ """
11
+ <%= data.github_api[:repository] %>
12
+ """
13
+ When I run `middleman build --verbose`
14
+ Then the exit status should be 0
15
+ And the file "build/index.html" should contain "myokoym/middleman-github_api"
16
+
17
+ Scenario: commits (no access token)
18
+ Given a fixture app "empty-app"
19
+ And a file named "config.rb" with:
20
+ """
21
+ activate :github_api, repo: "myokoym/middleman-github_api"
22
+ """
23
+ And a file named "source/index.html.erb" with:
24
+ """
25
+ <%= data.github_api[:commits].size %>
26
+ """
27
+ When I run `middleman build --verbose`
28
+ Then the exit status should be 0
29
+ And the file "build/index.html" should contain "0"
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require 'middleman-core'
3
+ require 'middleman-core/step_definitions'
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-github_api')
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ # Require core library
2
+ require 'middleman-core'
3
+
4
+ ::Middleman::Extensions.register(:github_api) do
5
+ require 'middleman-github_api/extension'
6
+ ::Middleman::GithubApi::Extension
7
+ end
@@ -0,0 +1,59 @@
1
+ module Middleman::GithubApi
2
+ class Extension < ::Middleman::Extension
3
+ option :repo, nil, 'target repository'
4
+
5
+ def initialize(app, options_hash={}, &block)
6
+ # Call super to build options from the options_hash
7
+ super
8
+ @app = app.inst
9
+
10
+ repository = options_hash[:repo]
11
+ unless repository
12
+ $stderr.puts("middleman-github_api: repository option is missing")
13
+ return
14
+ end
15
+
16
+ hash = {
17
+ repository: repository,
18
+ }
19
+
20
+ require "octokit"
21
+ access_token = ENV["MIDDLEMAN_GITHUB_API_ACCESS_TOKEN"]
22
+ unless access_token
23
+ $stderr.puts("middleman-github_api: GitHub access token is missing")
24
+ $stderr.puts("Set token to MIDDLEMAN_GITHUB_API_ACCESS_TOKEN of environment variables")
25
+ $stderr.puts("e.g.: $ export MIDDLEMAN_GITHUB_API_ACCESS_TOKEN=xxx")
26
+ hash[:commits] = []
27
+ @app.data.store(:github_api, hash)
28
+ return
29
+ end
30
+
31
+ client = Octokit::Client.new(access_token: access_token)
32
+ date = Time.now.strftime("%Y-%m-%d")
33
+ raw_commits = client.commits_on(repository, date)
34
+ commits = []
35
+ raw_commits.each do |commit|
36
+ commits << client.commit(repository, commit.sha)
37
+ end
38
+ hash[:commits] = commits
39
+
40
+ @app.data.store(:github_api, hash)
41
+
42
+ # set up your extension
43
+ # puts options.my_option
44
+ end
45
+
46
+ def after_configuration
47
+ # Do something
48
+ end
49
+
50
+ # A Sitemap Manipulator
51
+ # def manipulate_resource_list(resources)
52
+ # end
53
+
54
+ # module do
55
+ # def a_helper
56
+ # end
57
+ # end
58
+ end
59
+ end
@@ -0,0 +1 @@
1
+ require 'middleman-github_api'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-github_api"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Masafumi Yokoyama"]
9
+ s.email = ["myokoym@gmail.com"]
10
+ s.homepage = "https://github.com/myokoym/middleman-github_api"
11
+ s.summary = %q{A Middleman extension for GitHub API.}
12
+ s.description = s.summary
13
+ s.license = "MIT"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # The version of middleman-core your extension depends on
21
+ s.add_runtime_dependency("middleman-core", [">= 3.4.0"])
22
+ s.add_runtime_dependency("octokit", "~> 4.0")
23
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-github_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Masafumi Yokoyama
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.4.0
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: A Middleman extension for GitHub API.
42
+ email:
43
+ - myokoym@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - features/activate.feature
54
+ - features/data.feature
55
+ - features/support/env.rb
56
+ - fixtures/empty-app/config.rb
57
+ - fixtures/empty-app/source/.gitkeep
58
+ - lib/middleman-github_api.rb
59
+ - lib/middleman-github_api/extension.rb
60
+ - lib/middleman_extension.rb
61
+ - middleman-github_api.gemspec
62
+ homepage: https://github.com/myokoym/middleman-github_api
63
+ licenses:
64
+ - MIT
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A Middleman extension for GitHub API.
86
+ test_files: []