class Serialbar::CLI
Public Class Methods
source_root()
click to toggle source
# File lib/serialbar/cli.rb, line 11 def self.source_root File.dirname(__FILE__) end
Public Instance Methods
insert_data_file(name,adapter)
click to toggle source
# File lib/serialbar/cli.rb, line 65 def insert_data_file(name,adapter) create_file "#{name}/data_file.rb" do Serialbar::BoilerPlate.data_file_class end str = Serialbar::BoilerPlate.config_adapter_string(adapter) insert_into_file "#{name}/data_file.rb", str , :after => "include Serialbox::Adapters\n" end
insert_file_system()
click to toggle source
when developed
# File lib/serialbar/cli.rb, line 82 def insert_file_system #append instructions to readme end
insert_listener(name)
click to toggle source
# File lib/serialbar/cli.rb, line 75 def insert_listener(name) create_file "#{name}/listener.rb" do Serialbar::BoilerPlate.listener_class end end
insert_mongoid(name)
click to toggle source
# File lib/serialbar/cli.rb, line 60 def insert_mongoid(name) copy_file "generators/mongoid_example.yml", "#{name}/mongoid_example.yml" #append specific instructions to readme end
list_adapters()
click to toggle source
# File lib/serialbar/cli.rb, line 16 def list_adapters say "Currently available adapters" say "\tmongoid" end
new(name)
click to toggle source
# File lib/serialbar/cli.rb, line 23 def new(name) say "creating a new serialbar project #{name}", :green readme(name) # create readme file in project dir case options[:adapter] when "mongoid" say 'Using mongoid adapter', :green insert_mongoid(name) insert_data_file(name,"mongoid") else say 'Adapter type unknown', :red #invoke(:list_adapters,"") end insert_listener(name) end
readme(name)
click to toggle source
# File lib/serialbar/cli.rb, line 53 def readme(name) #create readme file and insert the contents #str = "text to read" #copy_file "generators/README", "#{name}/README" #insert_into_file "#{name}/README", str end
usage()
click to toggle source
# File lib/serialbar/cli.rb, line 41 def usage puts <<-DES Usage: Serialbox help [command] Description: A simple app to create a database or file based storage adapter for serial port data DES help end