orion 0.0.2 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 748377c858db4daa18b3c1b7c8badf17849d3ab5
4
- data.tar.gz: 15d61cfdf1c3b10991e6efbc9372368a68b96839
3
+ metadata.gz: 142f0738a84b14879a801534a2a582b442078d27
4
+ data.tar.gz: f2bf18e3513faa642b8529d9645bbed978f63861
5
5
  SHA512:
6
- metadata.gz: 8120de11ffddb77a16558b5a5f048be324c43150486ec206da3ea60af9a43d68110626e7994fb2166581a55dd98a27b1b7f2348b73af7425ad2631af6c3357af
7
- data.tar.gz: b4402d9973f498b1ae9708daacd49e228f1d7ed3f021d2b7039c9173da131d463ed131eaf96a3ba918af47436218de496f2e3a4bfeeda95d5e5ea4fb3d4ce762
6
+ metadata.gz: 03df67ff4fb3b9d79a6047f0e8cfebc2509fff6326d3a47ebe15aca4eb08facf64da5e04ead7e700f0f652fcf8c9f9fa03c5b2b2da877b19427a520466657f9b
7
+ data.tar.gz: 4f9a11da2b86a0cf54360e42cee99a6f6d3b1300ac33c1a18c1238dbc579d174fc36cb9cb3800b16af0e86f8f5cede0f883cdcc52dabbe04e76dcd9991f51d3b
data/lib/orion/delete.rb CHANGED
@@ -1,5 +1,4 @@
1
- require 'orion/result'
2
- include Orion::Result
1
+ require "orion/orion_objects/array"
3
2
 
4
3
  module Orion
5
4
  module Delete
@@ -8,7 +7,7 @@ module Orion
8
7
  end
9
8
 
10
9
  def self.with_response(files)
11
- result(delete_files(files))
10
+ delete_files(files).to_orion
12
11
  end
13
12
 
14
13
  private
data/lib/orion/info.rb ADDED
@@ -0,0 +1,35 @@
1
+ require "orion/orion_objects/hash"
2
+ require "orion/orion_support/i18n"
3
+
4
+ module Orion
5
+ class Info
6
+ def initialize(path)
7
+ @path ||= path
8
+ end
9
+
10
+ def info(*methods)
11
+ methods = Info.available_methods & methods
12
+ if methods.empty?
13
+ raise I18n.t("errors.get_info.no_correct_methods", methods: Info.available_methods.join(", "))
14
+ else
15
+ methods.one? ? single_method(methods.first) : find_info_from(methods).to_orion
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def find_info_from(methods)
22
+ Hash[methods.map { |method| [method, File.send(method, @path)] }]
23
+ end
24
+
25
+ def single_method(method)
26
+ File.send(method, @path)
27
+ end
28
+
29
+ def self.available_methods
30
+ [:atime, :ctime, :mtime, :ftype, :size, :absolute_path, :basename,
31
+ :directory?, :dirname, :executable?, :exists?, :extname, :file?,
32
+ :readable?, :socket?, :symlink?, :writable?, :zero?]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ require 'ostruct'
2
+
3
+ class Array
4
+ def to_orion
5
+ self.empty? ? OpenStruct.new(success: false, count: 0, files: self) : OpenStruct.new(success: true, count: self.size, files: self)
6
+ end
7
+
8
+ def one?
9
+ self.size == 1 ? true : false
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'ostruct'
2
+
3
+ class Hash
4
+ def to_orion
5
+ OpenStruct.new(self)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'ostruct'
2
+
3
+ class NilClass
4
+ def to_orion
5
+ OpenStruct.new(success: false, count: nil, files: nil)
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ require "i18n"
2
+
3
+ I18n.load_path = Dir['locales/*.yml']
data/lib/orion/search.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'find'
2
- require 'orion/result'
3
- # require 'boyer_moore/boyer_moore'
4
- include Orion::Result
2
+ require "orion/orion_objects/array"
3
+ require "orion/orion_objects/nil"
5
4
 
6
5
  module Orion
7
6
  class Search
@@ -16,7 +15,7 @@ module Orion
16
15
  end
17
16
 
18
17
  def with_response(query)
19
- result(find(query))
18
+ find(query).to_orion
20
19
  end
21
20
 
22
21
  private
@@ -31,7 +30,5 @@ module Orion
31
30
  end
32
31
  results
33
32
  end
34
-
35
33
  end
36
-
37
34
  end
data/lib/orion/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Orion
2
- VERSION = "0.0.2"
3
- end
2
+ VERSION = "0.1.0"
3
+ end
data/lib/orion.rb CHANGED
@@ -1,10 +1,13 @@
1
+ require "orion/orion_support/i18n"
1
2
  require "orion/version"
2
3
  require "orion/search"
3
4
  require "orion/delete"
5
+ require "orion/info"
4
6
 
5
7
  module Orion
6
8
  def self.search(root_path, query)
7
- Orion::Search.new(root_path).with_response(query)
9
+ method_call = Orion::Search.new(root_path).with_response(query)
10
+ block_given? ? yield(method_call) : method_call
8
11
  end
9
12
 
10
13
  def self.delete(root_path, query)
@@ -15,4 +18,9 @@ module Orion
15
18
  Orion::Delete.delete(found_files)
16
19
  end
17
20
  end
21
+
22
+ def self.get_info(path, *methods)
23
+ method_call = Orion::Info.new(path).info(*methods)
24
+ block_given? ? yield(method_call) : method_call
25
+ end
18
26
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bismark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-17 00:00:00.000000000 Z
11
+ date: 2013-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ruby-progressbar
14
+ name: i18n
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.1.1
19
+ version: 0.6.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.1.1
26
+ version: 0.6.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,21 +66,7 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: factory_girl
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '>='
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- description: Orion allows you to search and delete files in your system.
69
+ description: Orion allows you to perform some file-related tasks in the filesystem.
84
70
  email:
85
71
  - bismark64@gmail.com
86
72
  executables: []
@@ -90,10 +76,14 @@ files:
90
76
  - lib/boyer_moore/rich_hash.rb
91
77
  - lib/boyer_moore/boyer_moore.rb
92
78
  - lib/orion.rb
79
+ - lib/orion/orion_support/i18n.rb
80
+ - lib/orion/orion_objects/array.rb
81
+ - lib/orion/orion_objects/nil.rb
82
+ - lib/orion/orion_objects/hash.rb
93
83
  - lib/orion/version.rb
94
84
  - lib/orion/delete.rb
95
- - lib/orion/result.rb
96
85
  - lib/orion/search.rb
86
+ - lib/orion/info.rb
97
87
  homepage: https://github.com/bismark64/orion
98
88
  licenses:
99
89
  - MIT
@@ -117,5 +107,5 @@ rubyforge_project:
117
107
  rubygems_version: 2.0.3
118
108
  signing_key:
119
109
  specification_version: 4
120
- summary: Orion allows you to search and delete files in your system
110
+ summary: Orion allows you to perform some file-related tasks in the filesystem
121
111
  test_files: []
data/lib/orion/result.rb DELETED
@@ -1,13 +0,0 @@
1
- module Orion
2
- module Result
3
- def result(array)
4
- if array.nil?
5
- {success: false, count: nil, files: nil}
6
- elsif array.empty?
7
- {success: false, count: 0, files: []}
8
- else
9
- {success: true ,count: array.size, files: array}
10
- end
11
- end
12
- end
13
- end