social_snippet-supports-git 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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MzY3OWMyYjc1MzRmNWZiZDdkYWIwOGQ3ODI2OGM2NTljNjMxMjNkNg==
5
+ data.tar.gz: !binary |-
6
+ YzZhNDIyZjFlYzAyYjcyOGEyZDI5ZjU4ZGJmYzcxMDhiNDJkNmNhYg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTIxY2RkZTJjNGMyM2Y1NjI1MzQ3N2YxZGQ5NjE1NTk3Y2FhZjlhNmNiYzM3
10
+ NTIwOWI5ODA4MzAxN2U2MzRkM2RmNjAyNjA5MTMxMjg2N2NmOTc2ZmM3Mzg2
11
+ OGY5MWFiYWRjZmJmNzM4ZjU4MDA0YTVhOTE4MjFiNTFhYTkxYjE=
12
+ data.tar.gz: !binary |-
13
+ MTBmM2NiZjQxMzkxODAyZGRhODg5YWNhMjkzMmQ4NjU1MTIwYjZiOTQ5YjUw
14
+ OTBjMWNkY2MzNDVkYmI1NjAwN2NlMzkxOWI0YjI5NmM1OGRhNTIyNGY3ZjVl
15
+ YjNjYTg1NzljMWJiYTliNTlkNmVhMWJlNDk1NWJjZTM5ZTExMmE=
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,33 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - "2.2"
5
+ - "2.1"
6
+ - "2.0"
7
+ - "1.9"
8
+
9
+ bundler_args: "--without debug --jobs 3"
10
+
11
+ sudo: false
12
+
13
+ env:
14
+ global:
15
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=YES
16
+
17
+ script:
18
+ - bundle exec rake spec
19
+
20
+ deploy:
21
+ provider: rubygems
22
+ api_key:
23
+ master:
24
+ secure: "votwFnqKibzKsE9cBS2vXsmtewjt0ZuAj6ivBizb31dPPwLTD+naPPyRVVf+NMKUN6lPkMBzbUJ0Lcp51FDBE8UwQhcEMgOanhEVxwwCvky5aDHBT77LCsQOiwJHKVoGuQx/xDDiAsazf+3xuGOY2S5BElGggUzH2Uoc9Dvu+1w="
25
+ gem:
26
+ master: social_snippet-supports-git
27
+ on:
28
+ repo: social-snippet/social-snippet-supports-git
29
+ ruby: "2.2"
30
+
31
+ cache:
32
+ bundler: true
33
+
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in social_snippet-supports-git.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ if ::Dir.exists? "../social-snippet"
8
+ gem "byebug"
9
+ gem "social_snippet", :path => "../social-snippet"
10
+ else
11
+ gem "social_snippet", :github => "social-snippet/social-snippet"
12
+ end
13
+ end
14
+
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # SocialSnippet::Supports::Git
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/social_snippet/supports/git`. 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 'social_snippet-supports-git'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install social_snippet-supports-git
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 `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` to 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
+ 1. Fork it ( https://github.com/[my-github-username]/social_snippet-supports-git/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ require "bundler/setup"
2
+ require "bundler/gem_tasks"
3
+
4
+ task :default => [:spec]
5
+
6
+ #
7
+ # Testing
8
+ #
9
+
10
+ require "rspec/core/rake_task"
11
+
12
+ RSpec::Core::RakeTask.new(:spec) do |t|
13
+ t.rspec_opts = [
14
+ "--format documentation",
15
+ "--color",
16
+ ]
17
+ end
18
+
19
+ RSpec::Core::RakeTask.new(:spec_current) do |t|
20
+ t.rspec_opts = [
21
+ "--format documentation",
22
+ "--color",
23
+ "--tag current"
24
+ ]
25
+ end
26
+
27
+ #
28
+ # Documentation
29
+ #
30
+
31
+ require "yard"
32
+ require "yard/rake/yardoc_task"
33
+
34
+ # rake yard
35
+ YARD::Rake::YardocTask.new do |t|
36
+ t.files = [
37
+ "lib/{,**}/*.rb"
38
+ ]
39
+ end
40
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "social_snippet/supports/git"
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
data/bin/setup ADDED
@@ -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,97 @@
1
+ module SocialSnippet::Repository::Drivers
2
+
3
+ class GitDriver < DriverBase
4
+
5
+ attr_reader :rugged_repo
6
+
7
+ def fetch
8
+ dest_dir = ::Dir.mktmpdir
9
+ @rugged_repo = ::Rugged::Repository.clone_at(url, dest_dir)
10
+ end
11
+
12
+ def snippet_json
13
+ @snippet_json ||= read_snippet_json
14
+ end
15
+
16
+ def read_snippet_json
17
+ oid = rugged_repo.head.target.tree["snippet.json"][:oid]
18
+ @snippet_json ||= ::JSON.parse rugged_repo.lookup(oid).read_raw.data
19
+ end
20
+
21
+ def read_file(oid)
22
+ rugged_repo.lookup(oid).read_raw.data
23
+ end
24
+
25
+ def each_directory(ref, &block)
26
+ rugged_ref(ref).target.tree.walk_trees do |parent, tree|
27
+ yield ::SocialSnippet::Repository::Drivers::Entry.new(join_path(parent, tree[:name]))
28
+ end
29
+ end
30
+
31
+ def each_file(ref, &block)
32
+ rugged_ref(ref).target.tree.walk_blobs do |parent, item|
33
+ yield ::SocialSnippet::Repository::Drivers::Entry.new(join_path(parent, item[:name]), read_file(item[:oid]))
34
+ end
35
+ end
36
+
37
+ def join_path(a, b)
38
+ if a.empty?
39
+ b
40
+ else
41
+ ::File.join a, b
42
+ end
43
+ end
44
+
45
+ def current_ref
46
+ rugged_repo.head.name.gsub /^refs\/heads\//, ""
47
+ end
48
+
49
+ def rugged_ref(ref_name)
50
+ rugged_repo.references.each("refs/*/#{ref_name}").first
51
+ end
52
+
53
+ def rev_hash(ref)
54
+ rugged_ref(ref).target_id
55
+ end
56
+
57
+ def refs
58
+ all_refs = []
59
+ all_refs.concat remote_refs
60
+ all_refs.concat tags
61
+ all_refs
62
+ end
63
+
64
+ def remote_refs
65
+ rugged_repo.references.each("refs/remotes/origin/**/*").map do |r|
66
+ r.name.match(/^refs\/remotes\/origin\/(.*)/)[1]
67
+ end
68
+ end
69
+
70
+ def tags
71
+ rugged_repo.references.each("refs/tags/**/*").map do |r|
72
+ r.name.match(/^refs\/tags\/(.*)/)[1]
73
+ end
74
+ end
75
+
76
+ class << self
77
+
78
+ def target_url?(url)
79
+ uri = ::URI.parse(url)
80
+ is_git_uri(uri)
81
+ end
82
+
83
+ def is_git_uri(uri)
84
+ /git|https?/ === uri.scheme
85
+ end
86
+
87
+ def target_path?(path)
88
+ ::File.directory?(path) && ::File.directory?(::File.join path, ".git")
89
+ end
90
+
91
+ end # class << self
92
+
93
+ end # GitDriver
94
+
95
+ ::SocialSnippet::Repository::DriverFactory.add_driver GitDriver
96
+
97
+ end # SocialSnippet
@@ -0,0 +1,10 @@
1
+ require "social_snippet/supports/git/version"
2
+ require "social_snippet/repository/drivers/git_driver"
3
+
4
+ module SocialSnippet
5
+ module Supports
6
+ module Git
7
+ # Your code goes here...
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module SocialSnippet
2
+ module Supports
3
+ module Git
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'social_snippet/supports/git/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "social_snippet-supports-git"
8
+ spec.version = SocialSnippet::Supports::Git::VERSION
9
+ spec.authors = ["Hiroyuki Sano"]
10
+ spec.email = ["sh19910711@gmail.com"]
11
+
12
+ if spec.respond_to?(:metadata)
13
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
+ end
15
+
16
+ spec.summary = %q{Git Repository Supports}
17
+ spec.homepage = "https://github.com/social-snippet/social-snippet-supports-git"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.required_ruby_version = ">= 1.9.3"
26
+
27
+ spec.add_runtime_dependency "rugged", ["~> 0.21.4", ">= 0.21.4"]
28
+
29
+ spec.add_development_dependency "bundler"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "yard"
32
+ spec.add_development_dependency "rspec"
33
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: social_snippet-supports-git
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroyuki Sano
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rugged
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.21.4
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.21.4
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.21.4
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.21.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: yard
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description:
90
+ email:
91
+ - sh19910711@gmail.com
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - .gitignore
97
+ - .travis.yml
98
+ - Gemfile
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/social_snippet/repository/drivers/git_driver.rb
104
+ - lib/social_snippet/supports/git.rb
105
+ - lib/social_snippet/supports/git/version.rb
106
+ - social_snippet-supports-git.gemspec
107
+ homepage: https://github.com/social-snippet/social-snippet-supports-git
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: ! 'TODO: Set to ''http://mygemserver.com'' to prevent pushes
112
+ to rubygems.org, or delete to allow pushes to any server.'
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: 1.9.3
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.5
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Git Repository Supports
133
+ test_files: []