camlistore 0.0.1

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Y2JlYWUyODNiNjdhMzBmYTQ5NzE3NjAxYWRmMjI4ZjEzNDUwMDg4YQ==
5
+ data.tar.gz: !binary |-
6
+ NDI3NzVkZDBlNDU1NzhiNGNhZDc4ZmE1N2Q1NTM5MmViZWI1NDJmMw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MzMwYjRiMWNhNjdkMWU3ZmNkNmU3MmM4MmE4MDc1MDljNTBiYzU0OThjNTM2
10
+ M2U5ODIyMTcwZTk4YzMyMzIxMDE3OGJkMjRkMjVmMDU5ZTlkZWJkYWNhOTk3
11
+ NDQ4MTE1NGVkMTYwNzVkMmMyZjc3ZmE4MzA5OGNjZDcyMzBkOWE=
12
+ data.tar.gz: !binary |-
13
+ YjhlNDUyYTI0ZjdhM2UwZWI2NTA2MTdhMjgwYzNkZTAzZjQwMzI1MjVjMjg5
14
+ NmU3YTBlOWVlODFmZjVkM2UyYWM2MzNjM2FkODAwY2Q5MGFjYWMyNDE1NDAy
15
+ NDk4MzFmZWQ4MDQxNzBlMTZmZjhmZDkwNjdmZTE5NjdhNjY4ODE=
@@ -0,0 +1,2 @@
1
+ pkg
2
+ Gemfile.lock
data/LICENSE ADDED
File without changes
@@ -0,0 +1,10 @@
1
+ Example:
2
+ ======================
3
+
4
+ ```ruby
5
+ require 'camlistore'
6
+
7
+ camli = Camlistore.new
8
+ result = camli.enumerate_blobs(limit: 1)
9
+ result.blobs.first.blobRef # => "sha1-..."
10
+ ```
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'camlistore/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'camlistore'
8
+ gem.version = Camlistore::VERSION
9
+ gem.author = 'Quinn Shanahan'
10
+ gem.email = 'quinn@tastehoneyco.com'
11
+ gem.description = %q{Some access to your camlistore in ruby}
12
+ gem.summary = %q{Camlistore client}
13
+ gem.homepage = %q{https://github.com/quinn/camlistore-ruby-client}
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+ gem.add_runtime_dependency 'faraday_middleware', '~> 0.9.0'
20
+ end
@@ -0,0 +1,17 @@
1
+ require 'net/http'
2
+ require 'faraday'
3
+ require 'faraday_middleware'
4
+ require 'active_support/core_ext/object/blank'
5
+ require 'active_support/core_ext/array/wrap'
6
+ require 'active_support/core_ext/string/inflections'
7
+ require 'active_support/concern'
8
+
9
+ module Camlistore
10
+ autoload :Configuration, 'camlistore/configuration'
11
+ autoload :API, 'camlistore/api'
12
+ autoload :Client, 'camlistore/client'
13
+
14
+ def self.new *args
15
+ Client.new *args
16
+ end
17
+ end
@@ -0,0 +1,39 @@
1
+ module Camlistore
2
+
3
+ module API
4
+ extend ActiveSupport::Concern
5
+
6
+ def connection
7
+ @connection ||= Faraday.new(config.bshost) do |conn|
8
+ conn.response :mashify
9
+ conn.response :json, content_type: 'text/javascript'
10
+ conn.adapter Faraday.default_adapter
11
+ end
12
+ end
13
+
14
+ def api_call url, params = {}
15
+ response = connection.get(url, params)
16
+
17
+ data = response.body
18
+
19
+ # Camlistore doesn't seem to give errors?
20
+ # error_message = data.error_message
21
+ # raise ArgumentError, error_message if error_message
22
+
23
+ if block_given?
24
+ yield data
25
+ else
26
+ data
27
+ end
28
+ end
29
+
30
+ module ClassMethods
31
+ def api_method key, url, &block
32
+ define_method key do |params = {}|
33
+ api_call url, params, &block
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ end
@@ -0,0 +1,38 @@
1
+ module Camlistore
2
+ Configuration.namespace :camlistore
3
+ Configuration.keys :bshost
4
+ Configuration.env ENV
5
+
6
+ class Client
7
+ attr_reader :config
8
+ include API
9
+
10
+ def initialize options = {}
11
+ @config = Configuration.new(options, bshost: 'http://localhost:3179/bs/')
12
+ raise ArgumentError, "You must supply blobstore host." unless config.bshost.present?
13
+ end
14
+
15
+ api_method :enumerate_blobs, 'camli/enumerate-blobs'
16
+
17
+ def each_blob &block
18
+ data = enumerate_blobs
19
+ blobs = data.blobs
20
+
21
+ while blobs.any?
22
+ blobs.each &block
23
+
24
+ blobs = if data.continueAfter.present?
25
+ data = enumerate_blobs(after: data.continueAfter)
26
+ data.blobs
27
+ else
28
+ []
29
+ end
30
+ end
31
+ end
32
+
33
+ def get sha
34
+ api_call('camli/' + sha)
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,32 @@
1
+ module Camlistore
2
+
3
+ class Configuration
4
+ def initialize options = {}, defaults = {}
5
+ @config = {}
6
+
7
+ @@keys.each do |key|
8
+ @config[key] = options[key] || @@env["#{@@namespace.to_s.upcase}_#{key.to_s.upcase}"] || defaults[key]
9
+ end
10
+ end
11
+
12
+ def method_missing method
13
+ super unless @@keys.include? method
14
+ @config[method]
15
+ end
16
+
17
+ class << self
18
+ def keys *args
19
+ @@keys = args
20
+ end
21
+
22
+ def namespace namespace
23
+ @@namespace = namespace
24
+ end
25
+
26
+ def env env
27
+ @@env = env
28
+ end
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,3 @@
1
+ module Camlistore
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: camlistore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Quinn Shanahan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday_middleware
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ description: Some access to your camlistore in ruby
28
+ email: quinn@tastehoneyco.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - LICENSE
35
+ - README.md
36
+ - camlistore.gemspec
37
+ - lib/camlistore.rb
38
+ - lib/camlistore/api.rb
39
+ - lib/camlistore/client.rb
40
+ - lib/camlistore/configuration.rb
41
+ - lib/camlistore/version.rb
42
+ homepage: https://github.com/quinn/camlistore-ruby-client
43
+ licenses: []
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.0.7
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Camlistore client
65
+ test_files: []
66
+ has_rdoc: