Module: Chimps::Utils::ActsOnResource::ClassMethods

Defined in:
lib/chimps-cli/utils/acts_on_resource.rb

Instance Method Summary collapse

Instance Method Details

#allowed_resourcesObject



22
23
24
# File 'lib/chimps-cli/utils/acts_on_resource.rb', line 22

def allowed_resources
  %w[dataset collection source license]
end

#default_resource_typeObject



18
19
20
# File 'lib/chimps-cli/utils/acts_on_resource.rb', line 18

def default_resource_type
  normalize_resource_name(default_resources_type)
end

#default_resources_typeObject



14
15
16
# File 'lib/chimps-cli/utils/acts_on_resource.rb', line 14

def default_resources_type
  'datasets'
end

#normalize_resource_name(string) ⇒ Object



40
41
42
# File 'lib/chimps-cli/utils/acts_on_resource.rb', line 40

def normalize_resource_name string
  string.to_s.downcase.gsub(/s$/,'')
end

#resources_listingObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/chimps-cli/utils/acts_on_resource.rb', line 26

def resources_listing
  doc = <<DOC
In addition to #{default_resources_type}, this command can operate on
other resources at Infochimps as well.  If the first
argument passed is one of

DOC
  allowed_resources.each do |resource|
    doc << "  #{resource}\n"
  end

  doc << "\nthen this command will act on that resource instead."
end