Browse files

first commit

  • Loading branch information...
0 parents commit 20dc6c443477dd4ad68fe4d888eaf69e7126d483 @txus committed Dec 6, 2011
Showing with 101 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +4 −0 Gemfile
  3. +23 −0 Rakefile
  4. +3 −0 Readme.md
  5. +5 −0 lib/springpad.rb
  6. +13 −0 lib/springpad/api.rb
  7. +3 −0 lib/springpad/version.rb
  8. +27 −0 springpad.gemspec
  9. +14 −0 test/springpad/api_test.rb
  10. +5 −0 test/test_helper.rb
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
4 Gemfile
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in springpad.gemspec
+gemspec
23 Rakefile
@@ -0,0 +1,23 @@
+# encoding: utf-8
+require 'bundler'
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.test_files = FileList['./test/**/*_test.rb']
+end
+
+desc "Checks the user has appropriate credentials"
+task :check_credentials do
+ begin
+ config = YAML.load(File.read(File.expand_path("~/.springpad")))
+ rescue
+ raise StandardError, "File ~/.springpad does not exist. You must create it in a YAML format with 'user', 'password' and 'token' fields."
+ end
+ unless config['user'] && config['password'] && config['token']
+ raise StandardError, "One of the three fields (either user, password or token) is not filled properly in ~/.springpad. Please check it."
+ end
+end
+
+task :default => [:check_credentials, :test]
3 Readme.md
@@ -0,0 +1,3 @@
+# springpad
+
+Command-line client for [Springpad](http://springpadit.com). Currently WIP.
5 lib/springpad.rb
@@ -0,0 +1,5 @@
+require_relative "springpad/version"
+require_relative "springpad/api"
+
+module Springpad
+end
13 lib/springpad/api.rb
@@ -0,0 +1,13 @@
+require 'yaml'
+
+module Springpad
+ class API
+ attr_reader :user, :password, :token
+ def initialize
+ config = YAML.load(File.read(File.expand_path("~/.springpad")))
+ @user = config['user']
+ @password = config['password']
+ @token = config['token']
+ end
+ end
+end
3 lib/springpad/version.rb
@@ -0,0 +1,3 @@
+module Springpad
+ VERSION = "0.0.1"
+end
27 springpad.gemspec
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "springpad/version"
+
+Gem::Specification.new do |s|
+ s.name = "springpad"
+ s.version = Springpad::VERSION
+ s.authors = ["Josep M. Bach"]
+ s.email = ["josep.m.bach@gmail.com"]
+ s.homepage = "http://github.com/txus/springpad"
+ s.summary = %q{Command-line client for Springpad.}
+ s.description = %q{Command-line client for Springpad.}
+
+ s.rubyforge_project = "springpad"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ # specify any dependencies here; for example:
+ s.add_development_dependency "minitest"
+ s.add_development_dependency "mocha"
+ s.add_development_dependency "vcr"
+ s.add_development_dependency "webmock"
+ s.add_runtime_dependency "rest-client"
+end
14 test/springpad/api_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+
+module Springpad
+ describe API do
+ it 'initializes a user and password from ~/.springpad' do
+ config = YAML.load(File.read(File.expand_path("~/.springpad")))
+
+ api = API.new
+ api.user.must_equal config['user']
+ api.password.must_equal config['password']
+ api.token.must_equal config['token']
+ end
+ end
+end
5 test/test_helper.rb
@@ -0,0 +1,5 @@
+gem 'minitest'
+require 'minitest/spec'
+require 'minitest/autorun'
+require 'mocha'
+require_relative '../lib/springpad'

0 comments on commit 20dc6c4

Please sign in to comment.