Permalink
Browse files

reorganized code, updated README, added gemspec

  • Loading branch information...
1 parent 2280731 commit 0ed3123749e28e2bbefe0592250c51691bb9ae25 Michael committed Dec 21, 2008
View
@@ -1,2 +1,4 @@
.DS_Store
-doc/
+doc
+.todo
+*.gem
View
24 README
@@ -1,24 +0,0 @@
-rSnipt
-- Michael Boutros (me@michaelboutros)
-
--- Introduction
-"Snipt is your collection of frequently used commands or code snippets." The aim of this library is to provide
-an easy to use interface for developers to create new applications that can use Snipt. For example, imagine this:
-
-$ ./script/generate model User username:string password:string admin:boolean
-$ snipt !! -d 'generate generic user model' -t 'ruby, rails, model' -p false
-
-I know many developers live in their terminal, so this could be extremely useful. Also:
-
-$ snipt -d 'generate generic user model'
-
-Which would then execute the command that was created, whether from the website or from this library.
-
--- Progress
-At present, you can completely manipulate a user's snipts (add/edit/delete), as well get public snipts. Next on the list is retrieving by tag, etc. until almost all of the website's functionality is available through the API.
-
--- Contribution
-Just request a pull, and there is a 99% chance I'll take it, as long as it doesn't break anything.
-
--- Usage and Tests
-For usage examples, just browse the source. As for tests, I've found that testing scraping libraries is flaky at best, so the only testing I've done is just verifying data. If someone would like to write a full test suite for the library, then please, feel free to do so.
View
@@ -0,0 +1,16 @@
+rsnipt
+- Michael Boutros (me@michaelboutros)
+
+-- Introduction
+"Snipt is your collection of frequently used commands or code snippets." The aim of this library is to provide
+an easy to use interface for developers to create new applications that can use Snipt. At the same time, a CLI
+is provided in order to provide extremely easy access to the library's funtionality. Run 'snipt --help' for more information on that.
+
+-- Progress
+At present, almost all / all functionality of the website is implemented. I say all because it does everything that I would need, but I say almost all because someone else might come along and want something new. If you do want something new, feel free to do it yourself, or send me an email.
+
+-- Contribution
+I'm eagerly awaiting any pull requests, and unless your code causes pain to small kittens, it will most likely be accepted.
+
+-- Usage and Tests
+For usage examples, just browse the source until the full docs are written. As for tests, I haven't found any way of testing libraries that scrape websites. If anyone has any suggestions, feel free to put them forth.
View
@@ -1,13 +1,16 @@
#!/usr/bin/env ruby
-if ARGV.length == 0 || ARGV[0] == '--help'
- puts 'usage'
- exit
-end
-
args = ARGV.dup
ARGV.clear
-require File.dirname(__FILE__) + '/../lib/cli.rb'
-require File.dirname(__FILE__) + '/../rsnipt.rb'
+commands = ['add', 'exec']
+if args.length == 0 || args[0] == '--help'
+ puts 'usage: snipt <command> [data]'
+ puts "commands: #{commands.join(', ')} (run with --help for options)"
+
+ exit
+end
+
+require File.dirname(__FILE__) + '/../lib/rsnipt/cli.rb'
+require File.dirname(__FILE__) + '/../lib/rsnipt.rb'
SniptCLI.new(args.shift, args)
View
@@ -1,6 +1,8 @@
require 'rsnipt'
client = Snipt.new('username', 'password')
+client.detailed_return = true
+
if client.logged_in?
client.snipts # all of the user's snipts
# => [SniptStruct, SniptStruct, etc.]
View
@@ -0,0 +1,10 @@
+require 'rubygems'
+require 'json'
+require 'mechanize'
+
+path = File.dirname(__FILE__)
+
+require "#{path}/rsnipt/initialize"
+require "#{path}/rsnipt/actions"
+require "#{path}/rsnipt/snipt_struct"
+require "#{path}/rsnipt/snipts"
File renamed without changes.
@@ -105,16 +105,16 @@ def exec(arguments)
end
def attempt_login
- username = ask_for_username
- password = ask_for_password
+ username = ask_for_username
+ password = ask_for_password
- @client = Snipt.new(username, password)
- @client.detailed_return = true
+ @client = Snipt.new(username, password)
+ @client.detailed_return = true
- unless @client.logged_in?
- puts 'Authentication failed.'
- exit
- end
+ unless @client.logged_in?
+ puts 'Authentication failed.'
+ exit
+ end
end
def ask_for_username
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,32 @@
+Gem::Specification.new do |s|
+ s.name = "rsnipt"
+ s.version = "0.9"
+ s.summary = "A Ruby library and CLI to interact with Snipt.net."
+ s.email = "me@michaelboutros.com"
+ s.homepage = "http://github.com/michaelboutros/rsnipt"
+ s.description = "A Ruby library and CLI to interact with Snipt.net, whether as a user logged in or as a browser."
+ s.has_rdoc = true
+ s.authors = ["Michael Boutros"]
+ s.files = ["README.txt",
+ "rsnipt.gemspec",
+ "lib/rsnipt.rb",
+ "lib/rsnipt/actions.rb",
+ "lib/rsnipt/cli.rb",
+ "lib/rsnipt/initialize.rb",
+ "lib/rsnipt/snipt_struct.rb",
+ "lib/rsnipt/snipts.rb",
+ "examples/with_user.rb",
+ "examples/without_user.rb",
+ "bin/snipt"]
+
+ s.executables = [ "snipt" ]
+ s.default_executable = "snipt"
+
+ s.require_path = "lib"
+ s.bindir = "bin"
+
+ s.rdoc_options = ["--main", "Snipt"]
+ s.extra_rdoc_files = ["README.txt"]
+
+ s.add_dependency("mechanize", ["> 0.0.0"])
+end
View
@@ -1,10 +0,0 @@
-require 'rubygems'
-require 'json'
-require 'mechanize'
-
-path = File.dirname(__FILE__)
-
-require "#{path}/lib/initialize"
-require "#{path}/lib/actions"
-require "#{path}/lib/snipt_struct"
-require "#{path}/lib/snipts"

0 comments on commit 0ed3123

Please sign in to comment.